1 | <?php |
||
11 | class Controller |
||
12 | { |
||
13 | /** |
||
14 | * @var array |
||
15 | */ |
||
16 | private $container; |
||
17 | |||
18 | /** |
||
19 | * @var array |
||
20 | */ |
||
21 | protected $data; |
||
22 | |||
23 | /** |
||
24 | * Constructor. |
||
25 | * |
||
26 | * @param array $container |
||
27 | */ |
||
28 | public function __construct(array $container) |
||
32 | |||
33 | /** |
||
34 | * @param string $name Item name |
||
35 | * |
||
36 | * @return mixed Item from container |
||
37 | */ |
||
38 | public function get($name) |
||
42 | |||
43 | /** |
||
44 | * @param string $name Config name |
||
45 | * |
||
46 | * @return mixed Config value |
||
47 | */ |
||
48 | public function config($name) |
||
52 | |||
53 | /** |
||
54 | * @return string |
||
55 | */ |
||
56 | public function dir() |
||
60 | |||
61 | /** |
||
62 | * Check is user logged. |
||
63 | * |
||
64 | * @return bool Return true, if logged |
||
65 | */ |
||
66 | public function isLogged() |
||
70 | |||
71 | public function terminate($code = 1) |
||
75 | |||
76 | /** |
||
77 | * @param string $path Path to redirect |
||
78 | * @param string $type Message type |
||
79 | * @param mixed $message Message content |
||
80 | * |
||
81 | * @return void |
||
82 | */ |
||
83 | public function redirectWithMessage($path, $type = 'success', $message = 'Success') |
||
108 | |||
109 | private function selectMessagesTemplate() |
||
117 | |||
118 | /** |
||
119 | * @param string $template Template name |
||
120 | * @param array $data Data to use in template |
||
121 | */ |
||
122 | public function render($template, $data = []) |
||
155 | } |
||
156 |
An exit expression should only be used in rare cases. For example, if you write a short command line script.
In most cases however, using an
exit
expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.