Completed
Push — master ( 6e1d34...22a8c1 )
by Jean C.
02:15
created

src/Moip.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Artesaos\Moip;
4
5
use Illuminate\Contracts\Foundation\Application;
6
use Moip\Moip as Api;
7
use Moip\MoipBasicAuth;
8
9
class Moip
10
{
11
    /**
12
     * The Laravel Application.
13
     *
14
     * @var \Illuminate\Contracts\Foundation\Application
15
     **/
16
    private $app;
17
18
    /**
19
     * Class Moip sdk.
20
     *
21
     * @var \Moip\Moip
22
     **/
23
    private $moip;
24
25
    /**
26
     * Class constructor.
27
     * 
28
     * @param \Illuminate\Contracts\Foundation\Application $app The Laravel Application.
29
     */
30
    public function __construct(Application $app)
31
    {
32
        $this->app = $app;
33
    }
34
35
    /**
36
     * Start Moip sdk.
37
     */
38
    public function start()
39
    {
40
        $this->moip = $this->app->make(Api::class, [$this->app->make(MoipBasicAuth::class, [config('moip.credentials.token'), config('moip.credentials.key')]), $this->getHomologated()]);
41
42
        return $this;
43
    }
44
45
    /**
46
     * Create a new Customer instance.
47
     *
48
     * @return \Moip\Resource\Customer
49
     */
50
    public function customers()
51
    {
52
        return $this->moip->customers();
53
    }
54
55
    /**
56
     * Create a new Account instance.
57
     *
58
     * @return \Moip\Resource\Account
59
     */
60
    public function accounts()
61
    {
62
        return $this->moip->accounts();
0 ignored issues
show
The method accounts() does not seem to exist on object<Moip\Moip>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
63
    }
64
65
    /**
66
     * Create a new Entry instance.
67
     *
68
     * @return \Moip\Resource\Entry
69
     */
70
    public function entries()
71
    {
72
        return $this->moip->entries();
73
    }
74
75
    /**
76
     * Create a new Order instance.
77
     *
78
     * @return \Moip\Resource\Orders
79
     */
80
    public function orders()
81
    {
82
        return $this->moip->orders();
83
    }
84
85
    /**
86
     * Create a new Payment instance.
87
     *
88
     * @return \Moip\Resource\Payment
89
     */
90
    public function payments()
91
    {
92
        return $this->moip->payments();
93
    }
94
95
    /**
96
     * Create a new Multiorders instance.
97
     *
98
     * @return \Moip\Resource\Multiorders
99
     */
100
    public function multiorders()
101
    {
102
        return $this->moip->multiorders();
103
    }
104
105
    /**
106
     * Get endpoint of request.
107
     * 
108
     * @return \Moip\Moip::ENDPOINT_PRODUCTION|\Moip\Moip::ENDPOINT_SANDBOX
109
     */
110
    private function getHomologated()
111
    {
112
        return config('moip.homologated') === true ? Api::ENDPOINT_PRODUCTION : Api::ENDPOINT_SANDBOX;
113
    }
114
}
115