File   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 28
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A log() 0 9 1
1
<?php
2
/**
3
 * CSP
4
 *
5
 * @author     Kenji Suzuki <https://github.com/kenjis>
6
 * @license    MIT License
7
 * @copyright  2014 Kenji Suzuki
8
 * @link       https://github.com/kenjis/php-csp-nonce-source
9
 */
10
11
namespace Kenjis\Csp\Logger;
12
13
class File implements LoggerInterface
14
{
15
    /**
16
     * @var string
17
     */
18
    private $logfile;
19
20
    /**
21
     * @param string $logfile
22
     */
23
    public function __construct($logfile)
24
    {
25
        $this->logfile = $logfile;
26
    }
27
28
    /**
29
     * @param \stdClass report object
30
     */
31
    public function log(\stdClass $report)
32
    {
33
        $data = json_encode(
34
            $report,
35
            JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES
36
        );
37
38
        file_put_contents($this->logfile, $data . "\n", LOCK_EX | FILE_APPEND);
39
    }
40
}
41