Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
6 / 6 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
| HttpControllerTrait | |
100.00% |
6 / 6 |
|
100.00% |
4 / 4 |
4 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| application | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| request | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| response | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Pop PHP Framework (https://www.popphp.org/) |
| 4 | * |
| 5 | * @link https://github.com/popphp/popphp-framework |
| 6 | * @author Nick Sagona, III <dev@noladev.com> |
| 7 | * @copyright Copyright (c) 2009-2026 NOLA Interactive, LLC. |
| 8 | * @license https://www.popphp.org/license New BSD License |
| 9 | */ |
| 10 | |
| 11 | /** |
| 12 | * @namespace |
| 13 | */ |
| 14 | namespace Pop\Controller; |
| 15 | |
| 16 | use Pop\Application; |
| 17 | use Pop\Http\Server\Request; |
| 18 | use Pop\Http\Server\Response; |
| 19 | use Pop\Http\Uri; |
| 20 | |
| 21 | /** |
| 22 | * Pop HTTP controller trait |
| 23 | * |
| 24 | * @category Pop |
| 25 | * @package Pop\Controller |
| 26 | * @author Nick Sagona, III <dev@noladev.com> |
| 27 | * @copyright Copyright (c) 2009-2026 NOLA Interactive, LLC. |
| 28 | * @license https://www.popphp.org/license New BSD License |
| 29 | * @version 4.4.0 |
| 30 | */ |
| 31 | trait HttpControllerTrait |
| 32 | { |
| 33 | |
| 34 | /** |
| 35 | * Application object |
| 36 | * @var ?Application |
| 37 | */ |
| 38 | protected ?Application $application = null; |
| 39 | |
| 40 | /** |
| 41 | * Request object |
| 42 | * @var ?Request |
| 43 | */ |
| 44 | protected ?Request $request = null; |
| 45 | |
| 46 | /** |
| 47 | * Response object |
| 48 | * @var ?Response |
| 49 | */ |
| 50 | protected ?Response $response = null; |
| 51 | |
| 52 | /** |
| 53 | * Constructor for the controller |
| 54 | * |
| 55 | * @param Application $application |
| 56 | * @param Request $request |
| 57 | * @param Response $response |
| 58 | */ |
| 59 | public function __construct( |
| 60 | Application $application, Request $request = new Request(new Uri()), Response $response = new Response() |
| 61 | ) |
| 62 | { |
| 63 | $this->application = $application; |
| 64 | $this->request = $request; |
| 65 | $this->response = $response; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Get application object |
| 70 | * |
| 71 | * @return ?Application |
| 72 | */ |
| 73 | public function application(): ?Application |
| 74 | { |
| 75 | return $this->application; |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Get request object |
| 80 | * |
| 81 | * @return ?Request |
| 82 | */ |
| 83 | public function request(): ?Request |
| 84 | { |
| 85 | return $this->request; |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * Get response object |
| 90 | * |
| 91 | * @return ?Response |
| 92 | */ |
| 93 | public function response(): ?Response |
| 94 | { |
| 95 | return $this->response; |
| 96 | } |
| 97 | |
| 98 | } |