Completed
Push — master ( 4e7de2...1dbfef )
by Ivo
15s queued 12s
created

AbstractSoapDataCollector::getRequests()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Freshcells\SoapClientBundle\DataCollector;
4
5
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
6
7
abstract class AbstractSoapDataCollector extends DataCollector
8
{
9
    private $callRegistry;
10
11
    /**
12
     * SoapDataCollector constructor.
13
     * @param SoapCallRegistry $callRegistry
14
     */
15 6
    public function __construct(SoapCallRegistry $callRegistry)
16
    {
17 6
        $this->callRegistry = $callRegistry;
18 6
    }
19
20
    /**
21
     * @see collect()
22
     */
23 6
    protected function doCollect()
24
    {
25 6
        $time = 0;
26 6
        foreach ($this->callRegistry->getCalls() as $call) {
27 6
            $time += (isset($call['duration']) ? $call['duration'] : 0);
28
        }
29
30 6
        $this->data = [
31 6
            'total'    => count($this->callRegistry->getCalls()),
32 6
            'time'     => $time,
33 6
            'requests' => $this->callRegistry->getCalls(),
34
        ];
35 6
    }
36
37 4
    public function reset()
38
    {
39 4
        $this->data = [
40
            'total'    => 0,
41
            'time'     => 0,
42
            'requests' => [],
43
        ];
44 4
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49 6
    public function getName()
50
    {
51 6
        return 'freshcells_soap_client';
52
    }
53
54
    /**
55
     * @return int
56
     */
57 6
    public function getTotal()
58
    {
59 6
        return $this->data['total'];
60
    }
61
62
    /**
63
     * @return int Time in milliseconds.
64
     */
65
    public function getTime()
66
    {
67
        return $this->data['time'];
68
    }
69
70
    /**
71
     * @return array
72
     */
73
    public function getRequests()
74
    {
75
        return $this->data['requests'];
76
    }
77
}
78