GroupRef::getElements()   A
last analyzed

Complexity

Conditions 4
Paths 2

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

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