Completed
Push — master ( 3fbd33...51cff9 )
by David
02:08
created

ConnectionResponse::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2.0078

Importance

Changes 0
Metric Value
dl 0
loc 13
c 0
b 0
f 0
ccs 7
cts 8
cp 0.875
rs 9.8333
cc 2
nc 2
nop 1
crap 2.0078
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Copyright (C) 2013 Mailgun
7
 *
8
 * This software may be modified and distributed under the terms
9
 * of the MIT license. See the LICENSE file for details.
10
 */
11
12
namespace Mailgun\Model\Domain;
13
14
use Mailgun\Model\ApiResponse;
15
16
/**
17
 * @author Sean Johnson <[email protected]>
18
 */
19
final class ConnectionResponse implements ApiResponse
20
{
21
    private $noVerify;
22
    private $requireTLS;
23
24 1
    public static function create(array $data): ?self
25
    {
26 1
        if (!isset($data['connection'])) {
27
            return null;
28
        }
29 1
        $connSettings = $data['connection'];
30
31 1
        $model = new self();
32 1
        $model->noVerify = $connSettings['skip_verification'] ?? null;
33 1
        $model->requireTLS = $connSettings['require_tls'] ?? null;
34
35 1
        return $model;
36
    }
37
38 1
    private function __construct()
39
    {
40 1
    }
41
42
    /**
43
     * Disable remote TLS certificate verification.
44
     *
45
     * @return bool
46
     */
47 1
    public function getSkipVerification(): ?bool
48
    {
49 1
        return $this->noVerify;
50
    }
51
52
    /**
53
     * Requires TLS for all outbound communication.
54
     *
55
     * @return bool
56
     */
57 1
    public function getRequireTLS(): ?bool
58
    {
59 1
        return $this->requireTLS;
60
    }
61
}
62