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

JoseCollector::reset()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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