Passed
Pull Request — master (#2)
by nicolas
03:52
created

MailjetDataCollector::getCallCount()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 10
rs 9.4285
cc 2
eloc 5
nc 2
nop 0
1
<?php
2
3
namespace Dekalee\MailjetBundle\DataCollector;
4
5
use Dekalee\MailjetBundle\Client\DekaleeClient;
6
use Symfony\Component\HttpFoundation\Request;
7
use Symfony\Component\HttpFoundation\Response;
8
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
9
10
/**
11
 * Class MailjetDataCollector
12
 */
13
class MailjetDataCollector extends DataCollector
14
{
15
    protected $client;
16
17
    /**
18
     * @param DekaleeClient $client
19
     */
20
    public function __construct(DekaleeClient $client)
21
    {
22
        $this->client = $client;
23
    }
24
25
    /**
26
     * Collects data for the given Request and Response.
27
     *
28
     * @param Request    $request   A Request instance
29
     * @param Response   $response  A Response instance
30
     * @param \Exception $exception An Exception instance
31
     */
32
    public function collect(Request $request, Response $response, \Exception $exception = null)
33
    {
34
        $this->data = $this->client->getCalls();
35
    }
36
37
    /**
38
     * Returns the name of the collector.
39
     *
40
     * @return string The collector name
41
     */
42
    public function getName()
43
    {
44
        return 'mailjet';
45
    }
46
47
    /**
48
     * @return array
49
     */
50
    public function getData()
51
    {
52
        return $this->data;
53
    }
54
55
    public function getCallCount()
56
    {
57
        $count = 0;
58
59
        foreach ($this->data as $methodCalls) {
60
            $count += count($methodCalls);
61
        }
62
63
        return $count;
64
    }
65
}
66