> For the complete documentation index, see [llms.txt](https://anton-d-perera.gitbook.io/php-attributes-reader/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://anton-d-perera.gitbook.io/php-attributes-reader/reading-attributes/class-attributes.md).

# Class Attributes

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

```php
<?php

declare(strict_types=1);

use \AntonDPerera\PHPAttributesReader\AttributesReader;

$class = Abc::class;

$attributes_reader = AttributesReader($class);
```

### Available functions for Class Attributes&#x20;

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

Returns `true` or `false` based on availability of Class attributes.

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

Returns array of attributes. Each item on Array will be an instance of Attribute class

```php
\AntonDPerera\PHPAttributesReader\Attribute
```

Refer [Attribute class Reference documentation](/php-attributes-reader/reading-attributes/attribute-class.md) for more details.

```php
public function getClassAttribute(string $attribute_name): Attribute | ClassAttributeNotFoundException
```

1. Throws `ClassAttributeNotFoundException` when the given attribute name is not available as a Class Attribute.\
   `\`AntonDPerera\PHPAttributesReader\Exceptions\ClassAttributeNotFoundException
2. Returns an instance of `Attribute` if there is a Class attribute with the given name.\
   `\AntonDPerera\PHPAttributesReader\Attribute`
