Event   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 41.67%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getPath() 4 4 1
A getDataFields() 6 6 1
A stream() 6 6 1
A getRenderer() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 Event 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 'events';
34
    }
35
36 2
    public function getDataFields()
37
    {
38
        return [
39 2
            'name', 'param', 'time'
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\Event();
62
    }
63
}
64