DomainManager::fetchRecord()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 13
ccs 7
cts 7
cp 1
rs 9.4285
cc 1
eloc 6
nc 1
nop 0
crap 1
1
<?php
2
3
namespace PeterNijssen\Ses\Manager;
4
5
use Aws\Ses\SesClient;
6
use PeterNijssen\Ses\Model\Dns;
7
use PeterNijssen\Ses\Model\DomainIdentity;
8
9
/**
10
 * This manager handles domain identities
11
 */
12
class DomainManager extends SesManager
13
{
14
    /**
15
     * Constructor
16
     *
17
     * @param SesClient      $sesClient
18
     * @param DomainIdentity $identity
19
     */
20 9
    public function __construct(SesClient $sesClient, DomainIdentity $identity)
21
    {
22 9
        parent::__construct($sesClient, $identity);
23 9
    }
24
25
    /**
26
     * Create the identity within SES
27
     */
28 1
    public function create()
29
    {
30 1
        $this->sesClient->verifyDomainIdentity(
31
            [
32 1
                'Domain' => $this->identity->getIdentity(),
33
            ]
34 1
        );
35 1
    }
36
37
    /**
38
     * Return the DNS record for the domain
39
     *
40
     * @return Dns
41
     */
42 1
    public function fetchRecord()
43
    {
44 1
        $result = $this->sesClient->verifyDomainIdentity(
45
            [
46 1
                'Domain' => $this->identity->getIdentity(),
47
            ]
48 1
        );
49
50 1
        $value = $result->search("VerificationToken");
51 1
        $name = "_amazonses.".$this->identity->getDomain();
52
53 1
        return new Dns("TXT", $name, $value);
54
    }
55
}
56