Passed
Pull Request — master (#42)
by Arman
03:27
created

FileLogger   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 6
c 1
b 0
f 0
dl 0
loc 31
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A report() 0 3 1
A __construct() 0 4 1
1
<?php
2
3
/**
4
 * Quantum PHP Framework
5
 *
6
 * An open source software development framework for PHP
7
 *
8
 * @package Quantum
9
 * @author Arman Ag. <[email protected]>
10
 * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
11
 * @link http://quantum.softberg.org/
12
 * @since 2.4.0
13
 */
14
15
namespace Quantum\Logger;
16
17
18
use Quantum\Contracts\ReportableInterface;
19
use Quantum\Libraries\Storage\FileSystem;
20
use Quantum\Di\Di;
21
22
/**
23
 * Class FileLogger
24
 * @package Quantum\Logger
25
 */
26
class FileLogger implements ReportableInterface
27
{
28
29
    /**
30
     * @var \Quantum\Libraries\Storage\FileSystem
31
     */
32
    private $fs;
33
34
    /**
35
     * @var string
36
     */
37
    private $logFile;
38
39
    /**
40
     * FileLogger constructor.
41
     * @param string $logFile
42
     * @throws \Quantum\Exceptions\DiException
43
     * @throws \ReflectionException
44
     */
45
    public function __construct(string $logFile)
46
    {
47
        $this->logFile = $logFile;
48
        $this->fs = Di::get(FileSystem::class);
49
    }
50
51
    /**
52
     * @inheritDoc
53
     */
54
    public function report($level, $message, array $context = [])
55
    {
56
        $this->fs->append($this->logFile, $message);
57
    }
58
59
}