Conditions | 5 |
Paths | 4 |
Total Lines | 20 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
19 | 7 | public function __construct($logObject) |
|
20 | { |
||
21 | 7 | switch (true) { |
|
22 | 7 | case $logObject instanceof LogInterface: |
|
23 | 3 | $this->log = $logObject; |
|
24 | 3 | break; |
|
25 | |||
26 | 4 | case is_string($logObject) && $this->classExists($logObject): |
|
27 | 2 | $this->log = new $logObject(); |
|
28 | |||
29 | 2 | if (!$this->log instanceof LogInterface) { |
|
30 | 1 | $message = 'Log should be instance of SimpleLog\LogInterface: ' . get_class($this->log); |
|
31 | 1 | throw new \LogicException($message); |
|
32 | } |
||
33 | |||
34 | 1 | break; |
|
35 | |||
36 | 1 | default: |
|
37 | 1 | throw new \LogicException('Cannot create Log instance: ' . get_class($logObject)); |
|
|
|||
38 | break; |
||
39 | 1 | } |
|
71 |