Completed
Pull Request — master (#58)
by Ilya
01:50
created

Serialize::context()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Damax\Common\Bridge\Symfony\Bundle\Annotation;
6
7
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationInterface;
8
use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer;
9
10
/**
11
 * @Annotation
12
 */
13
final class Serialize implements ConfigurationInterface
14
{
15
    /**
16
     * @var bool
17
     */
18
    private $deepPopulate;
19
20
    public function __construct(array $data)
21
    {
22
        $this->deepPopulate = (bool) ($data['deepPopulate'] ?? $data['value']);
23
    }
24
25
    public function context(): array
26
    {
27
        return [
28
            AbstractObjectNormalizer::DEEP_OBJECT_TO_POPULATE => $this->deepPopulate,
29
        ];
30
    }
31
32
    public function getAliasName(): string
33
    {
34
        return 'serialize';
35
    }
36
37
    public function allowArray(): bool
38
    {
39
        return false;
40
    }
41
}
42