| Total Complexity | 11 |
| Total Lines | 97 |
| Duplicated Lines | 0 % |
| Coverage | 85.71% |
| Changes | 0 | ||
| 1 | <?php |
||
| 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 | 47 | public function __construct(Group $group) |
|
| 25 | { |
||
| 26 | 47 | parent::__construct($group->getSchema(), ''); |
|
| 27 | 47 | $this->wrapped = $group; |
|
| 28 | 47 | } |
|
| 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 | 47 | public function setMin($min) |
|
| 44 | { |
||
| 45 | 47 | $this->min = $min; |
|
| 46 | |||
| 47 | 47 | return $this; |
|
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @return int |
||
| 52 | */ |
||
| 53 | 1 | public function getMax() |
|
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @param int $max |
||
| 60 | * |
||
| 61 | * @return $this |
||
| 62 | */ |
||
| 63 | 47 | public function setMax($max) |
|
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * @return string |
||
| 72 | */ |
||
| 73 | 1 | public function 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 | /** |
||
| 86 | * @var string $k |
||
| 87 | */ |
||
| 88 | 1 | foreach ($elements as $k => $element) { |
|
| 89 | /** |
||
| 90 | * @var Element|ElementRef|ElementSingle|GroupRef $e |
||
| 91 | */ |
||
| 92 | 1 | $e = clone $element; |
|
| 93 | 1 | $e->setMax($this->getMax()); |
|
| 94 | 1 | $elements[$k] = $e; |
|
| 95 | 1 | } |
|
| 96 | 1 | } |
|
| 97 | |||
| 98 | 1 | return $elements; |
|
| 99 | } |
||
| 100 | |||
| 101 | public function addElement(ElementItem $element) |
||
| 104 | } |
||
| 105 | } |
||
| 106 |