1 | <?php |
||
12 | class Route |
||
13 | { |
||
14 | private $name; |
||
15 | private $method = 'get'; |
||
16 | private $pattern = '/'; |
||
17 | private $handler; |
||
18 | private $scope = Jarvis::DEFAULT_SCOPE; |
||
19 | private $router; |
||
20 | |||
21 | public function __construct(string $name = null, Router $router) |
||
26 | |||
27 | public function name() |
||
31 | |||
32 | public function method() : string |
||
36 | |||
37 | public function setMethod(string $method) : Route |
||
43 | |||
44 | public function pattern() : string |
||
48 | |||
49 | public function setPattern(string $pattern) : Route |
||
55 | |||
56 | public function handler() |
||
60 | |||
61 | public function setHandler($handler) : Route |
||
67 | |||
68 | public function scope() : string |
||
72 | |||
73 | public function setScope(string $scope) : Route |
||
79 | |||
80 | public function end() |
||
84 | } |
||
85 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.