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

TransferMetadata   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
wmc 5
dl 0
loc 36
ccs 8
cts 10
cp 0.8
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addPropertyMetadata() 0 15 4
A getAssociation() 0 3 1
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