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

Prepaid   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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