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

TransferMetadata::addPropertyMetadata()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 8
cts 8
cp 1
rs 9.2
c 0
b 0
f 0
cc 4
eloc 7
nc 6
nop 1
crap 4
1
<?php
2
3
namespace Vox\Webservice\Metadata;
4
5
use Metadata\PropertyMetadata as BasePropertyMetadata;
6
use Vox\Metadata\ClassMetadata;
7
use Vox\Metadata\PropertyMetadata;
8
use Vox\Webservice\Mapping\Id;
9
10
class TransferMetadata extends ClassMetadata
11
{
12
    /**
13
     * @var PropertyMetadata
14
     */
15
    public $id;
16
    
17
    /**
18
     * @var PropertyMetadata
19
     */
20
    public $associations;
21
    
22 11
    public function addPropertyMetadata(BasePropertyMetadata $metadata)
23
    {
24 11
        if ($metadata instanceof PropertyMetadata) {
25 11
            if ($id = $metadata->getAnnotation(Id::class)) {
0 ignored issues
show
Unused Code introduced by
The assignment to $id is dead and can be removed.
Loading history...
26 7
                $this->id = $metadata;
27
            }
28
        }
29
        
30 11
        parent::addPropertyMetadata($metadata);
31
        
32 11
        if ($metadata->hasAnnotation(\Vox\Webservice\Mapping\BelongsTo::class)) {
0 ignored issues
show
introduced by
The method hasAnnotation() does not exist on Metadata\PropertyMetadata. Are you sure you never get this type here, but always one of the subclasses? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

32
        if ($metadata->/** @scrutinizer ignore-call */ hasAnnotation(\Vox\Webservice\Mapping\BelongsTo::class)) {
Loading history...
33 1
            $this->associations[$metadata->name] = $metadata;
34
        }
35
        
36 11
        return $this;
37
    }
38
    
39
    /**
40
     * @param string $name
41
     * @return PropertyMetadata
42
     */
43
    public function getAssociation(string $name)
44
    {
45
        return $this->associations[$name] ?? null;
46
    }
47
}
48