Total Complexity | 7 |
Total Lines | 33 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
8 | class SludioLogger |
||
9 | { |
||
10 | protected $logger; |
||
11 | |||
12 | /** |
||
13 | * Constructor. |
||
14 | * |
||
15 | * @param LoggerInterface $logger |
||
16 | */ |
||
17 | public function __construct($logger = null) |
||
18 | { |
||
19 | if (!$logger instanceof LoggerInterface && null !== $logger) { |
||
20 | throw new InvalidArgumentException(sprintf('SludioLogger needs PSR-3 LoggerInterface, "%s" was injected instead.', is_object($logger) ? get_class($logger) : gettype($logger))); |
||
21 | } |
||
22 | |||
23 | $this->logger = $logger; |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * Logs a command |
||
28 | * |
||
29 | * @param string $command Sludio command |
||
30 | * @param bool|string $error Error message or null |
||
31 | * @param string $type Log type |
||
32 | */ |
||
33 | public function log($command, $error = false, $type = 'info') |
||
34 | { |
||
35 | $this->logger->{(string)$type}($command.': '.strtoupper((string)$type).($error !== false ? ': '.$error : '')); |
||
|
|||
36 | } |
||
37 | |||
38 | public function error($command, $error) |
||
41 | } |
||
42 | } |