Passed
Push — static-analysis ( 1958c5...5a8282 )
by SignpostMarv
10:41 queued 08:16
created

GroupRef::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace GoetasWebservices\XML\XSDReader\Schema\Element;
4
5
use BadMethodCallException;
6
7
class GroupRef extends Group implements InterfaceSetMinMax
8
{
9
    /**
10
     * @var Group
11
     */
12
    protected $wrapped;
13
14
    /**
15
     * @var int
16
     */
17
    protected $min = 1;
18
19
    /**
20
     * @var int
21
     */
22
    protected $max = 1;
23
24 45
    public function __construct(Group $group)
25
    {
26 45
        parent::__construct($group->getSchema(), '');
27 45
        $this->wrapped = $group;
28 45
    }
29
30
    /**
31
     * @return int
32
     */
33
    public function getMin()
34
    {
35
        return $this->min;
36
    }
37
38
    /**
39
     * @param int $min
40
     *
41
     * @return $this
42
     */
43 45
    public function setMin($min)
44
    {
45 45
        $this->min = $min;
46
47 45
        return $this;
48
    }
49
50
    /**
51
     * @return int
52
     */
53 1
    public function getMax()
54
    {
55 1
        return $this->max;
56
    }
57
58
    /**
59
     * @param int $max
60
     *
61
     * @return $this
62
     */
63 45
    public function setMax($max)
64
    {
65 45
        $this->max = $max;
66
67 45
        return $this;
68
    }
69
70
    /**
71
     * @return string
72
     */
73 1
    public function getName()
74
    {
75 1
        return $this->wrapped->getName();
76
    }
77
78
    /**
79
     * @return ElementItem[]
80
     */
81 1
    public function getElements()
82
    {
83 1
        $elements = $this->wrapped->getElements();
84 1
        if ($this->getMax() > 0 || $this->getMax() === -1) {
85 1
            foreach ($elements as $k => $element) {
86
                /**
87
                 * @var Element|ElementRef|ElementSingle|GroupRef $e
88
                 */
89 1
                $e = clone $element;
90 1
                $e->setMax($this->getMax());
91 1
                $elements[$k] = $e;
92 1
            }
93 1
        }
94
95 1
        return $elements;
96
    }
97
98
    public function addElement(ElementItem $element)
99
    {
100
        throw new BadMethodCallException("Can't add an element for a ref group");
101
    }
102
}
103