Passed
Push — master ( 9d357d...1cde7b )
by Aleksandr
08:29
created

Offer::getStockrooms()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 4

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 10
cc 4
nc 2
nop 0
crap 4
1
<?php
2
3
4
namespace Zenwalker\CommerceML\Model;
5
6
7
use Zenwalker\CommerceML\Collections\SpecificationCollection;
8
9
/**
10
 * Class Offer
11
 *
12
 * @package Zenwalker\CommerceML\Model
13
 * @property Price prices
14
 * @property SpecificationCollection specifications
15
 * @property \SimpleXMLElement ХарактеристикиТовара
16
 */
17
class Offer extends Simple
18
{
19
    /**
20
     * @var Price
21
     */
22
    protected $prices = [];
23
    protected $stockrooms = [];
24
    protected $specifications = [];
25
26
    /**
27
     * @return array|SpecificationCollection
28
     */
29 1
    public function getSpecifications()
30
    {
31 1
        if (empty($this->specifications)) {
32 1
            $this->specifications = new SpecificationCollection($this->owner, $this->ХарактеристикиТовара);
33
        }
34 1
        return $this->specifications;
35
    }
36
37
    /**
38
     * @return Price
39
     */
40 1
    public function getPrices()
41
    {
42 1
        if ($this->xml && empty($this->prices)) {
43 1
            $this->prices = new Price($this->owner, $this->xml->Цены);
44
        }
45 1
        return $this->prices;
46
    }
47
48 1
    public function getStockrooms()
49
    {
50 1
        if ($this->xml && empty($this->stockrooms)) {
51 1
            foreach ($this->xml->Склад as $stockroom) {
52 1
                $this->stockrooms[] = new Stockroom($this->owner, $stockroom);
53
            }
54
        }
55 1
        return $this->stockrooms;
56
    }
57
}