Passed
Push — master ( f3b94d...fdd73f )
by nicolas
01:01
created

MailjetDataCollector   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 5
c 2
b 0
f 1
lcom 1
cbo 2
dl 0
loc 47
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A collect() 0 4 1
A getName() 0 4 1
A getData() 0 4 1
A getCallCount() 0 4 1
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
        return count($this->data);
58
    }
59
}
60