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
Pull Request — master (#21)
by
unknown
06:56
created

TwitterStatusUpdate::getImages()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace NotificationChannels\Twitter;
4
5
class TwitterStatusUpdate
6
{
7
    /** @var string */
8
    protected $content;
9
10
    /**
11
     * @var  array
12
     */
13
    private $images;
14
15
    /**
16
     * @var  array
17
     */
18
    public $imageIds;
19
20
    /**
21
     * @var  string
22
     */
23
    private $apiEndpoint = 'statuses/update';
24
25
    /*
26
     * @param  string $content
27
     */
28 7
    public function __construct($content)
29
    {
30 7
        $this->content = $content;
31 7
    }
32
33
    /**
34
     * Set Twitter media files.
35
     *
36
     * @return  $this
37
     */
38 2
    public function withImage(array $images){
39 2
        $this->images = collect($images);
0 ignored issues
show
Documentation Bug introduced by
It seems like collect($images) of type object<Illuminate\Support\Collection> is incompatible with the declared type array of property $images.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
40 2
        return $this;
41
    }
42
43
    /**
44
     * Get Twitter status update content.
45
     *
46
     * @return  string
47
     */
48 6
    public function getContent()
49
    {
50 6
        return $this->content;
51
    }
52
53
    /**
54
     * Get Twitter images list.
55
     *
56
     * @return  string
57
     */
58 5
    public function getImages()
59
    {
60 5
        return $this->images;
61
    }
62
63
    /**
64
     * Return Twitter status update api endpoint.
65
     * @return  string
66
     */
67 3
    public function getApiEndpoint()
68
    {
69 3
        return $this->apiEndpoint;
70
    }
71
72
    /**
73
     * Build Twitter request body.
74
     * @return  array
75
     */
76 4
    public function getRequestBody()
77
    {
78
        $body = [
79 4
            'status' => $this->getContent(),
80 4
        ];
81
82 4
        if ($this->imageIds) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->imageIds of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
83 2
            $body['media_ids'] = $this->imageIds->implode(',');
0 ignored issues
show
Bug introduced by
The method implode cannot be called on $this->imageIds (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
84 2
        }
85
86 4
        return $body;
87
    }
88
}
89