Completed
Push — master ( b3ea0d...a472ab )
by Asmir
03:28
created

GroupRef::setMax()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
c 0
b 0
f 0
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
namespace GoetasWebservices\XML\XSDReader\Schema\Element;
3
4
class GroupRef extends Group
5
{
6
7
    protected $wrapped;
8
9
    protected $min = 1;
10
11
    protected $max = 1;
12
13 45
    public function __construct(Group $group)
14
    {
15 45
        parent::__construct($group->getSchema(), '');
16 45
        $this->wrapped = $group;
17 45
    }
18
19
    public function getMin()
20
    {
21
        return $this->min;
22
    }
23
24 45
    public function setMin($min)
25
    {
26 45
        $this->min = $min;
27 45
        return $this;
28
    }
29
30 1
    public function getMax()
31
    {
32 1
        return $this->max;
33
    }
34
35 45
    public function setMax($max)
36
    {
37 45
        $this->max = $max;
38 45
        return $this;
39
    }
40
41 1
    public function getName()
42
    {
43 1
        return $this->wrapped->getName();
44
    }
45
46
    public function setName($name)
47
    {
48
        throw new \Exception("Can't set the name for a ref group");
49
    }
50
51 1
    public function getElements()
52
    {
53 1
        $elements = $this->wrapped->getElements();
54 1
        if($this->getMax()>0 || $this->getMax()===-1){
55 1
            foreach ($elements as $k => $element) {
56 1
                $e = clone $element;
57 1
                $e->setMax($this->getMax());
58 1
                $elements[$k] = $e;
59 1
            }
60 1
        }
61 1
        return $elements;
62
    }
63
64
    public function addElement(ElementItem $element)
65
    {
66
        throw new \Exception("Can't set the name for a ref group");
67
    }
68
}
69