> 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/argument-class.md).

# Argument Class

Namespace:

```
AntonDPerera\PHPAttributesReader\Argument
```

\
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 and arguments(values) on those 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

<pre class="language-php"><code class="lang-php">&#x3C;?php

declare(strict_types=1);

use \AntonDPerera\PHPAttributesReader\AttributesReader;

$class = Abc::class;

$attributes_reader = AttributesReader($class);

//This will return instance of AntonDPerera\PHPAttributesReader\Attribute
<strong>$attribute = $attributes_reader->getClassAttribute("TestAttribute11");
</strong><strong>$arguments = $attribute->getArguments();
</strong><strong>echo $arguments[0]->getType(); // return the value of constant Argument::ARGUMENT_VALUE_TYPE_ASSOCIATIVE_ARRAY
</strong>var_dump($arguments[0]->getValue()); // return array("key1" => "key1 value")
<strong>
</strong></code></pre>

Refer to [Class Attributes](/php-attributes-reader/reading-attributes/class-attributes.md) , [Method Attributes](/php-attributes-reader/reading-attributes/method-attributes.md) and [Property Attributes](/php-attributes-reader/reading-attributes/property-attributes.md) guides to see how to get attributes from the `AttributesReader` and then you can get arguments from those attributes using the same functions.<br>

### Available functions in Argument class

```php
public function getType(): int
```

Returns type of the Argument(type of the value as an integer) using one of the below constants which are defined on `Argument` class.

```php
    public const ARGUMENT_VALUE_TYPE_EMPTY = 0;
    public const ARGUMENT_VALUE_TYPE_BOOLEAN = 1;
    public const ARGUMENT_VALUE_TYPE_STRING = 2;
    public const ARGUMENT_VALUE_TYPE_INT = 3;
    public const ARGUMENT_VALUE_TYPE_FLOAT = 4;
    public const ARGUMENT_VALUE_TYPE_SEQUENTIAL_ARRAY = 5;
    public const ARGUMENT_VALUE_TYPE_ASSOCIATIVE_ARRAY = 6;
    public const ARGUMENT_VALUE_TYPE_OBJECT = 7;

    public const ARGUMENT_VALUE_TYPE_OTHER = 50;
```

<br>

```php
public function getValue(): mixed
```

Returns the value of the Argument.\ <br>

Support for different types of Arguments(Attribute values) is currently very limited and will be improved in future releases. \
\
\
Refer [Limitations](/php-attributes-reader/limitations.md) documentation to get an idea about the current capabilities and to evaluate this library for your needs.
