DummyAdapter::getCities()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
nc 1
nop 1
dl 0
loc 2
ccs 0
cts 1
cp 0
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace VasilDakov\Shipping\Adapter;
4
5
use VasilDakov\Shipping\Response;
6
7
class DummyAdapter implements AdapterInterface
8
{
9
    private const NAME = 'Econt';
10
11
    public function getName(): string
12
    {
13
        return self::NAME;
14
    }
15
16
    public function getCountries(): Response\GetCountriesResponse
17
    {
18
        // TODO: Implement getCountries() method.
19
    }
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 VasilDakov\Shipping\Response\GetCountriesResponse. 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...
20
21
    public function getCities(array $data)
22
    {
23
        // TODO: Implement getCities() method.
24
    }
0 ignored issues
show
Bug Best Practice introduced by
The expression ImplicitReturnNode returns the type null which is incompatible with the return type mandated by VasilDakov\Shipping\Adap...rInterface::getCities() of VasilDakov\Shipping\Response\GetCitiesResponse.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
25
26
    public function getOffices(array $data)
27
    {
28
        // TODO: Implement getOffices() method.
29
    }
0 ignored issues
show
Bug Best Practice introduced by
The expression ImplicitReturnNode returns the type null which is incompatible with the return type mandated by VasilDakov\Shipping\Adap...Interface::getOffices() of VasilDakov\Shipping\Response\GetOfficesResponse.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
30
31
    public function track(array $data)
32
    {
33
        // TODO: Implement track() method.
34
    }
35
}