AbstractSoapDataCollector   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 82.61%

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 2
dl 0
loc 71
ccs 19
cts 23
cp 0.8261
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A doCollect() 0 13 3
A reset() 0 8 1
A getName() 0 4 1
A getTotal() 0 4 1
A getTime() 0 4 1
A getRequests() 0 4 1
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 9
    public function __construct(SoapCallRegistry $callRegistry)
16
    {
17 9
        $this->callRegistry = $callRegistry;
18 9
    }
19
20
    /**
21
     * @see collect()
22
     */
23 9
    protected function doCollect()
24
    {
25 9
        $time = 0;
26 9
        foreach ($this->callRegistry->getCalls() as $call) {
27 9
            $time += (isset($call['duration']) ? $call['duration'] : 0);
28
        }
29
30 9
        $this->data = [
31 9
            'total'    => count($this->callRegistry->getCalls()),
32 9
            'time'     => $time,
33 9
            'requests' => $this->callRegistry->getCalls(),
34
        ];
35 9
    }
36
37 3
    public function reset()
38
    {
39 3
        $this->data = [
40
            'total'    => 0,
41
            'time'     => 0,
42
            'requests' => [],
43
        ];
44 3
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49 9
    public function getName()
50
    {
51 9
        return 'freshcells_soap_client';
52
    }
53
54
    /**
55
     * @return int
56
     */
57 9
    public function getTotal()
58
    {
59 9
        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