GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 418d78...2b27f2 )
by Sho
7s
created

Tracks::getTrackingStatus()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace ShippoClient\Entity;
4
5
use TurmericSpice\ReadableAttributes;
6
7
class Tracks
8
{
9
    use ReadableAttributes {
10
        mayHaveAsString as public getCarrier;
11
        mayHaveAsString as public getTrackingNumber;
12
        mayHaveAsString as public getEta;
13
        toArray as public __toArray;
14
    }
15
16
    /**
17
     * @return \ShippoClient\Entity\TrackingStatus
18
     */
19
    public function getTrackingStatus()
20
    {
21
        return new TrackingStatus($this->attributes->mayHave('tracking_status')->asArray());
0 ignored issues
show
Bug introduced by
The property attributes does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
22
    }
23
24
    /**
25
     * @return \ShippoClient\Entity\TrackingHistory
26
     */
27
    public function getTrackingHistory()
28
    {
29
        $entities = $this->attributes->mayHave('tracking_history')
30
            ->asInstanceArray('ShippoClient\\Entity\\TrackingStatus');
31
32
        return new TrackingHistory($entities);
33
    }
34
35
    /**
36
     * @return \ShippoClient\Entity\Location
37
     */
38
    public function getAddressFrom()
39
    {
40
        $addressFrom = $this->attributes->mayHave('address_from')->asArray();
41
42
        return new Location($addressFrom);
43
    }
44
45
    /**
46
     * @return \ShippoClient\Entity\Location
47
     */
48
    public function getAddressTo()
49
    {
50
        $addressTo = $this->attributes->mayHave('address_to')->asArray();
51
52
        return new Location($addressTo);
53
    }
54
55
    /**
56
     * @return \ShippoClient\Entity\ServiceLevel
57
     */
58
    public function getServiceLevel()
59
    {
60
        $serviceLevel = $this->attributes->mayHave('servicelevel')->asArray();
61
62
        return new ServiceLevel($serviceLevel);
63
    }
64
65
    public function toArray()
66
    {
67
        return [
68
            'carrier'          => $this->getCarrier(),
0 ignored issues
show
Bug introduced by
The method getCarrier() does not seem to exist on object<ShippoClient\Entity\Tracks>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
69
            'tracking_number'  => $this->getTrackingNumber(),
0 ignored issues
show
Bug introduced by
The method getTrackingNumber() does not seem to exist on object<ShippoClient\Entity\Tracks>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
70
            'tracking_status'  => $this->getTrackingStatus()->toArray(),
71
            'tracking_history' => $this->getTrackingHistory()->toArray(),
72
            'eta'              => $this->getEta(),
73
            'address_from'     => $this->getAddressFrom()->toArray(),
74
            'address_to'       => $this->getAddressTo()->toArray(),
75
            'servicelevel'     => $this->getServiceLevel()->toArray(),
76
        ];
77
    }
78
}
79