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

ARBGetSubscriptionResponse   A

Complexity

Total Complexity 17

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 17
lcom 1
cbo 2
dl 0
loc 80
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscription() 0 4 1
A setSubscription() 0 5 1
C set() 0 46 15
1
<?php
2
3
namespace net\authorize\api\contract\v1;
4
5
/**
6
 * Class representing ARBGetSubscriptionResponse
7
 */
8
class ARBGetSubscriptionResponse extends ANetApiResponseType
9
{
10
11
    /**
12
     * @property \net\authorize\api\contract\v1\ARBSubscriptionMaskedType $subscription
13
     */
14
    private $subscription = null;
15
16
    /**
17
     * Gets as subscription
18
     *
19
     * @return \net\authorize\api\contract\v1\ARBSubscriptionMaskedType
20
     */
21
    public function getSubscription()
22
    {
23
        return $this->subscription;
24
    }
25
26
    /**
27
     * Sets a new subscription
28
     *
29
     * @param \net\authorize\api\contract\v1\ARBSubscriptionMaskedType $subscription
30
     * @return self
31
     */
32 1
    public function setSubscription(\net\authorize\api\contract\v1\ARBSubscriptionMaskedType $subscription)
33
    {
34 1
        $this->subscription = $subscription;
35 1
        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