Code Coverage  | 
      ||||||||||
Lines  | 
       Functions and Methods  | 
       Classes and Traits  | 
      ||||||||
| Total |         | 
       100.00%  | 
       6 / 6  | 
               | 
       100.00%  | 
       2 / 2  | 
       CRAP |         | 
       100.00%  | 
       1 / 1  | 
      
| FileLogger |         | 
       100.00%  | 
       6 / 6  | 
               | 
       100.00%  | 
       2 / 2  | 
       4 |         | 
       100.00%  | 
       1 / 1  | 
      
| setDestination |         | 
       100.00%  | 
       4 / 4  | 
               | 
       100.00%  | 
       1 / 1  | 
       3 | |||
| write |         | 
       100.00%  | 
       2 / 2  | 
               | 
       100.00%  | 
       1 / 1  | 
       1 | |||
| 1 | <?php declare(strict_types=1); | 
| 2 | /* | 
| 3 | * This file is part of Aplus Framework Log Library. | 
| 4 | * | 
| 5 | * (c) Natan Felles <natanfelles@gmail.com> | 
| 6 | * | 
| 7 | * For the full copyright and license information, please view the LICENSE | 
| 8 | * file that was distributed with this source code. | 
| 9 | */ | 
| 10 | namespace Framework\Log\Loggers; | 
| 11 | |
| 12 | use Framework\Log\Log; | 
| 13 | use Framework\Log\Logger; | 
| 14 | use InvalidArgumentException; | 
| 15 | |
| 16 | /** | 
| 17 | * Class FileLogger. | 
| 18 | * | 
| 19 | * @package log | 
| 20 | */ | 
| 21 | class FileLogger extends Logger | 
| 22 | { | 
| 23 | protected function setDestination(string $destination) : static | 
| 24 | { | 
| 25 | if ( ! \is_file($destination) && ! \is_dir(\dirname($destination))) { | 
| 26 | throw new InvalidArgumentException('Invalid file destination: ' . $destination); | 
| 27 | } | 
| 28 | $this->destination = $destination; | 
| 29 | return $this; | 
| 30 | } | 
| 31 | |
| 32 | protected function write(Log $log) : bool | 
| 33 | { | 
| 34 | $eol = $this->getConfig()['eol'] ?? \PHP_EOL . \PHP_EOL; | 
| 35 | return \error_log($log . $eol, 3, $this->getDestination()); | 
| 36 | } | 
| 37 | } |