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

Future::setFuture()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
namespace AfriCC\EPP\Extension\NASK\Renew;
3
4
use AfriCC\EPP\Frame\Command\Renew as RenewCommand;
5
use AfriCC\EPP\PeriodTrait;
6
use AfriCC\EPP\Validator;
7
use Exception;
8
9
class Future extends RenewCommand
10
{
11
    use PeriodTrait;
12
13
    /**
14
     * Set domain name for future (option)
15
     *
16
     * @param string $domain Domain Name
17
     *
18
     * @throws Exception on incorrect domain name
19
     */
20
    public function setFuture($domain)
21
    {
22
        if (!Validator::isHostname($domain)) {
23
            throw new Exception(sprintf('%s is not a valid domain name', $domain));
24
        }
25
26
        $this->set('future:name', $domain);
27
    }
28
29
    /**
30
     * Set current expiration date of future object
31
     *
32
     * @param string $curExpDate date in yyyy-mm-dd format
33
     */
34
    public function setCurrentExpirationDate($curExpDate)
35
    {
36
        $this->set('future:curExpDate', $curExpDate);
37
    }
38
39
    /**
40
     * Set renew period for future object
41
     *
42
     * Usually this should be 3y.
43
     *
44
     * @param string $period ending in y (for years) or m (for months)
45
     */
46
    public function setPeriod($period)
47
    {
48
        $this->appendPeriod('future:period[@unit=\'%s\']', $period);
49
    }
50
}
51
52