1 | <?php |
||
48 | class Item extends \Jkphl\Micrometa\Domain\Item\Item implements ItemInterface |
||
49 | { |
||
50 | /** |
||
51 | * Parser format |
||
52 | * |
||
53 | * @var int |
||
54 | */ |
||
55 | protected $format; |
||
56 | /** |
||
57 | * Item value |
||
58 | * |
||
59 | * @var string |
||
60 | */ |
||
61 | protected $value; |
||
62 | /** |
||
63 | * Nested Items |
||
64 | * |
||
65 | * @var ItemInterface[] |
||
66 | */ |
||
67 | protected $children; |
||
68 | |||
69 | /** |
||
70 | * Item constructor |
||
71 | * |
||
72 | * @param int $format Parser format |
||
73 | * @param PropertyListFactoryInterface $propertyListFactory Property list factory |
||
74 | * @param string|\stdClass|\stdClass[] $type Item type(s) |
||
75 | * @param \stdClass[] $properties Item properties |
||
76 | * @param ItemInterface[] $children Nested items |
||
77 | * @param string|null $itemId Item id |
||
78 | * @param string|null $itemLanguage Item language |
||
79 | * @param string|null $value Item value |
||
80 | */ |
||
81 | 32 | public function __construct( |
|
96 | |||
97 | /** |
||
98 | * Export the object |
||
99 | * |
||
100 | * @return mixed |
||
101 | */ |
||
102 | 3 | public function export() |
|
103 | { |
||
104 | return (object)[ |
||
105 | 3 | 'format' => $this->getFormat(), |
|
106 | 3 | 'id' => $this->getId(), |
|
107 | 3 | 'language' => $this->getLanguage(), |
|
108 | 3 | 'value' => $this->getValue(), |
|
109 | 3 | 'types' => array_map( |
|
110 | function ($type) { |
||
111 | 3 | return $type->profile.$type->name; |
|
112 | 3 | }, |
|
113 | 3 | $this->getType() |
|
114 | ), |
||
115 | 3 | 'properties' => $this->getProperties()->export(), |
|
116 | 3 | 'items' => array_map( |
|
117 | function (ItemInterface $item) { |
||
118 | 3 | return $item->export(); |
|
119 | 3 | }, |
|
120 | 3 | $this->getChildren() |
|
121 | ) |
||
122 | ]; |
||
123 | } |
||
124 | |||
125 | /** |
||
126 | * Return the parser format |
||
127 | * |
||
128 | * @return int Parser format |
||
129 | */ |
||
130 | 15 | public function getFormat() |
|
134 | |||
135 | /** |
||
136 | * Return the item value |
||
137 | * |
||
138 | * @return string Item value |
||
139 | */ |
||
140 | 5 | public function getValue() |
|
144 | |||
145 | /** |
||
146 | * Return the nested children |
||
147 | * |
||
148 | * @return ItemInterface[] Nested children |
||
149 | */ |
||
150 | 19 | public function getChildren() |
|
154 | } |
||
155 |