| 1 | <?php |
||
| 8 | trait DynamicObjectTrait |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var array |
||
| 12 | */ |
||
| 13 | protected $methods = []; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var array |
||
| 17 | */ |
||
| 18 | protected $properties = []; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var array |
||
| 22 | */ |
||
| 23 | protected $flags = []; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Add a method identified by the given name. |
||
| 27 | * |
||
| 28 | * @param string $name |
||
| 29 | * @param callable $method the body of the method |
||
| 30 | * @return $this |
||
| 31 | */ |
||
| 32 | public function addMethod($name, callable $method) |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Adds a lazy property identified by the given name. The property |
||
| 40 | * is lazy because it is not evaluated until asked for via __get(). |
||
| 41 | * |
||
| 42 | * @param string $name |
||
| 43 | * @param callable $factory |
||
| 44 | * @param bool $memoize |
||
| 45 | * @return $this |
||
| 46 | */ |
||
| 47 | public function addProperty($name, callable $factory, $memoize = false) |
||
| 52 | |||
| 53 | /** |
||
| 54 | * A simple mechanism for storing arbitrary flags. Flags are useful |
||
| 55 | * for tweaking behavior based on their presence. |
||
| 56 | * |
||
| 57 | * @return $this|mixed |
||
| 58 | */ |
||
| 59 | public function flag() |
||
| 73 | |||
| 74 | /** |
||
| 75 | * Reset flags. Flags are generally cleared after an Assertion is made. |
||
| 76 | * |
||
| 77 | * @return $this |
||
| 78 | */ |
||
| 79 | public function clearFlags() |
||
| 84 | } |
||
| 85 |