1: <?php
2: namespace Datadepo\Api\Structures;
3:
4: /**
5: * @property-read string $code
6: * @property-read array $options
7: * @property-read StoreLine $store
8: * @property-read PriceLine[] $prices
9: */
10: class VariantLine extends AbstractStructure
11: {
12:
13: /** @var StoreLine */
14: private $_store;
15:
16: /** @var PriceLine[] */
17: private $_prices;
18:
19: /**
20: * @param array $data
21: */
22: public function __construct($data)
23: {
24: $this->data = $data;
25: }
26:
27: /**
28: * @return string
29: */
30: public function getJson()
31: {
32: return json_encode($this->data);
33: }
34:
35: /**
36: * @return string
37: */
38: public function getCode()
39: {
40: return $this->data->code;
41: }
42:
43: /**
44: * @return string
45: */
46: public function getOptions()
47: {
48: return $this->data->options;
49: }
50:
51: /**
52: * @return StoreLine
53: */
54: public function getStore()
55: {
56: if ($this->_store === NULL) {
57: $this->_store = new StoreLine($this->data->store);
58: }
59: return $this->_store;
60: }
61:
62: /**
63: * @return PriceLine[]
64: */
65: public function getPrices()
66: {
67: if ($this->_prices === NULL) {
68: $this->_prices = array();
69: foreach ($this->data->prices as $currency => $data) {
70: $this->_prices[$currency] = new PriceLine($data, $currency);
71: }
72: }
73: return $this->_prices;
74: }
75:
76:
77: }