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

ARBGetSubscriptionStatusResponse::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 ARBGetSubscriptionStatusResponse
7
 */
8
class ARBGetSubscriptionStatusResponse extends ANetApiResponseType
9
{
10
11
    /**
12
     * @property string $status
13
     */
14
    private $status = null;
15
16
    /**
17
     * Gets as status
18
     *
19
     * @return string
20
     */
21
    public function getStatus()
22
    {
23
        return $this->status;
24
    }
25
26
    /**
27
     * Sets a new status
28
     *
29
     * @param string $status
30
     * @return self
31
     */
32
    public function setStatus($status)
33
    {
34
        $this->status = $status;
35
        return $this;
36
    }
37
38
39
    // Json Set Code
40
    public function set($data)
41
    {
42
        if(is_array($data) || is_object($data)) {
43
			$mapper = \net\authorize\util\Mapper::Instance();
44
			foreach($data AS $key => $value) {
45
				$classDetails = $mapper->getClass(get_class() , $key);
46
	 
47
				if($classDetails !== NULL ) {
48
					if ($classDetails->isArray) {
49
						if ($classDetails->isCustomDefined) {
50
							foreach($value AS $keyChild => $valueChild) {
51
								$type = new $classDetails->className;
52
								$type->set($valueChild);
53
								$this->{'addTo' . $key}($type);
54
							}
55
						}
56
						else if ($classDetails->className === 'DateTime' || $classDetails->className === 'Date' ) {
57
							foreach($value AS $keyChild => $valueChild) {
58
								$type = new \DateTime($valueChild);
59
								$this->{'addTo' . $key}($type);
60
							}
61
						}
62
						else {
63
							foreach($value AS $keyChild => $valueChild) {
64
								$this->{'addTo' . $key}($valueChild);
65
							}
66
						}
67
					}
68
					else {
69
						if ($classDetails->isCustomDefined){
70
							$type = new $classDetails->className;
71
							$type->set($value);
72
							$this->{'set' . $key}($type);
73
						}
74
						else if ($classDetails->className === 'DateTime' || $classDetails->className === 'Date' ) {
75
							$type = new \DateTime($value);
76
							$this->{'set' . $key}($type);
77
						}
78
						else {
79
							$this->{'set' . $key}($value);
80
						}
81
					}
82
				}
83
			}
84
		}
85
    }
86
    
87
}
88
89