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

ContactChecker::hasNoBlockedEmail()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 3
eloc 6
nc 2
nop 1
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