| 1 |
<?php |
| 2 |
|
| 3 |
namespace Props; |
| 4 |
|
| 5 |
/** |
| 6 |
* A version of Pimple that uses property access instead of array access |
| 7 |
* |
| 8 |
* @author Steve Clay <[email protected]> |
| 9 |
*/ |
| 10 |
class Pimple extends \Pimple\Container |
| 11 |
{ |
| 12 |
/** |
| 13 |
* Sets a parameter or an object. |
| 14 |
* |
| 15 |
* @param string $id The unique identifier for the parameter or object |
| 16 |
* @param mixed $value The value of the parameter or a closure to define an object |
| 17 |
* @throws \RuntimeException Prevent override of a frozen service |
| 18 |
*/ |
| 19 |
public function __set($id, $value) |
| 20 |
{ |
| 21 |
$this->offsetSet($id, $value); |
| 22 |
} |
| 23 |
|
| 24 |
/** |
| 25 |
* Gets a parameter or an object. |
| 26 |
* |
| 27 |
* @param string $id The unique identifier for the parameter or object |
| 28 |
* @return mixed The value of the parameter or an object |
| 29 |
* @throws \InvalidArgumentException if the identifier is not defined |
| 30 |
*/ |
| 31 |
public function __get($id) |
| 32 |
{ |
| 33 |
return $this->offsetGet($id); |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* Checks if a parameter or an object is set. |
| 38 |
* |
| 39 |
* @param string $id The unique identifier for the parameter or object |
| 40 |
* @return Boolean |
| 41 |
*/ |
| 42 |
public function __isset($id) |
| 43 |
{ |
| 44 |
return $this->offsetExists($id); |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* Unsets a parameter or an object. |
| 49 |
* |
| 50 |
* @param string $id The unique identifier for the parameter or object |
| 51 |
*/ |
| 52 |
public function __unset($id) |
| 53 |
{ |
| 54 |
$this->offsetUnset($id); |
| 55 |
} |
| 56 |
} |
| 57 |
|