CacheDataLogger::log()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PhpCache\Example\Logger;
4
5
/**
6
 * Description of CacheDataLogger.
7
 *
8
 * @author kdudas
9
 */
10
class CacheDataLogger
11
{
12
    private $logFilePath;
13
    private $logFileDir;
14
15
    public function __construct($logFilePath)
16
    {
17
        $this->logFilePath = $logFilePath;
18
        $pathParts = explode('/', $logFilePath);
19
        if (count($pathParts) > 1) {
20
            unset($pathParts[count($pathParts) - 1]);
21
            $this->logFileDir = implode('/', $pathParts);
22
            if (!file_exists($this->logFileDir)) {
23
                mkdir($this->logFileDir);
24
            }
25
        }
26
    }
27
28
    public function log($entry)
29
    {
30
        return file_put_contents($this->logFilePath, $entry."\n", FILE_APPEND);
31
    }
32
}
33