| @@ 25-31 (lines=7) @@ | ||
| 22 | if ($this->optionUniqueValues() && $this->contains($element)) { |
|
| 23 | return false; |
|
| 24 | } |
|
| 25 | if (! $this->checkElementType($element)) { |
|
| 26 | throw new \InvalidArgumentException( |
|
| 27 | 'Invalid element type;' |
|
| 28 | . ' the collection ' . get_class($this) |
|
| 29 | . ' was expecting a ' . $this->getElementType() . ' type' |
|
| 30 | ); |
|
| 31 | } |
|
| 32 | $this->data[] = $element; |
|
| 33 | return true; |
|
| 34 | } |
|
| @@ 29-35 (lines=7) @@ | ||
| 26 | ); |
|
| 27 | } |
|
| 28 | // always throw an exception if element is not the correct type |
|
| 29 | if (! $this->checkElementType($element)) { |
|
| 30 | throw new \InvalidArgumentException( |
|
| 31 | 'Invalid element type;' |
|
| 32 | . ' the ' . $this->containerInternalName() . ' ' . get_class($this) |
|
| 33 | . ' was expecting a ' . $this->getElementType() . ' type' |
|
| 34 | ); |
|
| 35 | } |
|
| 36 | // return the error message, add will throw an exception, offer will return false |
|
| 37 | if ($this->optionUniqueValues() && $this->contains($element)) { |
|
| 38 | return 'The ' . $this->containerInternalName() . ' does not allow duplicated elements'; |
|