Annotation::getArguments()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Leaditin\Annotations;
6
7
use Leaditin\Annotations\Exception\AnnotationException;
8
9
/**
10
 * Class Annotation
11
 *
12
 * @package Leaditin\Annotations
13
 * @author Igor Vuckovic <[email protected]>
14
 */
15
class Annotation
16
{
17
    /** @var string */
18
    protected $name;
19
20
    /** @var array */
21
    protected $arguments;
22
23
    /**
24
     * @param string $name
25
     * @param array $arguments
26
     */
27 29
    public function __construct(string $name, array $arguments)
28
    {
29 29
        $this->name = $name;
30 29
        $this->arguments = $arguments;
31 29
    }
32
33
    /**
34
     * @return string
35
     */
36 14
    public function getName() : string
37
    {
38 14
        return $this->name;
39
    }
40
41
    /**
42
     * @return array
43
     */
44 2
    public function getArguments() : array
45
    {
46 2
        return $this->arguments;
47
    }
48
49
    /**
50
     * @param int|string $name
51
     * @return bool
52
     */
53 7
    public function hasArgument($name) : bool
54
    {
55 7
        return array_key_exists($name, $this->arguments);
56
    }
57
58
    /**
59
     * @param int|string $name
60
     * @return null|int|bool|string|float|array
61
     * @throws AnnotationException
62
     */
63 6
    public function getArgument($name)
64
    {
65 6
        if (!$this->hasArgument($name)) {
66 1
            throw AnnotationException::undefinedArgument($this, $name);
67
        }
68
69 5
        return $this->arguments[$name];
70
    }
71
}
72