1 | <?php |
||
9 | abstract class InputHandler |
||
10 | { |
||
11 | /** |
||
12 | * @var BaseNode |
||
13 | */ |
||
14 | protected $root; |
||
15 | |||
16 | /** |
||
17 | * @var TypeHandler |
||
18 | */ |
||
19 | protected $typeHandler; |
||
20 | |||
21 | /** |
||
22 | * @var array |
||
23 | */ |
||
24 | protected $output = []; |
||
25 | |||
26 | /** |
||
27 | * @var array |
||
28 | */ |
||
29 | protected $errors = []; |
||
30 | |||
31 | public function __construct(TypeHandler $typeHandler = null) |
||
37 | |||
38 | public function add(string $key, string $type, array $options = []): BaseNode |
||
42 | |||
43 | public function remove(string $key) |
||
47 | |||
48 | public function bind(array $input) |
||
60 | |||
61 | public function getData($index = null) |
||
73 | |||
74 | public function isValid(): bool |
||
78 | |||
79 | public function getErrors(): array |
||
83 | |||
84 | public function getErrorsAsString(): string |
||
88 | |||
89 | abstract public function define(); |
||
90 | } |
||
91 |
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.