Completed
Push — master ( 9ebe33 )
by Kaushik
28:24
created

GetCustomerProfileResponse::set()   C

Complexity

Conditions 15
Paths 9

Size

Total Lines 46

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 46
rs 5.9166
c 0
b 0
f 0
cc 15
nc 9
nop 1

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