# Attribute Class

Namespace:

```
AntonDPerera\PHPAttributesReader\Attribute
```

\
The Attribute class on PHP Attributes Reader library is a class that helps to access details of a PHP attribute which was fetched through the `AttributesReader`<br>

PHP Class with Class Attributes

```php
<?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 and retrieve an attribute

```php
<?php

declare(strict_types=1);

use \AntonDPerera\PHPAttributesReader\AttributesReader;

$class = Abc::class;

$attributes_reader = AttributesReader($class);

//This will return instance of AntonDPerera\PHPAttributesReader\Attribute
$attributes_reader->getClassAttribute("TestAttribute11");
```

Refer to [Class Attributes](https://anton-d-perera.gitbook.io/php-attributes-reader/reading-attributes/class-attributes) , [Method Attributes](https://anton-d-perera.gitbook.io/php-attributes-reader/reading-attributes/method-attributes) and [Property Attributes](https://anton-d-perera.gitbook.io/php-attributes-reader/reading-attributes/property-attributes) guides to see how to get attributes from the `AttributesReader`.<br>

### Available functions in Attribute class

```php
public function getClass(): string
```

Returns namespace of the Attribute class\
\
Caution:\
if there isn't a specific class with the Attribute name then this won't be a valid class namespace)<br>

```php
public function getName(): string
```

Returns name of the attribute.<br>

```php
public function hasArguments(): bool
```

Returns `true` or `false` based on availability of arguments of the attribute.<br>

```php
public function getArguments(): array
```

Returns an array of Arguments for the Attribute. Each item on array will be an instance of Argument class\
`\AntonDPerera\PHPAttributesReader\Argument`

Refer [Argument class Reference](https://anton-d-perera.gitbook.io/php-attributes-reader/reading-attributes/argument-class) documentation for more details.<br>
