1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace unreal4u\MQTT\Internals; |
||
6 | |||
7 | use Psr\Log\LoggerInterface; |
||
8 | use unreal4u\Dummy\Logger; |
||
9 | |||
10 | abstract class ProtocolBase |
||
11 | { |
||
12 | /** |
||
13 | * The actual logger object |
||
14 | * @var LoggerInterface |
||
15 | */ |
||
16 | protected $logger; |
||
17 | |||
18 | /** |
||
19 | * Base constructor for all protocol stuff |
||
20 | * @param LoggerInterface|null $logger |
||
21 | */ |
||
22 | 127 | final public function __construct(LoggerInterface $logger = null) |
|
23 | { |
||
24 | 127 | if ($logger === null) { |
|
25 | 127 | $logger = new Logger(); |
|
26 | } |
||
27 | |||
28 | // Insert name of class within the logger |
||
29 | 127 | $this->logger = $logger->withName(str_replace('unreal4u\\MQTT\\', '', \get_class($this))); |
|
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
30 | |||
31 | 127 | $this->initializeObject(); |
|
32 | 127 | } |
|
33 | |||
34 | /** |
||
35 | * Should any method have any abnormal default behaviour, we can do so here |
||
36 | * |
||
37 | * @return ProtocolBase |
||
38 | */ |
||
39 | 127 | protected function initializeObject(): ProtocolBase |
|
40 | { |
||
41 | 127 | return $this; |
|
42 | } |
||
43 | } |
||
44 |