1: <?php
2:
3: namespace Deimos\Controller;
4:
5: use Deimos\Builder\Builder;
6: use Deimos\Controller\Exceptions\ControllerNotFound;
7: use Deimos\Controller\Traits\Request;
8:
9: abstract class Runner extends Builder
10: {
11:
12: use Request;
13:
14: 15: 16: 17: 18: 19: 20:
21: public function __construct(Builder $builder)
22: {
23: if ($builder instanceof self)
24: {
25: throw new \InvalidArgumentException('Instanceof SELF');
26: }
27:
28: $this->builder = $builder;
29: }
30:
31: 32: 33: 34: 35: 36: 37: 38:
39: public function execute()
40: {
41: $name = $this->request()->attribute('controller');
42:
43: if ($this->methodExists($name))
44: {
45: 46: 47:
48: $instance = $this->instance($name);
49:
50: return $instance->execute();
51: }
52:
53: throw new ControllerNotFound($name);
54: }
55:
56: }