Passed
Push — master ( e89c90...b07112 )
by Bas
03:34
created

ClientModelInstantiator::construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 4
c 1
b 0
f 1
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 10
cc 2
nc 2
nop 5
crap 2
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace DMT\Insolvency\Soap\Serializer;
4
5
use DMT\Insolvency\Client;
6
use DMT\Insolvency\Model\ConstructWithClientInterface;
7
use JMS\Serializer\Construction\ObjectConstructorInterface;
8
use JMS\Serializer\DeserializationContext;
9
use JMS\Serializer\Metadata\ClassMetadata;
10
use JMS\Serializer\Visitor\DeserializationVisitorInterface;
11
12
class ClientModelInstantiator implements ObjectConstructorInterface
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class ClientModelInstantiator
Loading history...
13
{
14
    private Client $client;
0 ignored issues
show
Coding Style introduced by
Private member variable "client" must be prefixed with an underscore
Loading history...
15
16
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
17
     * @param Client $client
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
18
     */
19 13
    public function __construct(Client $client)
20
    {
21 13
        $this->client = $client;
22 13
    }
23
24
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
Parameter $visitor should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $metadata should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $data should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $type should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $context should have a doc-comment as per coding-style.
Loading history...
25
     * @inheritDoc
26
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
27 11
    public function construct(DeserializationVisitorInterface $visitor, ClassMetadata $metadata, $data, array $type, DeserializationContext $context): ?object
28
    {
29 11
        $params = [];
30 11
        if (is_a($metadata->name, ConstructWithClientInterface::class, true)) {
31 7
            $params = [$this->client];
32
        }
33
34 11
        return new $metadata->name(...$params);
35
    }
36
}
37