|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Baguette\Mastodon\Entity; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Attachment |
|
7
|
|
|
* |
|
8
|
|
|
* @author USAMI Kenta <[email protected]> |
|
9
|
|
|
* @copyright 2017 Baguette HQ |
|
10
|
|
|
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL-3.0 |
|
11
|
|
|
* @see https://github.com/tootsuite/documentation/blob/master/Using-the-API/API.md#attachment |
|
12
|
|
|
* @property-read int $id ID of the attachment |
|
13
|
|
|
* @property-read string $type One of: "image", "video", "gifv" |
|
14
|
|
|
* @property-read string $url URL of the locally hosted version of the image |
|
15
|
|
|
* @property-read string $remote_url For remote images, the remote URL of the original image |
|
16
|
|
|
* @property-read string $preview_url URL of the preview image |
|
17
|
|
|
* @property-read string $text_url Shorter URL for the image, for insertion into text (only present on local images) |
|
18
|
|
|
*/ |
|
19
|
|
|
class Attachment extends Entity |
|
20
|
|
|
{ |
|
21
|
|
|
use \Teto\Object\TypedProperty; |
|
22
|
|
|
|
|
23
|
|
|
private static $property_types = [ |
|
|
|
|
|
|
24
|
|
|
'id' => 'int', |
|
25
|
|
|
'type' => 'enum', |
|
26
|
|
|
'url' => 'string', |
|
27
|
|
|
'remote_url' => 'string', |
|
28
|
|
|
'preview_url' => 'string', |
|
29
|
|
|
'text_url' => 'string', |
|
30
|
|
|
]; |
|
31
|
|
|
|
|
32
|
|
|
private static $enum_values = [ |
|
|
|
|
|
|
33
|
|
|
'type' => ['image', 'video', 'gifv'], |
|
34
|
|
|
]; |
|
35
|
|
|
|
|
36
|
2 |
|
public function __construct(array $properties) |
|
37
|
|
|
{ |
|
38
|
2 |
|
$this->setProperties($properties); |
|
39
|
2 |
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Returns attachment data as array |
|
43
|
|
|
* |
|
44
|
|
|
* @return array |
|
45
|
|
|
*/ |
|
46
|
3 |
|
public function toArray() |
|
47
|
|
|
{ |
|
48
|
|
|
return [ |
|
49
|
3 |
|
'id' => $this->id, |
|
50
|
3 |
|
'type' => $this->type, |
|
51
|
3 |
|
'url' => $this->url, |
|
52
|
3 |
|
'remote_url' => $this->remote_url, |
|
53
|
3 |
|
'preview_url' => $this->preview_url, |
|
54
|
3 |
|
'text_url' => $this->text_url, |
|
55
|
|
|
]; |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|
This check marks private properties in classes that are never used. Those properties can be removed.