1 | <?php |
||||
2 | /** |
||||
3 | * Created by PhpStorm. |
||||
4 | * User: sergio.rodenas |
||||
5 | * Date: 29/7/18 |
||||
6 | * Time: 18:43 |
||||
7 | */ |
||||
8 | |||||
9 | namespace Whisper\HetznerCloud\Clients; |
||||
10 | |||||
11 | use Zttp\PendingZttpRequest; |
||||
12 | |||||
13 | class HetznerCloud |
||||
14 | { |
||||
15 | public static $baseHost = "https://api.hetzner.cloud/v1/"; |
||||
16 | public static $authenticationToken; |
||||
17 | |||||
18 | private static $client; |
||||
19 | |||||
20 | public static function __callStatic($name, $arguments) |
||||
21 | { |
||||
22 | return (new static())->getClient()->{$name}(...$arguments)->json(); |
||||
23 | } |
||||
24 | |||||
25 | private function getClient(){ |
||||
26 | return (static::$client) ? static::$client : static::setClient(); |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() The method
Whisper\HetznerCloud\Cli...tznerCloud::setClient() is not static, but was called statically.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
27 | } |
||||
28 | |||||
29 | private function setClient(){ |
||||
30 | $client = (new PendingZttpRequest())->withHeaders([ |
||||
31 | 'Authorization' => 'Bearer '.static::$authenticationToken |
||||
32 | ]); |
||||
33 | |||||
34 | $client->options += [ |
||||
35 | 'base_uri' => static::$baseHost |
||||
36 | ]; |
||||
37 | |||||
38 | return static::$client = $client; |
||||
0 ignored issues
–
show
|
|||||
39 | } |
||||
40 | } |