Failed Conditions
Push — master ( fce8c6...a363f7 )
by Florent
06:01 queued 50s
created

JoseCollector   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 49
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-2017 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
20
final class JoseCollector extends DataCollector
21
{
22
    /**
23
     * @var Collector[]
24
     */
25
    private $collectors = [];
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function collect(Request $request, Response $response, \Exception $exception = null)
31
    {
32
        foreach ($this->collectors as $collector) {
33
            $collector->collect($this->data, $request, $response, $exception);
34
        }
35
    }
36
37
    /**
38
     * @param Collector $collector
39
     */
40
    public function add(Collector $collector)
41
    {
42
        $this->collectors[] = $collector;
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function getName()
49
    {
50
        return 'jose_collector';
51
    }
52
53
    /**
54
     * @return array
55
     */
56
    public function getData(): array
57
    {
58
        return $this->data;
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64
    public function reset()
65
    {
66
        $this->data = [];
67
    }
68
}
69