Manager   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 81.82%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 17
ccs 9
cts 11
cp 0.8182
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A GetContainer() 0 2 1
A ListContainers() 0 5 1
A NewContainer() 0 4 1
1
<?php
2
3
namespace CSFCloud\Containers;
4
5
use CSFCloud\KeyManager;
6
use CSFCloud\Resource;
7
use CSFCloud\Containers\Container;
8
use Httpful\Request;
9
10
class Manager extends Resource {
11
12 4
    public function ListContainers () : array {
13 4
        $request = Request::get("https://api.csfcloud.com/container?key=" . urlencode($this->keymanager->GetServerKey()))
14 4
            ->expectsText()->send();
15 4
        $cntlist = json_decode($request->body, true);
16 4
        return $cntlist;
17
    }
18
19
    public function GetContainer (string $id) : Container {
20
        return new Container($this->keymanager, $id);
21
    }
22
23 2
    public function NewContainer (string $template = '') : Container {
24 2
        $response = Request::post("https://api.csfcloud.com/container?key=" . urlencode($this->keymanager->GetServerKey()))
25 2
            ->sendsJson()->expectsJson()->body(json_encode(["template"=>$template]))->send();
26 2
        return new Container($this->keymanager, $response->body->id);
27
    }
28
29
}