@@ 95-113 (lines=19) @@ | ||
92 | return; |
|
93 | } |
|
94 | // check if an object is passed |
|
95 | if (is_object($key)) { |
|
96 | if ($key instanceof Strng) { |
|
97 | $newKey = $key->stringValue(); |
|
98 | } elseif ($key instanceof Flt) { |
|
99 | $newKey = $key->floatValue(); |
|
100 | } elseif ($key instanceof Integer) { |
|
101 | $newKey = $key->intValue(); |
|
102 | } elseif ($key instanceof Boolean) { |
|
103 | $newKey = $key->booleanValue(); |
|
104 | } elseif (method_exists($key, '__toString')) { |
|
105 | $newKey = $key->__toString(); |
|
106 | } else { |
|
107 | throw new InvalidKeyException('Passed key has to be a primitive datatype or has to implement the __toString() method'); |
|
108 | } |
|
109 | // add the item to the array |
|
110 | $this->items[$newKey] = $object; |
|
111 | // and return |
|
112 | return; |
|
113 | } |
|
114 | throw new InvalidKeyException('Passed key has to be a primitive datatype or has to implement the __toString() method'); |
|
115 | } |
|
116 |
@@ 110-130 (lines=21) @@ | ||
107 | return $this; |
|
108 | } |
|
109 | // check if an object is passed |
|
110 | if (is_object($key)) { |
|
111 | if ($key instanceof Strng) { |
|
112 | $newKey = $key->stringValue(); |
|
113 | } elseif ($key instanceof Flt) { |
|
114 | $newKey = $key->floatValue(); |
|
115 | } elseif ($key instanceof Integer) { |
|
116 | $newKey = $key->intValue(); |
|
117 | } elseif ($key instanceof Boolean) { |
|
118 | $newKey = $key->booleanValue(); |
|
119 | } elseif (method_exists($key, '__toString')) { |
|
120 | $newKey = $key->__toString(); |
|
121 | } else { |
|
122 | throw new InvalidKeyException('Passed key has to be a primitive datatype or has to implement the __toString() method'); |
|
123 | } |
|
124 | // add the passed object to the internal array |
|
125 | $this->items[$newKey] = $object; |
|
126 | // sort the instance |
|
127 | $this->sort(); |
|
128 | // return the instance |
|
129 | return $this; |
|
130 | } |
|
131 | throw new InvalidKeyException('Passed key has to be a primitive datatype or has to implement the __toString() method'); |
|
132 | } |
|
133 |