Completed
Pull Request — master (#67)
by
unknown
01:33
created

Future::changeAuthInfo()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

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