| Conditions | 5 |
| Paths | 9 |
| Total Lines | 24 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 28 | 12 | public function store($message, $level) |
|
| 29 | { |
||
| 30 | 12 | $flag = 0; |
|
| 31 | 12 | $logFile = $this->params['log_path'] . DIRECTORY_SEPARATOR . $level . '.log'; |
|
| 32 | |||
| 33 | 12 | if (!file_exists($this->params['log_path'])) { |
|
| 34 | 10 | $bool = mkdir($this->params['log_path']); |
|
| 35 | |||
| 36 | 10 | if (!$bool) { |
|
| 37 | 1 | throw new LogException('Unable to create log directory: ' . $this->params['log_path']); |
|
| 38 | } |
||
| 39 | 9 | } |
|
| 40 | |||
| 41 | 11 | if (file_exists($logFile)) { |
|
| 42 | 2 | $flag = FILE_APPEND; |
|
| 43 | 2 | } |
|
| 44 | |||
| 45 | 11 | $bool = file_put_contents($logFile, $message, $flag); |
|
| 46 | |||
| 47 | 11 | if (!$bool) { |
|
| 48 | 1 | throw new LogException('Unable to save log file: ' . $logFile); |
|
| 49 | } |
||
| 50 | |||
| 51 | 10 | return $this; |
|
| 52 | } |
||
| 54 |