Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
7 / 7 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
AbstractController | |
100.00% |
7 / 7 |
|
100.00% |
4 / 4 |
4 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
application | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
console | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
error | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | /** |
3 | * Pop PHP Framework (http://www.popphp.org/) |
4 | * |
5 | * @link https://github.com/popphp/pop-bootstrap |
6 | * @author Nick Sagona, III <nick@nolainteractive.com> |
7 | * @copyright Copyright (c) 2012-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com) |
8 | * @license http://www.popphp.org/license New BSD License |
9 | */ |
10 | |
11 | /** |
12 | * @namespace |
13 | */ |
14 | namespace Pop\Kettle\Controller; |
15 | |
16 | use Pop\Application; |
17 | use Pop\Console\Color; |
18 | use Pop\Console\Console; |
19 | use Pop\Kettle\Exception; |
20 | |
21 | /** |
22 | * Console abstract controller class |
23 | * |
24 | * @category Pop\Kettle |
25 | * @package Pop\Kettle |
26 | * @author Nick Sagona, III <nick@nolainteractive.com> |
27 | * @copyright Copyright (c) 2012-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com) |
28 | * @license http://www.popphp.org/license New BSD License |
29 | * @version 2.3.2 |
30 | */ |
31 | abstract class AbstractController extends \Pop\Controller\AbstractController |
32 | { |
33 | |
34 | /** |
35 | * Application object |
36 | * @var ?Application |
37 | */ |
38 | protected ?Application $application = null; |
39 | |
40 | /** |
41 | * Console object |
42 | * @var ?Console |
43 | */ |
44 | protected ?Console $console = null; |
45 | |
46 | /** |
47 | * Bypass maintenance false |
48 | * @var bool |
49 | */ |
50 | protected bool $bypassMaintenance = true; |
51 | |
52 | /** |
53 | * Constructor for the controller |
54 | * |
55 | * @param Application $application |
56 | * @param Console $console |
57 | */ |
58 | public function __construct(Application $application, Console $console) |
59 | { |
60 | $this->application = $application; |
61 | $this->console = $console; |
62 | |
63 | $this->console->setHelpColors(Color::BOLD_CYAN, Color::BOLD_GREEN, Color::BOLD_MAGENTA); |
64 | $this->console->addCommandsFromRoutes($application->router()->getRouteMatch(), './kettle'); |
65 | } |
66 | |
67 | /** |
68 | * Get application object |
69 | * |
70 | * @return Application |
71 | */ |
72 | public function application(): Application |
73 | { |
74 | return $this->application; |
75 | } |
76 | |
77 | /** |
78 | * Get request object |
79 | * |
80 | * @return Console |
81 | */ |
82 | public function console(): Console |
83 | { |
84 | return $this->console; |
85 | } |
86 | |
87 | /** |
88 | * Default error action method |
89 | * |
90 | * @throws Exception |
91 | * @return void |
92 | */ |
93 | public function error(): void |
94 | { |
95 | throw new Exception('Invalid Command'); |
96 | } |
97 | |
98 | } |