GetCustomerPaymentProfileListResponse::set()   C
last analyzed

Complexity

Conditions 15
Paths 9

Size

Total Lines 46

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 240

Importance

Changes 0
Metric Value
dl 0
loc 46
ccs 0
cts 0
cp 0
rs 5.9166
c 0
b 0
f 0
cc 15
nc 9
nop 1
crap 240

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace net\authorize\api\contract\v1;
4
5
/**
6
 * Class representing GetCustomerPaymentProfileListResponse
7
 */
8
class GetCustomerPaymentProfileListResponse extends ANetApiResponseType
9
{
10
11
    /**
12
     * @property integer $totalNumInResultSet
13
     */
14
    private $totalNumInResultSet = null;
15
16
    /**
17
     * @property \net\authorize\api\contract\v1\CustomerPaymentProfileListItemType[]
18
     * $paymentProfiles
19
     */
20
    private $paymentProfiles = null;
21
22
    /**
23
     * Gets as totalNumInResultSet
24
     *
25
     * @return integer
26
     */
27
    public function getTotalNumInResultSet()
28
    {
29
        return $this->totalNumInResultSet;
30
    }
31
32
    /**
33
     * Sets a new totalNumInResultSet
34
     *
35
     * @param integer $totalNumInResultSet
36
     * @return self
37
     */
38 1
    public function setTotalNumInResultSet($totalNumInResultSet)
39
    {
40 1
        $this->totalNumInResultSet = $totalNumInResultSet;
41 1
        return $this;
42
    }
43
44
    /**
45
     * Adds as paymentProfile
46
     *
47
     * @return self
48
     * @param \net\authorize\api\contract\v1\CustomerPaymentProfileListItemType
49
     * $paymentProfile
50
     */
51
    public function addToPaymentProfiles(\net\authorize\api\contract\v1\CustomerPaymentProfileListItemType $paymentProfile)
52
    {
53
        $this->paymentProfiles[] = $paymentProfile;
54
        return $this;
55
    }
56
57
    /**
58
     * isset paymentProfiles
59
     *
60
     * @param scalar $index
61
     * @return boolean
62
     */
63
    public function issetPaymentProfiles($index)
64
    {
65
        return isset($this->paymentProfiles[$index]);
66
    }
67
68
    /**
69
     * unset paymentProfiles
70
     *
71
     * @param scalar $index
72
     * @return void
73
     */
74
    public function unsetPaymentProfiles($index)
75
    {
76
        unset($this->paymentProfiles[$index]);
77
    }
78
79
    /**
80
     * Gets as paymentProfiles
81
     *
82
     * @return \net\authorize\api\contract\v1\CustomerPaymentProfileListItemType[]
83
     */
84
    public function getPaymentProfiles()
85
    {
86
        return $this->paymentProfiles;
87
    }
88
89
    /**
90
     * Sets a new paymentProfiles
91
     *
92
     * @param \net\authorize\api\contract\v1\CustomerPaymentProfileListItemType[]
93
     * $paymentProfiles
94
     * @return self
95
     */
96
    public function setPaymentProfiles(array $paymentProfiles)
97
    {
98
        $this->paymentProfiles = $paymentProfiles;
99
        return $this;
100
    }
101
102
103
    // Json Set Code
104
    public function set($data)
105
    {
106
        if(is_array($data) || is_object($data)) {
107
			$mapper = \net\authorize\util\Mapper::Instance();
108
			foreach($data AS $key => $value) {
109
				$classDetails = $mapper->getClass(get_class() , $key);
110
	 
111
				if($classDetails !== NULL ) {
112
					if ($classDetails->isArray) {
113
						if ($classDetails->isCustomDefined) {
114
							foreach($value AS $keyChild => $valueChild) {
115
								$type = new $classDetails->className;
116
								$type->set($valueChild);
117
								$this->{'addTo' . $key}($type);
118
							}
119
						}
120
						else if ($classDetails->className === 'DateTime' || $classDetails->className === 'Date' ) {
121
							foreach($value AS $keyChild => $valueChild) {
122
								$type = new \DateTime($valueChild);
123
								$this->{'addTo' . $key}($type);
124
							}
125
						}
126
						else {
127
							foreach($value AS $keyChild => $valueChild) {
128
								$this->{'addTo' . $key}($valueChild);
129
							}
130
						}
131
					}
132
					else {
133
						if ($classDetails->isCustomDefined){
134
							$type = new $classDetails->className;
135
							$type->set($value);
136
							$this->{'set' . $key}($type);
137
						}
138
						else if ($classDetails->className === 'DateTime' || $classDetails->className === 'Date' ) {
139
							$type = new \DateTime($value);
140
							$this->{'set' . $key}($type);
141
						}
142
						else {
143
							$this->{'set' . $key}($value);
144
						}
145
					}
146
				}
147
			}
148
		}
149
    }
150
    
151
}
152
153