Domain   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setDomain() 0 12 3
A setAuthInfo() 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\Info;
13
14
use AfriCC\EPP\Frame\Command\Info as InfoCommand;
15
use AfriCC\EPP\Validator;
16
use Exception;
17
18
/**
19
 * @see http://tools.ietf.org/html/rfc5731#section-3.1.2
20
 */
21
class Domain extends InfoCommand
22
{
23
    public function setDomain($domain, $return = 'all')
24
    {
25
        if (!Validator::isHostname($domain)) {
26
            throw new Exception(sprintf('%s is not a valid domain name', $domain));
27
        }
28
29
        if (!in_array($return, ['all', 'del', 'sub', 'none'])) {
30
            throw new Exception(sprintf('%s is not a known return value', $return));
31
        }
32
33
        $this->set(sprintf('domain:name[@hosts=\'%s\']', $return), $domain);
34
    }
35
36
    public function setAuthInfo($pw, $roid = null)
37
    {
38
        $node = $this->set('domain:authInfo/domain:pw', $pw);
39
40
        if ($roid !== null) {
41
            $node->setAttribute('roid', $roid);
42
        }
43
    }
44
}
45