Class Attributes
PHP Class with Class Attributes
<?php
declare(strict_types=1);
#[TestAttribute11(["key1" => "key1 value"])]
#[TestAttribute12(10.13)]
#[TestAttribute13(123)]
#[TestAttribute14()]
#[TestAttribute15(["value1", "value2"])]
class Abc
{
// rest of the codes
}Initialize the Attributes Reader
<?php
declare(strict_types=1);
use \AntonDPerera\PHPAttributesReader\AttributesReader;
$class = Abc::class;
$attributes_reader = AttributesReader($class);Available functions for Class Attributes
public function hasClassAttributes(): boolReturns true or false based on availability of Class attributes.
public function getClassAttributes(): arrayReturns array of attributes. Each item on Array will be an instance of Attribute class
\AntonDPerera\PHPAttributesReader\AttributeRefer Attribute class Reference documentation for more details.
public function getClassAttribute(string $attribute_name): Attribute | ClassAttributeNotFoundExceptionThrows
ClassAttributeNotFoundExceptionwhen the given attribute name is not available as a Class Attribute.\AntonDPerera\PHPAttributesReader\Exceptions\ClassAttributeNotFoundExceptionReturns an instance of
Attributeif there is a Class attribute with the given name.\AntonDPerera\PHPAttributesReader\Attribute
Last updated