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