| 1 |
<?php |
| 2 |
|
| 3 |
namespace Boxzilla\DI; |
| 4 |
|
| 5 |
/** |
| 6 |
* Class ContainerWithPropertyAccess |
| 7 |
* |
| 8 |
* This modifies Pimple so it is PSR-11 compatible and can be accessed using property accessors. |
| 9 |
* |
| 10 |
* @package Boxzilla\DI |
| 11 |
*/ |
| 12 |
class ContainerWithPropertyAccess extends Container { |
| 13 |
|
| 14 |
/** |
| 15 |
* @param string $name |
| 16 |
* @return mixed |
| 17 |
*/ |
| 18 |
public function __get( $name ) { |
| 19 |
return $this->offsetGet( $name ); |
| 20 |
} |
| 21 |
|
| 22 |
/** |
| 23 |
* @param string $name |
| 24 |
* @param mixed $value |
| 25 |
*/ |
| 26 |
public function __set( $name, $value ) { |
| 27 |
$this[ $name ] = $value; |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* @param string $name |
| 32 |
* @return bool |
| 33 |
*/ |
| 34 |
public function __isset( $name ) { |
| 35 |
return $this->offsetExists( $name ); |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* @param string $name |
| 40 |
* @return bool |
| 41 |
*/ |
| 42 |
public function has( $name ) { |
| 43 |
return $this->offsetExists( $name ); |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* @param string $name |
| 48 |
* @return mixed |
| 49 |
*/ |
| 50 |
public function get( $name ) { |
| 51 |
return $this->offsetGet( $name ); |
| 52 |
} |
| 53 |
|
| 54 |
} |