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 ( 88c884...6a0e80 )
by
unknown
10s
created

TwitterStatusUpdate::withImage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
ccs 1
cts 1
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
crap 1
1
<?php
2
3
namespace NotificationChannels\Twitter;
4
5
use NotificationChannels\Twitter\TwitterImage;
6
7
class TwitterStatusUpdate
8
{
9
    /** @var string */
10
    protected $content;
11
12
    /**
13
     * @var  array
14
     */
15
    private $images;
16
17
    /**
18
     * @var  array
19
     */
20
    public $imageIds;
21
22
    /**
23
     * @var  string
24
     */
25
    private $apiEndpoint = 'statuses/update';
26
27
    /*
28 7
     * @param  string $content
29
     */
30 7
    public function __construct($content)
31 7
    {
32 7
        $this->content = $content;
33
    }
34
35
    /**
36
     * Set Twitter media files.
37
     *
38
     * @param   array|string $images
39 6
     * @return  $this
40
     */
41 6
    public function withImage($images){
42
        collect($images)->each(function($image){
43
            $this->images[] = new TwitterImage($image);
44
        });
45
        return $this;
46
    }
47
48
    /**
49 5
     * Get Twitter status update content.
50
     *
51 5
     * @return  string
52
     */
53
    public function getContent()
54
    {
55
        return $this->content;
56
    }
57
58 3
    /**
59
     * Get Twitter images list.
60 3
     *
61
     * @return  string
62
     */
63
    public function getImages()
64
    {
65
        return $this->images;
66
    }
67 4
68
    /**
69
     * Return Twitter status update api endpoint.
70 4
     * @return  string
71 4
     */
72
    public function getApiEndpoint()
73 4
    {
74 2
        return $this->apiEndpoint;
75 2
    }
76
77 4
    /**
78
     * Build Twitter request body.
79
     * @return  array
80
     */
81
    public function getRequestBody()
82
    {
83
        $body = [
84
            'status' => $this->getContent(),
85
        ];
86
87
        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...
88
            $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...
89
        }
90
91
        return $body;
92
    }
93
}
94