| Total Complexity | 10 |
| Total Lines | 53 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | class ArrayLogger extends Logger |
||
| 22 | { |
||
| 23 | /** @var array */ |
||
| 24 | protected $logs; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @param int $mode |
||
| 28 | */ |
||
| 29 | public function __construct($mode = LoggerInterface::PLAIN_MODE) |
||
| 30 | { |
||
| 31 | parent::__construct($mode); |
||
| 32 | $this->logs = array(); |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @return array |
||
| 37 | */ |
||
| 38 | public function getLogs() |
||
| 39 | { |
||
| 40 | return $this->logs; |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @inheritDoc |
||
| 45 | */ |
||
| 46 | public function log($level, $message) |
||
| 47 | { |
||
| 48 | if ($this->mode === self::PLAIN_MODE) { |
||
| 49 | $this->logs[] = sprintf("%s %s", $level, $message); |
||
| 50 | } elseif ($this->mode === self::ARRAY_MODE) { |
||
| 51 | $lines = explode(self::CRLF, $message); |
||
| 52 | $this->logs[] = sprintf("%s %s", $level, $lines[0]); |
||
| 53 | foreach ($lines as $key => $line) { |
||
| 54 | if ($key === 0 || $line === '') continue; |
||
| 55 | $this->logs[] = $line; |
||
| 56 | } |
||
| 57 | } |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @inheritDoc |
||
| 62 | */ |
||
| 63 | public function clear() |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @inheritDoc |
||
| 70 | */ |
||
| 71 | public function count() |
||
| 74 | } |
||
| 75 | } |