Completed
Push — master ( 3b3aeb...14bab3 )
by
unknown
01:16
created

Future   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setFuture() 0 7 2
A changeRegistrant() 0 4 1
A changeAuthInfo() 0 10 2
1
<?php
2
3
namespace AfriCC\EPP\Extension\NASK\Update;
4
5
use AfriCC\EPP\Frame\Command\Update as UpdateCommand;
6
use AfriCC\EPP\Random;
7
use AfriCC\EPP\Validator;
8
use Exception;
9
10
class Future extends UpdateCommand
11
{
12
    /**
13
     * Set domain name for future (option)
14
     *
15
     * @param string $domain Domain Name
16
     *
17
     * @throws Exception on incorrect domain name
18
     */
19
    public function setFuture($domain)
20
    {
21
        if (!Validator::isHostname($domain)) {
22
            throw new Exception(sprintf('%s is not a valid domain name', $domain));
23
        }
24
        $this->set('future:name', $domain);
25
    }
26
27
    /**
28
     * Change registrant contact id of Future object
29
     *
30
     * @param string $registrant ContactID of registrant
31
     */
32
    public function changeRegistrant($registrant)
33
    {
34
        $this->set('future:chg/future:registrant', $registrant);
35
    }
36
37
    /**
38
     * Change future AuthInfo, generate if passed null
39
     *
40
     * @param string $pw AuthInfo code
41
     *
42
     * @return string  AuthInfo code
43
     */
44
    public function changeAuthInfo($pw = null)
45
    {
46
        if ($pw === null) {
47
            $pw = Random::auth(12);
48
        }
49
50
        $this->set('future:chg/future:authInfo/future:pw', $pw);
51
52
        return $pw;
53
    }
54
}
55