Cache   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 41.67%

Importance

Changes 6
Bugs 0 Features 1
Metric Value
wmc 4
c 6
b 0
f 1
lcom 1
cbo 4
dl 0
loc 47
ccs 5
cts 12
cp 0.4167
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A stream() 0 6 1
A getDataFields() 0 6 1
A getPath() 0 4 1
A getRenderer() 0 4 1
1
<?php
2
/**
3
 * User: LAHAXE Arnaud
4
 * Date: 05/11/2015
5
 * Time: 12:40
6
 * FileName : User.php
7
 * Project : profiler
8
 */
9
10
namespace Ndrx\Profiler\Collectors\Data;
11
12
use Ndrx\Profiler\Collectors\Contracts\StreamCollectorInterface;
13
use Ndrx\Profiler\Collectors\StreamCollector;
14
use Ndrx\Profiler\JsonPatch;
15
use Ndrx\Profiler\Renderer\BarRenderableInterface;
16
use Ndrx\Profiler\Renderer\RendererInterface;
17
18
abstract class Cache extends StreamCollector implements StreamCollectorInterface, BarRenderableInterface
19
{
20
    /**
21
     * Write data in the datasource and clean current buffer
22
     * @return mixed
23
     */
24
    public function stream()
25
    {
26
        $patch = $this->jsonPatch->generate($this->getPath(), JsonPatch::ACTION_ADD, $this->data, true);
27
        $this->dataSource->save($this->process, [$patch]);
28
        $this->data = [];
29
    }
30
31 2
    public function getDataFields()
32
    {
33
        return [
34 2
            'action', 'value', 'lifetime', 'key', 'result', 'success'
35 2
        ];
36
    }
37
38
    /**
39
     * The path in the final json
40
     * @example
41
     *  path /aa/bb
42
     *  will be transformed to
43
     *  {
44
     *     aa : {
45
     *              bb: <VALUE OF RESOLVE>
46
     *       }
47
     *  }
48
     * @return mixed
49
     */
50 2
    public function getPath()
51
    {
52 2
        return 'cache';
53
    }
54
55
    /**
56
     * @return RendererInterface
57
     *
58
     * @throws \RuntimeException
59
     */
60
    public function getRenderer()
61
    {
62
        return new \Ndrx\Profiler\Renderer\Html\Data\Cache();
63
    }
64
}
65