Completed
Pull Request — master (#2)
by Paulius
02:11 queued 41s
created

LabelsRequest::getCountry()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace DPD\Interconnector\Request;
4
5
use DPD\Interconnector\Authentication;
6
7
class LabelsRequest implements RequestInterface
8
{
9
    private $authentication;
10
11
    private $trackingNumbers = [];
12
13
    private $printInfo = [];
14
15
    public function __construct(Authentication $authentication, array $trackingNumbers, string $printType, string $printFormat)
16
    {
17
        $this->authentication = $authentication;
18
        $this->trackingNumbers = $trackingNumbers;
19
        $this->printInfo = [
20
            'type' => $printType,
21
            'format' => $printFormat
22
        ];
23
    }
24
25
    public function toArray(): array
26
    {
27
        return array_merge(
28
            $this->authentication->toArray(),
29
            ['parcels' => $this->getTrackingNumbers(), 'printType' => $this->printInfo['type'], 'printFormat' => $this->printInfo['format']]
30
        );
31
    }
32
33
    public function getTrackingNumbers(): string
34
    {
35
        return implode('|', $this->trackingNumbers);
36
    }
37
38
    public function getCountry(): string
39
    {
40
        $this->authentication->country;
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 string. 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...
41
    }
42
}