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

Future::changeRegistrant()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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