Passed
Pull Request — master (#6)
by Victor
03:27
created

ContactChecker::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 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 4
    public function __construct(Client $client)
18
    {
19 4
        $this->client = $client;
20 4
    }
21
22
    /**
23
     * hasNoBlockedEmail
24
     *
25
     * @param $email
26
     *
27
     * @return mixed
28
     */
29 3
    public function hasNoBlockedEmail($email)
30
    {
31 3
        $response = $this->client->get(['contactstatistics', $email]);
32 3
        if (!$response->success()) {
33 1
            return 'error';
34
        } else {
35 2
            $blockedCount = $response->getBody();
36 2
            if ($blockedCount['Data'][0]['BlockedCount']) {
37 1
                return false;
38
            }
39
40 1
            return true;
41
        }
42
    }
43
}
44