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 ( d2378f...d01cde )
by Sho
02:24
created

TrackingStatus::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 1 Features 1
Metric Value
c 4
b 1
f 1
dl 0
loc 12
rs 9.4285
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
namespace ShippoClient\Entity;
4
5
use TurmericSpice\ReadableAttributes;
6
7
class TrackingStatus
8
{
9
    use ReadableAttributes {
10
        mayHaveAsString as public getStatusDetails;
11
        mayHaveAsString as public getStatusDate;
12
        toArray as __toArray;
13
    }
14
15
    /**
16
     * Date and time of object creation.
17
     *
18
     * @return \DateTime
19
     */
20
    public function getObjectCreated()
21
    {
22
        return $this->attributes->mayHave('object_created')->asInstanceOf('\\DateTime');
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...
23
    }
24
25
    /**
26
     * Date and time of last object update.
27
     *
28
     * @return \DateTime
29
     */
30
    public function getObjectUpdated()
31
    {
32
        return $this->attributes->mayHave('object_updated')->asInstanceOf('\\DateTime');
33
    }
34
35
    /**
36
     * Unique identifier of the given object.
37
     *
38
     * @return string
39
     */
40
    public function getObjectId()
41
    {
42
        return $this->attributes->mayHave('object_id')->asString();
43
    }
44
45
    /**
46
     * Package status.
47
     *  - "UNKNOWN"   The package has not been found via the carrier's tracking system,
48
     *                or it has been found but not yet scanned by the carrier.
49
     *  - "TRANSIT"   The package has been scanned by the carrier and is in transit.
50
     *  - "DELIVERED" The package has been successfully delivered.
51
     *  - "RETURNED"  The package is en route to be returned to the sender, or has been returned successfully.
52
     *  - "FAILURE"   The carrier indicated that there has been an issue with the delivery.
53
     *                This can happen for various reasons and depends on the carrier.
54
     *                This status does not indicate a technical error, but rather a delivery issue.
55
     *
56
     * @return string
57
     */
58
    public function getStatus()
59
    {
60
        return $this->attributes->mayHave('status')->asString();
61
    }
62
63
    /**
64
     * @return Location
65
     */
66
    public function getLocation()
67
    {
68
        $attributes = $this->attributes->mayHave('location')->asArray();
69
        return new Location($attributes);
70
    }
71
72
    public function toArray()
73
    {
74
        return [
75
            'object_created' => $this->getObjectCreated(),
76
            'object_updated' => $this->getObjectUpdated(),
77
            'object_id'      => $this->getObjectId(),
78
            'status'         => $this->getStatus(),
79
            'status_date'    => $this->getStatusDate(),
80
            'status_details' => $this->getStatusDetails(),
0 ignored issues
show
Bug introduced by
The method getStatusDetails() does not exist on ShippoClient\Entity\TrackingStatus. Did you maybe mean getStatus()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
81
            'location'       => $this->getLocation()->toArray(),
82
        ];
83
    }
84
}
85