Passed
Push — master ( 6ef306...d2de8d )
by Bence
04:24
created

Manager::GetContainer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 1
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 1
dl 0
loc 1
rs 10
c 0
b 0
f 0
ccs 0
cts 1
cp 0
crap 2
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 2
    public function ListContainers() : array {
13 2
        $request = Request::get("https://api.csfcloud.com/container?key=" . urlencode($this->keymanager->GetServerKey()))->expectsText()->send();
0 ignored issues
show
Bug introduced by
The method expectsText() does not exist on Httpful\Request. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

13
        $request = Request::get("https://api.csfcloud.com/container?key=" . urlencode($this->keymanager->GetServerKey()))->/** @scrutinizer ignore-call */ expectsText()->send();
Loading history...
14 2
        $cntlist = json_decode($request->body, true);
15 2
        return $cntlist;
16
    }
17
18
    public function GetContainer(string $id) : Container {
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

18
    public function GetContainer(/** @scrutinizer ignore-unused */ string $id) : Container {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
19
20
    }
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return CSFCloud\Containers\Container. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
21
22
}