Total Complexity | 13 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Coverage | 94.44% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
18 | class Price extends Simple |
||
19 | { |
||
20 | protected $type; |
||
21 | |||
22 | 1 | public function __get($name) |
|
23 | { |
||
24 | 1 | if ($result = parent::__get($name)) { |
|
25 | 1 | if ($this->type && ($value = $this->type->{$name})) { |
|
26 | return $value; |
||
27 | } |
||
28 | } |
||
29 | 1 | return $result; |
|
30 | } |
||
31 | |||
32 | 1 | public function propertyAliases() |
|
33 | { |
||
34 | return [ |
||
35 | 1 | 'Представление' => 'performance', |
|
36 | 'ИдТипаЦены' => 'id', |
||
37 | 'ЦенаЗаЕдиницу' => 'cost', |
||
38 | 'Валюта' => 'currency', |
||
39 | 'Единица' => 'unit', |
||
40 | 'Коэффициент' => 'rate', |
||
41 | ]; |
||
42 | } |
||
43 | |||
44 | 1 | public function getType() |
|
45 | { |
||
46 | 1 | if (!$this->type && ($id = $this->id)) { |
|
47 | 1 | if ($type = $this->owner->offerPackage->xpath('//c:ТипЦены[c:Ид = :id]', ['id' => $id])) { |
|
48 | 1 | $this->type = new Simple($this->owner, $type[0]); |
|
49 | } |
||
50 | } |
||
51 | 1 | return $this->type; |
|
52 | } |
||
53 | |||
54 | 1 | public function init() |
|
55 | { |
||
56 | 1 | if ($this->xml && $this->xml->Цена) { |
|
|
|||
57 | 1 | foreach ($this->xml->Цена as $price) { |
|
58 | 1 | $this->append(new self($this->owner, $price)); |
|
59 | } |
||
60 | 1 | $this->getType(); |
|
61 | } |
||
62 | 1 | parent::init(); |
|
63 | } |
||
64 | } |