Issues (19)

src/Collections/PropertyCollection.php (1 issue)

Labels
Severity
1
<?php
2
3
4
namespace Zenwalker\CommerceML\Collections;
5
6
7
use Zenwalker\CommerceML\Model\Property;
8
use Zenwalker\CommerceML\Model\Simple;
9
10
/**
11
 * Class ValueProperties
12
 *
13
 * @package Zenwalker\CommerceML\Model
14
 */
15
class PropertyCollection extends Simple
16
{
17
    /**
18
     * @param $id
19
     * @return Property|null
20
     */
21 2
    public function getById($id)
22
    {
23 2
        foreach ($this as $property) {
24 2
            if ($property->id === (string)$id) {
25 2
                return $property;
26
            }
27
        }
28 1
        return null;
29
    }
30
31 2
    protected function loadPropertiesValue()
32
    {
33 2
        foreach ($this->xml->ЗначенияСвойства as $property) {
0 ignored issues
show
A parse error occurred: Syntax error, unexpected T_LNUMBER, expecting T_STRING or T_VARIABLE or '{' or '$' on line 33 at column 29
Loading history...
34 2
            $properties = $this->owner->classifier->getProperties();
35 2
            $object = clone $properties->getById((string)$property->Ид);
36 2
            $object->productId = (string)$this->xpath('..')[0]->Ид;
37 2
            $object->init();
38 2
            $this->append($object);
39
        }
40 2
    }
41
42 2
    protected function loadProperties()
43
    {
44 2
        foreach ($this->xml->Свойство as $property) {
45 2
            $this->append(new Property($this->owner, $property));
46
        }
47 2
    }
48
49 2
    public function init()
50
    {
51 2
        if (isset($this->xml->ЗначенияСвойства)) {
52 2
            $this->loadPropertiesValue();
53
        }
54 2
        if (isset($this->xml->Свойство)) {
55 2
            $this->loadProperties();
56
        }
57 2
        parent::init();
58
    }
59
}