Template::getRenderer()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 4
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
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\RendererInterface;
16
17 View Code Duplication
abstract class Template extends StreamCollector implements StreamCollectorInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
18
{
19
    /**
20
     * The path in the final json
21
     * @example
22
     *  path /aa/bb
23
     *  will be transformed to
24
     *  {
25
     *     aa : {
26
     *              bb: <VALUE OF RESOLVE>
27
     *       }
28
     *  }
29
     * @return mixed
30
     */
31 2
    public function getPath()
32
    {
33 2
        return 'template';
34
    }
35
36 2
    public function getDataFields()
37
    {
38
        return [
39 2
            'name', 'data', 'time', 'file'
40 2
        ];
41
    }
42
43
    /**
44
     * Write data in the datasource and clean current buffer
45
     * @return mixed
46
     */
47
    public function stream()
48
    {
49
        $patch = $this->jsonPatch->generate($this->getPath(), JsonPatch::ACTION_ADD, $this->data, true);
50
        $this->dataSource->save($this->process, [$patch]);
51
        $this->data = [];
52
    }
53
54
    /**
55
     * @return RendererInterface
56
     *
57
     * @throws \RuntimeException
58
     */
59
    public function getRenderer()
60
    {
61
        return new \Ndrx\Profiler\Renderer\Html\Data\Template();
62
    }
63
}
64