@@ 36-49 (lines=14) @@ | ||
33 | * @param bool $memoize |
|
34 | * Memoize parameter. |
|
35 | */ |
|
36 | public static function addDynamicProperty($names, $value, $memoize = false) |
|
37 | { |
|
38 | if (!is_array($names)) { |
|
39 | $names = array($names); |
|
40 | } |
|
41 | ||
42 | foreach ($names as $property) { |
|
43 | static::$dynamicProperties[get_called_class()][$property] = [ |
|
44 | 'name' => $property, |
|
45 | 'factory' => $value, |
|
46 | 'memoize' => $memoize, |
|
47 | ]; |
|
48 | } |
|
49 | } |
|
50 | ||
51 | /** |
|
52 | * Add a dynamic method. |
|
@@ 63-77 (lines=15) @@ | ||
60 | * @param bool $static |
|
61 | * Static flag parameter. |
|
62 | */ |
|
63 | public static function addDynamicMethod($names, \Closure $func, $memoize = false, $static = false) |
|
64 | { |
|
65 | if (!is_array($names)) { |
|
66 | $names = array($names); |
|
67 | } |
|
68 | ||
69 | foreach ($names as $method) { |
|
70 | static::$dynamicMethods[get_called_class()][$method] = [ |
|
71 | 'name' => $method, |
|
72 | 'factory' => $func, |
|
73 | 'memoize' => $memoize, |
|
74 | 'static' => $static, |
|
75 | ]; |
|
76 | } |
|
77 | } |
|
78 | ||
79 | /** |
|
80 | * Check if a dynamic property exists. |