Passed
Pull Request — master (#6)
by Victor
06:14
created

ContactChecker   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 29
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A hasNoBlockedEmail() 0 9 3
1
<?php
2
3
namespace Dekalee\MailjetBundle\Checker;
4
5
use Mailjet\Client;
6
7
/**
8
 * Class ContactChecker
9
 */
10
class ContactChecker
11
{
12
    protected $client;
13
14
    /**
15
     * @param Client $client
16
     */
17
    public function __construct(Client $client)
18
    {
19
        $this->client = $client;
20
    }
21
22
    /**
23
     * hasNoBlockedEmail
24
     *
25
     * @param $email
26
     *
27
     * @return bool
28
     */
29
    public function hasNoBlockedEmail($email)
30
    {
31
        $response = $this->client->get(['contactstatistics', $email]);
32
        $blockedCount = $response->getBody();
33
        if ($response->success() && $blockedCount['Data'][0]['BlockedCount']) {
34
            return false;
35
        }
36
        return true;
37
    }
38
}
39