Completed
Pull Request — master (#52)
by
unknown
04:33 queued 01:58
created

Transfers::populate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
4
namespace Moip\Resource;
5
6
use Requests;
7
use stdClass;
8
9
class Transfers extends MoipResource
10
{
11
    /**
12
     * @const strign
13
     */
14
    const PATH = 'transfers';
15
16
    const METHOD = 'BANK_ACCOUNT';
17
18
    const TYPE = 'CHECKING';
19
20
    const TYPE_HOLD = 'CPF';
21
    /**
22
     * Initializes new instances.
23
     */
24
    protected function initialize()
25
    {
26
        $this->data = new stdClass();
27
    }
28
29
     protected function populate(stdClass $response)
30
    {
31
        $transfers = clone $this;
32
        
33
        return $transfers;
34
    }
35
36
    public function setTransfers($amount, $bankNumber, $agencyNumber, $agencyCheckNumber, $accountNumber, $accountCheckNumber) {
37
        $this->data->amount = $amount;
38
        $this->data->transferInstrument = new stdClass();
39
        $this->data->transferInstrument->method =  self::METHOD;
40
        $this->data->transferInstrument->bankAccount  = new stdClass();
41
        #$this->data->initialize();
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
42
        $this->data->transferInstrument->bankAccount->type = self::TYPE;
43
        $this->data->transferInstrument->bankAccount->bankNumber = $bankNumber;
44
        $this->data->transferInstrument->bankAccount->agencyNumber = $agencyNumber;
45
        $this->data->transferInstrument->bankAccount->agencyCheckNumber = $agencyCheckNumber;
46
        $this->data->transferInstrument->bankAccount->accountNumber = $accountNumber;
47
        $this->data->transferInstrument->bankAccount->accountCheckNumber = $accountCheckNumber;
48
        return $this; 
49
    }
50
51
    public function setHolder($fullname, $taxDocument){
52
53
        $this->data->transferInstrument->bankAccount->holder = new stdClass();
54
        $this->data->transferInstrument->bankAccount->holder->fullname = $fullname;
55
        $this->data->transferInstrument->bankAccount->holder->taxDocument = new stdClass();
56
        $this->data->transferInstrument->bankAccount->holder->taxDocument->type = self::TYPE_HOLD;
57
        $this->data->transferInstrument->bankAccount->holder->taxDocument->number = $taxDocument;
58
        return $this; 
59
    }
60
61
    public function execute()
62
    {
63
        
64
65
        $path = sprintf('/%s/%s', MoipResource::VERSION, self::PATH);
66
        
67
        $response = $this->httpRequest($path, Requests::POST, $this);
68
69
        return $this->populate($response);
70
    }
71
72
     /**
73
     * Get MoIP Transfers id.
74
     * 
75
     * @return strign
76
     */
77
    public function getId()
78
    {
79
        return $this->getIfSet('id');
80
    }
81
   
82
}
83