Domain   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 47
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A list() 0 6 1
A create() 0 10 1
A delete() 0 4 1
1
<?php
2
/*
3
 *   This file is part of the Vultr PHP library.
4
 *
5
 *   (c) Albert Leitato <[email protected]>
6
 *
7
 *   For the full copyright and license information, please view the LICENSE
8
 *   file that was distributed with this source code.
9
 */
10
namespace Vultr\Api;
11
12
use Vultr\Entity\Domain as DomainEntity;
13
use Vultr\Exceptions\HttpException;
14
15
/**
16
 * @author Albert Leitato <[email protected]>
17
 */
18
class Domain extends AbstractApi
19
{
20
    /**
21
     * List all domains associated with the current account.
22
     *
23
     * @return DomainEntity[]
24
     */
25
    public function list()
26
    {
27
        $domains = $this->adapter->get(\sprintf('%s/dns/list', $this->endpoint));
28
29
        return $this->heanleResponse($domains, DomainEntity::class, true);
0 ignored issues
show
Bug introduced by
The method heanleResponse() does not exist on Vultr\Api\Domain. Did you maybe mean handleResponse()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
30
    }
31
32
    /**
33
     * Create a domain name in DNS.
34
     *
35
     * @param string $name      Domain name to create
36
     * @param string $ipAddress IP to use when creating default records (A and MX)
37
     *
38
     * @throws HttpException
39
     *
40
     * @return DomainEntity
41
     */
42
    public function create($name, $ipAddress)
43
    {
44
        $content = ['name' => $name, 'serverip' => $ipAddress];
45
46
        $domain = $this->adapter->post(\sprintf('%s/dns/create_domain', $this->endpoint), http_build_query($content));
47
48
        $domain = \json_decode($domain);
49
50
        return new DomainEntity($domain->domain);
51
    }
52
53
    /**
54
     * Delete a domain name and all associated records.
55
     *
56
     * @param string $domain Domain name to delete
57
     *
58
     * @throws HttpException
59
     */
60
    public function delete($domain)
61
    {
62
        $this->adapter->post(\sprintf('%s/dns/delete_domain', $this->endpoint), http_build_query(compact('domain')));
63
    }
64
}
65