JoseCollector   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 37
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A collect() 0 6 2
A add() 0 4 1
A getName() 0 4 1
A getData() 0 4 1
A reset() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2019 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace Jose\Bundle\JoseFramework\DataCollector;
15
16
use Symfony\Component\HttpFoundation\Request;
17
use Symfony\Component\HttpFoundation\Response;
18
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
19
use Symfony\Component\VarDumper\Cloner\Data;
20
21
class JoseCollector extends DataCollector
22
{
23
    /**
24
     * @var Collector[]
25
     */
26
    private $collectors = [];
27
28
    public function collect(Request $request, Response $response, ?\Exception $exception = null): void
29
    {
30
        foreach ($this->collectors as $collector) {
31
            $collector->collect($this->data, $request, $response, $exception);
32
        }
33
    }
34
35
    public function add(Collector $collector): void
36
    {
37
        $this->collectors[] = $collector;
38
    }
39
40
    public function getName()
41
    {
42
        return 'jose_collector';
43
    }
44
45
    /**
46
     * @return array|Data
47
     */
48
    public function getData()
49
    {
50
        return $this->data;
51
    }
52
53
    public function reset(): void
54
    {
55
        $this->data = [];
56
    }
57
}
58