Passed
Pull Request — master (#1366)
by Asmir
09:41
created

StaticPropertyMetadata::unserializeProperties()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 8
ccs 0
cts 8
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace JMS\Serializer\Metadata;
6
7
class StaticPropertyMetadata extends PropertyMetadata
8
{
9
    /**
10
     * @var mixed
11 43
     */
12
    private $value;
13 43
14 43
    /**
15 43
     * StaticPropertyMetadata constructor.
16 43
     *
17 43
     * @param mixed $fieldValue
18 43
     * @param array $groups
19 43
     */
20
    public function __construct(string $className, string $fieldName, $fieldValue, array $groups = [])
21 15
    {
22
        $this->class = $className;
23 15
        $this->name = $fieldName;
24
        $this->serializedName = $fieldName;
25
        $this->value = $fieldValue;
26
        $this->readOnly = true;
27
        $this->groups = $groups;
28
    }
29
30
    /**
31
     * @return mixed
32
     */
33
    public function getValue()
34
    {
35
        return $this->value;
36
    }
37
38
    public function setAccessor(string $type, ?string $getter = null, ?string $setter = null): void
39
    {
40
    }
41
42
    protected function serializeToArray(): array
43
    {
44
        return [
45
            $this->value,
46
            parent::serializeToArray(),
47
        ];
48
    }
49
50
    protected function unserializeFromArray(array $data): void
51
    {
52
        [
53
            $this->value,
54
            $parentData,
55
        ] = $data;
56
57
        parent::unserializeFromArray($parentData);
58
    }
59
}
60