1 | <?php |
||
11 | class FacebookPosterPost |
||
12 | { |
||
13 | /** |
||
14 | * The post message. |
||
15 | * |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $message; |
||
19 | |||
20 | /** |
||
21 | * The post link. |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $link; |
||
26 | |||
27 | /** |
||
28 | * The post image. |
||
29 | * |
||
30 | * @var \NotificationChannels\FacebookPoster\Attachments\Image |
||
31 | */ |
||
32 | protected $image; |
||
33 | |||
34 | /** |
||
35 | * The post video. |
||
36 | * |
||
37 | * @var \NotificationChannels\FacebookPoster\Attachments\Video |
||
38 | */ |
||
39 | protected $video; |
||
40 | |||
41 | /** |
||
42 | * Additional post parameters. |
||
43 | * |
||
44 | * @var array |
||
45 | */ |
||
46 | protected $params; |
||
47 | |||
48 | /** |
||
49 | * The post API endpoint. |
||
50 | * |
||
51 | * @var string |
||
52 | */ |
||
53 | protected $apiEndpoint = 'me/feed'; |
||
54 | |||
55 | /** |
||
56 | * Create a new post instance. |
||
57 | * |
||
58 | * @param string $message |
||
59 | * @return void |
||
|
|||
60 | */ |
||
61 | 7 | public function __construct($message) |
|
62 | { |
||
63 | 7 | $this->message = $message; |
|
64 | 7 | } |
|
65 | |||
66 | /** |
||
67 | * Get post message. |
||
68 | * |
||
69 | * @return string |
||
70 | */ |
||
71 | 7 | public function getMessage() |
|
72 | { |
||
73 | 7 | return $this->message; |
|
74 | } |
||
75 | |||
76 | /** |
||
77 | * Set facebook post main link. |
||
78 | * |
||
79 | * @param string $link |
||
80 | * |
||
81 | * @return $this |
||
82 | */ |
||
83 | 1 | public function withLink($link) |
|
84 | { |
||
85 | 1 | $this->link = $link; |
|
86 | |||
87 | 1 | return $this; |
|
88 | } |
||
89 | |||
90 | /** |
||
91 | * Set a post image. |
||
92 | * |
||
93 | * @param string $path |
||
94 | * @param string $endpoint |
||
95 | * @return $this |
||
96 | */ |
||
97 | 1 | public function withImage($path, $endpoint = 'me/photos') |
|
103 | |||
104 | /** |
||
105 | * Set a post video. |
||
106 | * |
||
107 | * @param string $path |
||
108 | * @param string $title |
||
109 | * @param string $description |
||
110 | * @param string $endpoint |
||
111 | * @return $this |
||
112 | */ |
||
113 | 1 | public function withVideo($path, $title = null, $description = null, $endpoint = 'me/videos') |
|
119 | |||
120 | /** |
||
121 | * Schedule the post for a date in the future. |
||
122 | * |
||
123 | * @param \DateTimeInterface|int $timestamp |
||
124 | * @return $this |
||
125 | */ |
||
126 | 3 | public function scheduledFor($timestamp) |
|
137 | |||
138 | /** |
||
139 | * Return Facebook Post api endpoint. |
||
140 | * |
||
141 | * @return string |
||
142 | */ |
||
143 | 4 | public function getApiEndpoint() |
|
147 | |||
148 | /** |
||
149 | * Build Facebook post request body. |
||
150 | * |
||
151 | * @return array |
||
152 | */ |
||
153 | 7 | public function getPostBody() |
|
179 | |||
180 | /** |
||
181 | * Validate that there is acceptable post content. |
||
182 | * |
||
183 | * @throws \NotificationChannels\FacebookPoster\Exceptions\InvalidPostContent |
||
184 | */ |
||
185 | 7 | protected function validate() |
|
193 | } |
||
194 |
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.