1 | <?php |
||
8 | class Log |
||
9 | { |
||
10 | /** @var int */ |
||
11 | private $ownerPid; |
||
12 | |||
13 | /** @var int */ |
||
14 | private $masterPid; |
||
15 | |||
16 | /** @var \Psr\Log\LoggerInterface */ |
||
17 | private $logger; |
||
18 | |||
19 | /** |
||
20 | * @param int $ownerPid |
||
21 | * @param LoggerInterface | null $logger |
||
22 | */ |
||
23 | public function __construct($ownerPid, $logger) |
||
28 | |||
29 | /** |
||
30 | * @param int $pid |
||
31 | * @return void |
||
32 | */ |
||
33 | public function setMasterPid($pid) |
||
37 | |||
38 | /** |
||
39 | * creates context |
||
40 | * |
||
41 | * @return array |
||
42 | */ |
||
43 | private function context() |
||
63 | |||
64 | /** |
||
65 | * info |
||
66 | * |
||
67 | * @param string $message |
||
68 | * @return void |
||
69 | */ |
||
70 | public function info($message) |
||
78 | |||
79 | /** |
||
80 | * error |
||
81 | * |
||
82 | * @param string $message |
||
83 | * @return void |
||
84 | */ |
||
85 | public function error($message) |
||
93 | } |
||
94 |
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.