Host   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setHost() 0 8 2
A addAddr() 0 4 1
A addStatus() 0 4 1
A removeAddr() 0 4 1
A removeStatus() 0 4 1
A changeHost() 0 8 2
1
<?php
2
3
/**
4
 * This file is part of the php-epp2 library.
5
 *
6
 * (c) Gunter Grodotzki <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE file
9
 * that was distributed with this source code.
10
 */
11
12
namespace AfriCC\EPP\Frame\Command\Update;
13
14
use AfriCC\EPP\AddrTrait;
15
use AfriCC\EPP\Frame\Command\Update as UpdateCommand;
16
use AfriCC\EPP\Validator;
17
use Exception;
18
19
/**
20
 * @see http://tools.ietf.org/html/rfc5732#section-3.2.5
21
 */
22
class Host extends UpdateCommand
23
{
24
    use AddrTrait;
25
26
    public function setHost($host)
27
    {
28
        if (!Validator::isHostname($host)) {
29
            throw new Exception(sprintf('%s is not a valid host name', $host));
30
        }
31
32
        $this->set('host:name', $host);
33
    }
34
35
    public function addAddr($ip)
36
    {
37
        $this->appendAddr('host:add/host:addr[]', $ip);
38
    }
39
40
    public function addStatus($status)
41
    {
42
        $this->set(sprintf('host:add/host:status[@s=\'%s\']', $status));
43
    }
44
45
    public function removeAddr($ip)
46
    {
47
        $this->appendAddr('host:rem/host:addr[]', $ip);
48
    }
49
50
    public function removeStatus($status)
51
    {
52
        $this->set(sprintf('host:rem/host:status[@s=\'%s\']', $status));
53
    }
54
55
    public function changeHost($host)
56
    {
57
        if (!Validator::isHostname($host)) {
58
            throw new Exception(sprintf('%s is not a valid host name', $host));
59
        }
60
61
        $this->set('host:chg/host:name', $host);
62
    }
63
}
64