1 | <?php |
||
10 | class FacebookPosterPost |
||
11 | { |
||
12 | /** |
||
13 | * The post message. |
||
14 | * |
||
15 | * @var string |
||
16 | */ |
||
17 | protected $message; |
||
18 | |||
19 | /** |
||
20 | * The post link. |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | protected $link; |
||
25 | |||
26 | /** |
||
27 | * The post media. |
||
28 | * |
||
29 | * @var \NotificationChannels\FacebookPoster\Attachments\Attachment |
||
30 | */ |
||
31 | protected $media; |
||
32 | |||
33 | /** |
||
34 | * Additional post parameters. |
||
35 | * |
||
36 | * @var array |
||
37 | */ |
||
38 | protected $params; |
||
39 | |||
40 | /** |
||
41 | * The post API endpoint. |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | protected $endpoint = 'me/feed'; |
||
46 | |||
47 | /** |
||
48 | * Create a new post instance. |
||
49 | * |
||
50 | * @param string $message |
||
51 | * @return void |
||
|
|||
52 | */ |
||
53 | 7 | public function __construct($message) |
|
57 | |||
58 | /** |
||
59 | * Get the post message. |
||
60 | * |
||
61 | * @return string |
||
62 | */ |
||
63 | 7 | public function getMessage() |
|
67 | |||
68 | /** |
||
69 | * Set a post link. |
||
70 | * |
||
71 | * @param string $link |
||
72 | * |
||
73 | * @return $this |
||
74 | */ |
||
75 | 1 | public function withLink($link) |
|
81 | |||
82 | /** |
||
83 | * Set a post image. |
||
84 | * |
||
85 | * @param string $path |
||
86 | * @param string $endpoint |
||
87 | * @return $this |
||
88 | */ |
||
89 | 1 | public function withImage($path, $endpoint = 'me/photos') |
|
96 | |||
97 | /** |
||
98 | * Set a post video. |
||
99 | * |
||
100 | * @param string $path |
||
101 | * @param string $title |
||
102 | * @param string $description |
||
103 | * @param string $endpoint |
||
104 | * @return $this |
||
105 | */ |
||
106 | 1 | public function withVideo($path, $title = null, $description = null, $endpoint = 'me/videos') |
|
115 | |||
116 | /** |
||
117 | * Schedule the post for a date in the future. |
||
118 | * |
||
119 | * @param \DateTimeInterface|int $timestamp |
||
120 | * @return $this |
||
121 | */ |
||
122 | 3 | public function scheduledFor($timestamp) |
|
133 | |||
134 | /** |
||
135 | * Return Facebook API endpoint. |
||
136 | * |
||
137 | * @return string |
||
138 | */ |
||
139 | 4 | public function getEndpoint() |
|
143 | |||
144 | /** |
||
145 | * Get the media attached to the post. |
||
146 | * |
||
147 | * @return \NotificationChannels\FacebookPoster\Attachment |
||
148 | */ |
||
149 | 4 | public function getMedia() |
|
153 | |||
154 | /** |
||
155 | * Build Facebook post request body. |
||
156 | * |
||
157 | * @return array |
||
158 | */ |
||
159 | 7 | public function getBody() |
|
177 | |||
178 | /** |
||
179 | * Validate that there is acceptable post content. |
||
180 | * |
||
181 | * @throws \NotificationChannels\FacebookPoster\Exceptions\InvalidPostContent |
||
182 | */ |
||
183 | 7 | protected function validate() |
|
191 | } |
||
192 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.