Host   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setHost() 0 9 2
A addAddr() 0 4 1
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\Create;
13
14
use AfriCC\EPP\AddrTrait;
15
use AfriCC\EPP\Frame\Command\Create as CreateCommand;
16
use AfriCC\EPP\Validator;
17
use Exception;
18
19
/**
20
 * @see http://tools.ietf.org/html/rfc5732#section-3.2.1
21
 */
22
class Host extends CreateCommand
23
{
24
    use AddrTrait;
25
26
    public function setHost($hostname)
27
    {
28
        // validate hostname
29
        if (!Validator::isHostname($hostname)) {
30
            throw new Exception(sprintf('not a valid Hostname: %s', $hostname));
31
        }
32
33
        $this->set('host:name', $hostname);
34
    }
35
36
    public function addAddr($ip)
37
    {
38
        $this->appendAddr('host:addr[]', $ip);
39
    }
40
}
41