Total Complexity | 7 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | class Acme |
||
8 | { |
||
9 | protected $client; |
||
10 | |||
11 | protected $resource = ''; |
||
12 | |||
13 | private function __construct(string $authToken) |
||
14 | { |
||
15 | $this->client = SDK::make('https://api.acme.com')->withAuthHeaders($authToken); |
||
16 | } |
||
17 | |||
18 | public static function create(string $authToken): self |
||
19 | { |
||
20 | return new self($authToken); |
||
21 | } |
||
22 | |||
23 | public function load(...$resources): self |
||
30 | } |
||
31 | |||
32 | public function __get(string $resource): self |
||
33 | { |
||
34 | $this->resource = $resource; |
||
35 | |||
36 | return $this; |
||
37 | } |
||
38 | |||
39 | public function get(): array |
||
40 | { |
||
41 | return json_decode($this->client->use($this->resource)->get()->getBody()->getContents()); |
||
42 | } |
||
43 | |||
44 | public function find($identifier) |
||
47 | } |
||
48 | } |
||
49 | |||
50 | // Create your SDK |
||
51 | $acme = Acme::create('1234-api-token-1234')->load('users', 'posts'. 'categories', 'likes'); |
||
67 |