Issues (19)

src/Model/Property.php (1 issue)

Labels
Severity
1
<?php namespace Zenwalker\CommerceML\Model;
2
3
/**
4
 * Class Property
5
 *
6
 * @package Zenwalker\CommerceML\Model
7
 * @property \SimpleXMLElement[] availableValues
8
 * @property Simple valueModel
9
 * @property mixed value
10
 */
11
class Property extends Simple
12
{
13
    public $productId;
14
    protected $_value;
15
16
    /**
17
     * @return \SimpleXMLElement[]
18
     */
19 1
    public function getAvailableValues()
20
    {
21 1
        return $this->owner->classifier->getReferenceBookById($this->id);
22
    }
23
24
    /**
25
     * @return Simple|null
26
     */
27 2
    public function getValueModel()
28
    {
29 2
        if ($this->productId && !$this->_value && ($product = $this->owner->catalog->getById($this->productId))) {
30 2
            $xpath = "c:ЗначенияСвойств/c:ЗначенияСвойства[c:Ид = '{$this->id}']";
31 2
            $valueXml = $product->xpath($xpath)[0];
32 2
            $value = $this->_value = (string)$valueXml->Значение;
0 ignored issues
show
A parse error occurred: Syntax error, unexpected T_LNUMBER, expecting T_STRING or T_VARIABLE or '{' or '$' on line 32 at column 56
Loading history...
33 2
            if ($property = $this->owner->classifier->getReferenceBookValueById($value)) {
34 1
                $this->_value = new Simple($this->owner, $property);
35
            } else {
36 1
                $this->_value = new Simple($this->owner, $valueXml);
37
            }
38
        }
39 2
        return $this->_value;
40
    }
41
42 2
    public function getValue()
43
    {
44 2
        return $this->getValueModel() ? (string)$this->getValueModel()->value : null;
45
    }
46
}