ProductConfiguration   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 41
ccs 0
cts 19
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDeliveryMethods() 0 4 1
A addDeliveryMethod() 0 4 1
A createFromXML() 0 13 3
1
<?php
2
3
namespace Bpost\BpostApiClient\Bpost;
4
5
use SimpleXMLElement;
6
use Bpost\BpostApiClient\Bpost\ProductConfiguration\DeliveryMethod;
7
8
/**
9
 * Class ProductConfiguration
10
 * @package Bpost\BpostApiClient\Bpost
11
 */
12
class ProductConfiguration
13
{
14
15
    /** @var array DeliveryMethod[] */
16
    private $deliveryMethods = array();
17
18
    /**
19
     * @return DeliveryMethod[]
20
     */
21
    public function getDeliveryMethods()
22
    {
23
        return $this->deliveryMethods;
24
    }
25
26
    /**
27
     * @param DeliveryMethod $deliveryMethod
28
     */
29
    public function addDeliveryMethod(DeliveryMethod $deliveryMethod)
30
    {
31
        $this->deliveryMethods[] = $deliveryMethod;
32
    }
33
34
    /**
35
     * @param SimpleXMLElement $xml
36
     *
37
     * @return ProductConfiguration
38
     */
39
    public static function createFromXML(SimpleXMLElement $xml)
40
    {
41
        $productConfiguration = new self();
42
        $children = $xml->children();
43
44
        if (isset($children->deliveryMethod)) {
45
            foreach ($children->deliveryMethod as $deliveryMethodXml) {
46
                $productConfiguration->addDeliveryMethod(DeliveryMethod::createFromXML($deliveryMethodXml));
47
            }
48
        }
49
50
        return $productConfiguration;
51
    }
52
}
53