petrknap/has-requirements

Simple trait to check if requirements of your code are fulfilled

Maintainers

Package info

github.com/petrknap/php-has-requirements

pkg:composer/petrknap/has-requirements

Fund package maintenance!

Other

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-04-11 07:30 UTC

This package is auto-updated.

Last update: 2026-04-11 07:36:42 UTC


README

final class ServiceWithRequirements {
    use PetrKnap\HasRequirements\HasRequirements;
    
    public function __construct() {
        self::checkRequirements(functions: ['required_function']);
    }

    public function do(): void {
        required_function();
    }
}

It should not replace Composers requires, but it could improve them and check suggests.

Run composer require petrknap/has-requirements to install it. You can support this project via donation. The project is licensed under the terms of the LGPL-3.0-or-later.