1 | <?php |
||
2 | |||
3 | namespace App\Document; |
||
4 | |||
5 | use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB; |
||
6 | use Symfony\Component\Serializer\Annotation\Groups; |
||
7 | |||
8 | /** |
||
9 | * @MongoDB\EmbeddedDocument |
||
10 | */ |
||
11 | class Package |
||
12 | { |
||
13 | /** |
||
14 | * @MongoDB\Field(type="string") |
||
15 | * @Groups({"package_default"}) |
||
16 | */ |
||
17 | protected $version; |
||
18 | |||
19 | /** |
||
20 | * @MongoDB\Field(type="raw") |
||
21 | * @Groups({"package_default"}) |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $data; |
||
26 | |||
27 | public function getVersion(): string |
||
28 | { |
||
29 | return $this->version; |
||
30 | } |
||
31 | |||
32 | public function setVersion(string $version): self |
||
33 | { |
||
34 | $this->version = $version; |
||
35 | |||
36 | return $this; |
||
37 | } |
||
38 | |||
39 | public function getData(): array |
||
40 | { |
||
41 | if(is_string($this->data)) { |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
42 | return json_decode($this->data, true); |
||
43 | } |
||
44 | |||
45 | return $this->data; |
||
46 | } |
||
47 | |||
48 | public function setData(array $data): self |
||
49 | { |
||
50 | $this->data = json_encode($data); |
||
51 | |||
52 | return $this; |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * @return array |
||
57 | */ |
||
58 | public function getReplace() |
||
59 | { |
||
60 | if(isset($this->getData()['replace'])) { |
||
61 | return array_keys($this->getData()['replace']); |
||
62 | } |
||
63 | return []; |
||
64 | } |
||
65 | } |
||
66 |