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 ( 3c5f28...9ed616 )
by
unknown
02:43
created

FacebookPosterPost::getPostBody()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 20
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 20
rs 9.2
c 1
b 0
f 0
cc 4
eloc 10
nc 8
nop 0
1
<?php
2
3
namespace NotificationChannels\FacebookPoster;
4
5
use NotificationChannels\FacebookPoster\Attachments\Link;
6
use NotificationChannels\FacebookPoster\Attachments\Image;
7
use NotificationChannels\FacebookPoster\Attachments\Video;
8
9
class FacebookPosterPost
10
{
11
    /** @var string */
12
    protected $content;
13
14
    /** @object FacebookPosterLink */
15
    protected $link;
16
17
    /** @object FacebookPosterImage */
18
    protected $image;
19
20
    /** @object FacebookPosterVideo */
21
    protected $video;
22
23
    /**
24
     * @var string
25
     */
26
    private $apiEndpoint = 'me/feed';
27
28
    public function __construct($postContent)
29
    {
30
        $this->content = $postContent;
31
    }
32
33
    /**
34
     * Get Post content.
35
     *
36
     * @return string
37
     */
38
    public function getContent()
39
    {
40
        return $this->content;
41
    }
42
43
    /**
44
     * Set facebook post main link.
45
     *
46
     * @param string $link
47
     *
48
     * @return $this
49
     */
50
    public function withLink($link)
51
    {
52
        $this->link = new Link($link);
53
54
        return $this;
55
    }
56
57
    /**
58
     * Set facebook post image.
59
     *
60
     * @param $imagePath
61
     * @param string $endpoint
62
     *
63
     * @return $this
64
     */
65
    public function withImage($imagePath, $endpoint = 'me/photos')
66
    {
67
        $this->image = new Image($imagePath, $endpoint);
68
69
        return $this;
70
    }
71
72
    /**
73
     * Set facebook post image.
74
     *
75
     * @param $videoPath
76
     * @param array  $data
77
     * @param string $endpoint
78
     *
79
     * @return $this
80
     */
81
    public function withVideo($videoPath, $data = [], $endpoint = 'me/videos')
82
    {
83
        $this->video = new video($videoPath, $endpoint);
84
85
        if (isset($data['title'])) {
86
            $this->video->setTitle($data['title']);
87
        }
88
89
        if (isset($data['description'])) {
90
            $this->video->setDescription($data['description']);
91
        }
92
93
        return $this;
94
    }
95
96
    /**
97
     * Return Facebook Post api endpoint.
98
     *
99
     * @return string
100
     */
101
    public function getApiEndpoint()
102
    {
103
        return $this->apiEndpoint;
104
    }
105
106
    /**
107
     * Build Facebook post request body.
108
     *
109
     * @return array
110
     */
111
    public function getPostBody()
112
    {
113
        $body = [
114
            'message' => $this->getContent(),
115
        ];
116
117
        if ($this->link != null) {
118
            $body['link'] = $this->link->getUrl();
119
        }
120
121
        if ($this->image != null) {
122
            $body['media'] = $this->image;
123
        }
124
125
        if ($this->video != null) {
126
            $body['media'] = $this->video;
127
        }
128
129
        return $body;
130
    }
131
}
132