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

Prepaid   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 70
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isAccountType() 0 10 3
A setPaymentsAccountType() 0 7 2
A setFundsAccountType() 0 7 2
1
<?php
2
namespace AfriCC\EPP\Extension\NASK\Report;
3
4
use AfriCC\EPP\Extension\NASK\Report;
5
6
class Prepaid extends Report
7
{
8
    
9
    /**
10
     * Check whether account type is acceptable by NASK
11
     * 
12
     * @param string $accountType
13
     * @return boolean
14
     */
15
    private function isAccountType($accountType)
16
    {
17
        switch (strtoupper($accountType)){
18
            case 'DOMAIN':
19
            case 'ENUM':
20
                return true;
21
            default:
22
                return false;
23
        }
24
    }
25
    
26
    /**
27
     * Set account type in conjunction with payments report.
28
     * 
29
     * Use either this or setFundsAccountType. Never combine them in single frame.
30
     * 
31
     * Acceptable accountType:
32
     * <ul>
33
     *  <li>DOMAIN</li>
34
     *  <li>ENUM</li>
35
     * </ul>
36
     *  
37
     * @see Prepaid::setFundsAccountType()
38
     * @uses Prepaid::isAccountType()
39
     * @param string $accountType
40
     * @throws \Exception On wrong account type
41
     */
42
    public function setPaymentsAccountType($accountType)
43
    {
44
        if(!$this->isAccountType($accountType)){
45
            throw new \Exception(sprintf('"%s" is not valid Account Type!', $accountType));
46
        }
47
        $this->set('extreport:prepaid/extreport:payment/extreport:accountType', $accountType);
48
    }
49
    
50
    /**
51
     * Set account type in conjunction with payments report.
52
     *
53
     * Use either this or setPaymentsAccountType. Never combine them in single frame.
54
     * 
55
     * Acceptable accountType:
56
     * <ul>
57
     *  <li>DOMAIN</li>
58
     *  <li>ENUM</li>
59
     * </ul>
60
     *
61
     * @see Prepaid::setPaymentsAccountType()
62
     * @uses Prepaid::isAccountType()
63
     * @param string $accountType
64
     * @throws \Exception On wrong account type
65
     */
66
    public function setFundsAccountType($accountType)
67
    {
68
        if(!$this->isAccountType($accountType)){
69
            throw new \Exception(sprintf('"%s" is not valid Account Type!', $accountType));
70
        }
71
        $this->set('extreport:prepaid/extreport:paymentFunds/extreport:accountType', $accountType);
72
    }
73
    
74
    
75
}
76
77