StreamCollector::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.6667
cc 1
eloc 5
nc 1
nop 3
crap 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: arnaud
5
 * Date: 31/10/15
6
 * Time: 17:40
7
 */
8
9
namespace Ndrx\Profiler\Collectors;
10
11
use Ndrx\Profiler\Collectors\Contracts\StreamCollectorInterface;
12
use Ndrx\Profiler\DataSources\Contracts\DataSourceInterface;
13
use Ndrx\Profiler\JsonPatch;
14
use Ndrx\Profiler\Process;
15
16
/**
17
 * Class StreamCollector
18
 * @package Ndrx\Profiler\Collectors
19
 */
20
abstract class StreamCollector extends Collector implements StreamCollectorInterface
21
{
22
    /**
23
     * @param Process $process
24
     * @param DataSourceInterface $dataSource
25
     * @param JsonPatch|null $jsonPatch
26
     */
27 118
    public function __construct(Process $process, DataSourceInterface $dataSource, JsonPatch $jsonPatch = null)
28
    {
29 118
        parent::__construct($process, $dataSource, $jsonPatch);
30
31
        // create logs domain
32 118
        $patch = $this->jsonPatch->generate($this->getPath(), JsonPatch::ACTION_ADD, [], false);
33 118
        $this->dataSource->save($this->process, [$patch]);
34 118
        $this->registerListeners();
35 118
    }
36
37
    abstract protected function registerListeners();
38
}
39