neontsun/read-attribute

Utils for reading attributes

1.1.0 2025-02-26 09:53 UTC

This package is auto-updated.

Last update: 2025-04-26 10:07:38 UTC


README

#[\Attribute(\Attribute::TARGET_CLASS)]
final class CustomAttribute {}

#[CustomAttribute]
final class Foo
{

}

use Neontsun\ReadAttribute\ReadAttribute;

final class Controller 
{
    use ReadAttribute;
    
    public function __invoke() 
    {
        $attribute = $this->readClassAttribute(Foo::class, CustomAttribute::class);
        
        if ($attribute instanceof CustomAttribute) {
            // true
        }
    }
}