| Total Complexity | 12 |
| Total Lines | 105 |
| Duplicated Lines | 0 % |
| Coverage | 88.24% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class GroupRef extends Group implements InterfaceSetMinMax |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var Group |
||
| 12 | */ |
||
| 13 | protected $wrapped; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var int |
||
| 17 | */ |
||
| 18 | protected $min = 1; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var int |
||
| 22 | */ |
||
| 23 | protected $max = 1; |
||
| 24 | |||
| 25 | 135 | public function __construct(Group $group) |
|
| 26 | { |
||
| 27 | 135 | parent::__construct($group->getSchema(), ''); |
|
| 28 | 135 | $this->wrapped = $group; |
|
| 29 | 135 | } |
|
| 30 | |||
| 31 | /** |
||
| 32 | * @return int |
||
| 33 | */ |
||
| 34 | public function getMin() |
||
| 35 | { |
||
| 36 | return $this->min; |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @param int $min |
||
| 41 | * |
||
| 42 | * @return $this |
||
| 43 | */ |
||
| 44 | 135 | public function setMin($min) |
|
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @return int |
||
| 52 | */ |
||
| 53 | 3 | public function getMax() |
|
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @param int $max |
||
| 60 | * |
||
| 61 | * @return $this |
||
| 62 | */ |
||
| 63 | 135 | public function setMax($max) |
|
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * @return string |
||
| 71 | */ |
||
| 72 | 3 | public function getName() |
|
| 75 | } |
||
| 76 | |||
| 77 | /** |
||
| 78 | * @return ElementItem[] |
||
| 79 | */ |
||
| 80 | 3 | public function getElements() |
|
| 81 | { |
||
| 82 | 3 | $elements = $this->wrapped->getElements(); |
|
| 83 | 3 | if($this->getMax()>0 || $this->getMax()===-1){ |
|
| 84 | 3 | foreach ($elements as $k => $element) { |
|
| 85 | /** |
||
| 86 | * @var Element|ElementRef|ElementSingle|GroupRef $e |
||
| 87 | */ |
||
| 88 | 3 | $e = clone $element; |
|
| 89 | 3 | $e->setMax($this->getMax()); |
|
| 90 | 3 | $elements[$k] = $e; |
|
| 91 | 1 | } |
|
| 92 | 1 | } |
|
| 93 | 3 | return $elements; |
|
| 94 | } |
||
| 95 | |||
| 96 | public function addElement(ElementItem $element) |
||
| 97 | { |
||
| 98 | throw new BadMethodCallException("Can't add an element for a ref group"); |
||
| 99 | } |
||
| 100 | |||
| 101 | /** |
||
| 102 | * @return GroupRef |
||
| 103 | */ |
||
| 104 | 135 | public static function loadGroupRef(Group $referenced, DOMElement $node) |
|
| 113 | } |
||
| 114 | } |
||
| 115 |