| @@ 40-46 (lines=7) @@ | ||
| 37 | if ($this->containsKey($key)) { |
|
| 38 | return $this->data[$key]; |
|
| 39 | } |
|
| 40 | if (null !== $default and ! $this->checkValueType($default)) { |
|
| 41 | throw new \InvalidArgumentException( |
|
| 42 | 'The default value provided for ' |
|
| 43 | . get_class($this) . '::getOrDefault is not a valid type,' |
|
| 44 | . ' expected ' . $this->getKeyType() . '.' |
|
| 45 | ); |
|
| 46 | } |
|
| 47 | return $default; |
|
| 48 | } |
|
| 49 | ||
| @@ 57-63 (lines=7) @@ | ||
| 54 | ||
| 55 | public function put($key, $value) |
|
| 56 | { |
|
| 57 | if (! $this->checkKeyType($key)) { |
|
| 58 | throw new \InvalidArgumentException( |
|
| 59 | 'The key provided for ' . get_class($this) |
|
| 60 | . '::put is not a valid type,' |
|
| 61 | . ' expected ' . $this->getKeyType() . '.' |
|
| 62 | ); |
|
| 63 | } |
|
| 64 | if (! $this->checkValueType($value)) { |
|
| 65 | throw new \InvalidArgumentException( |
|
| 66 | 'The value provided for ' . get_class($this) |
|
| @@ 64-70 (lines=7) @@ | ||
| 61 | . ' expected ' . $this->getKeyType() . '.' |
|
| 62 | ); |
|
| 63 | } |
|
| 64 | if (! $this->checkValueType($value)) { |
|
| 65 | throw new \InvalidArgumentException( |
|
| 66 | 'The value provided for ' . get_class($this) |
|
| 67 | . '::put is not a valid type,' |
|
| 68 | . ' expected ' . $this->getValueType() . '.' |
|
| 69 | ); |
|
| 70 | } |
|
| 71 | $previous = $this->get($key); |
|
| 72 | $this->data[$key] = $value; |
|
| 73 | return $previous; |
|