Completed
Pull Request — master (#133)
by
unknown
01:47
created

Escrow::getStatus()   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
    /**
15
     * @const string
16
     */
17
    const PATH = 'escrows';
18
19
    /**
20
     * Initializes new instances.
21
     */
22
    protected function initialize()
23
    {
24
        $this->data = new stdClass();
25
    }
26
27
    /**
28
     * Set id MoIP escrow.
29
     *
30
     *
31
     * @return \Moip\Resource\Escrow
32
     */
33
    public function setId($id)
34
    {
35
        $this->data->id = $id;
36
37
        return $this;
38
    }
39
40
    /**
41
     * Get id MoIP escrow.
42
     *
43
     *
44
     * @return \Moip\Resource\Escrow
45
     */
46
    public function getId()
47
    {
48
        return $this->getIfSet('id');
49
    }
50
51
    /**
52
     * Get escrow status.
53
     *
54
     * @return string Escrow status. Possible values HOLD_PENDING, HELD, RELEASED
55
     */
56
    public function getStatus()
57
    {
58
        return $this->getIfSet('status');
59
    }
60
61
    /**
62
     * get creation time.
63
     *
64
     * @return \DateTime
65
     */
66
    public function getCreatedAt()
67
    {
68
        return $this->data->createdAt;
69
    }
70
71
    /**
72
     * Returns when the last update occurred.
73
     *
74
     * @return \DateTime
75
     */
76
    public function getUpdatedAt()
77
    {
78
        return $this->data->updatedAt;
79
    }
80
81
    /**
82
     * Get escrow description
83
     *
84
     * @return string Escrow description.
85
     */
86
    public function getDescription()
87
    {
88
        return $this->data->description;
89
    }
90
91
    /**
92
     * Release a escrow payment.
93
     *
94
     * @return Payment
95
     */
96 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...
97
    {
98
        $path = sprintf('/%s/%s/%s/%s', MoipResource::VERSION, self::PATH, $this->getId(), 'release');
99
100
        $response = $this->httpRequest($path, Requests::POST, []);
101
102
        return $this->populate($response);
103
    }
104
105
    /**
106
     * Mount escrow structure.
107
     *
108
     * @param \stdClass $response
109
     *
110
     * @return Escrow
111
     */
112
    protected function populate(stdClass $response)
113
    {
114
        $escrow = clone $this;
115
116
        $escrow->data->id = $this->getIfSet('id', $response);
117
        $escrow->data->status = $this->getIfSet('status', $response);
118
        $escrow->data->description = $this->getIfSet('description', $response);
119
        $escrow->data->amount = $this->getIfSet('amount', $response);
120
        $escrow->data->_links = $this->getIfSet('_links', $response);
121
        $escrow->data->createdAt = $this->getIfSetDateTime('createdAt', $response);
122
        $escrow->data->updatedAt = $this->getIfSetDateTime('updatedAt', $response);
123
124
        return $escrow;
125
    }
126
}
127