Completed
Push — master ( d4f643...31fba3 )
by JHONATAN
02:46
created

AnnotationsTrait::hasAnnotation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Vox\Metadata;
4
5
trait AnnotationsTrait
6
{
7
    private $annotations;
8
    
9
    public function getAnnotations(): array
10
    {
11
        return $this->annotations;
12
    }
13
14 16
    public function setAnnotations(array $annotations)
15
    {
16 16
        $this->annotations = $annotations;
17
        
18 16
        return $this;
19
    }
20
    
21 14
    public function getAnnotation(string $annotationName, $throwException = false)
22
    {
23 14
        if (!isset($this->annotations[$annotationName]) && $throwException) {
24
            throw new \InvalidArgumentException("no annotation with name $annotationName");
25
        }
26
        
27 14
        return $this->annotations[$annotationName] ?? null;
28
    }
29
    
30 11
    public function hasAnnotation(string $annotationName)
31
    {
32 11
        return isset($this->annotations[$annotationName]);
33
    }
34
}
35