Completed
Push — master ( 1b5410...64fdd0 )
by Jean C.
28s
created

Escrow::initialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Moip\Resource;
4
5
use Requests;
6
use stdClass;
7
8
/**
9
 * Class Escrow.
10
 */
11
class Escrow extends MoipResource
12
{
13
    /**
14
     * @const string
15
     */
16
    const PATH = 'escrows';
17
18
    /**
19
     * Initializes new instances.
20
     */
21
    protected function initialize()
22
    {
23
        $this->data = new stdClass();
24
    }
25
26
    /**
27
     * Set id MoIP escrow.
28
     *
29
     *
30
     * @return \Moip\Resource\Escrow
31
     */
32
    public function setId($id)
33
    {
34
        $this->data->id = $id;
35
36
        return $this;
37
    }
38
39
    /**
40
     * Get id MoIP escrow.
41
     *
42
     *
43
     * @return \Moip\Resource\Escrow
44
     */
45
    public function getId()
46
    {
47
        return $this->getIfSet('id');
48
    }
49
50
    /**
51
     * Get escrow status.
52
     *
53
     * @return string Escrow status. Possible values HOLD_PENDING, HELD, RELEASED
54
     */
55
    public function getStatus()
56
    {
57
        return $this->getIfSet('status');
58
    }
59
60
    /**
61
     * get creation time.
62
     *
63
     * @return \DateTime
64
     */
65
    public function getCreatedAt()
66
    {
67
        return $this->data->createdAt;
68
    }
69
70
    /**
71
     * Returns when the last update occurred.
72
     *
73
     * @return \DateTime
74
     */
75
    public function getUpdatedAt()
76
    {
77
        return $this->data->updatedAt;
78
    }
79
80
    /**
81
     * Get escrow description.
82
     *
83
     * @return string Escrow description.
84
     */
85
    public function getDescription()
86
    {
87
        return $this->data->description;
88
    }
89
90
    /**
91
     * Release a escrow payment.
92
     *
93
     * @return Payment
94
     */
95 View Code Duplication
    public function release()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
96
    {
97
        $path = sprintf('/%s/%s/%s/%s', MoipResource::VERSION, self::PATH, $this->getId(), 'release');
98
99
        $response = $this->httpRequest($path, Requests::POST, []);
100
101
        return $this->populate($response);
102
    }
103
104
    /**
105
     * Mount escrow structure.
106
     *
107
     * @param \stdClass $response
108
     *
109
     * @return Escrow
110
     */
111
    protected function populate(stdClass $response)
112
    {
113
        $escrow = clone $this;
114
115
        $escrow->data->id = $this->getIfSet('id', $response);
116
        $escrow->data->status = $this->getIfSet('status', $response);
117
        $escrow->data->description = $this->getIfSet('description', $response);
118
        $escrow->data->amount = $this->getIfSet('amount', $response);
119
        $escrow->data->_links = $this->getIfSet('_links', $response);
120
        $escrow->data->createdAt = $this->getIfSetDateTime('createdAt', $response);
121
        $escrow->data->updatedAt = $this->getIfSetDateTime('updatedAt', $response);
122
123
        return $escrow;
124
    }
125
}
126