1 | <?php |
||
6 | final class Engine |
||
7 | { |
||
8 | private $container; |
||
9 | |||
10 | 20 | public function __construct(Util\Container $container = null) { |
|
13 | |||
14 | /** Create a configured engine and set the base dir and extension optionally */ |
||
15 | 8 | public static function create($base_dir, $ext = null) { |
|
21 | |||
22 | /** Create a configured engine and pass in an array to configure after extension registration */ |
||
23 | 20 | public static function createWithConfig(array $config = []) { |
|
37 | |||
38 | /** @return string */ |
||
39 | 16 | public function render($template_name, array $data = [], array $attributes = []) { |
|
46 | |||
47 | 20 | public function addMethods(array $methods) { |
|
50 | 20 | public function __call($method, array $args) { |
|
51 | 20 | $methods = $this->container->get('engine_methods'); |
|
52 | 20 | if (isset($methods[$method])) { |
|
53 | 20 | return $methods[$method]($this, ...$args); |
|
54 | } |
||
55 | |||
56 | 4 | throw new \BadMethodCallException("No method {$method} found for engine."); |
|
57 | } |
||
58 | |||
59 | /** @deprecated kept for bc */ |
||
60 | public function loadExtension(Extension $extension) { |
||
66 | |||
67 | 20 | public function getContainer() { |
|
70 | } |
||
71 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: