1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace FondBot\Templates; |
6
|
|
|
|
7
|
|
|
use Illuminate\Support\Collection; |
8
|
|
|
|
9
|
|
|
class Attachment |
10
|
|
|
{ |
11
|
|
|
public const TYPE_FILE = 'file'; |
12
|
|
|
public const TYPE_IMAGE = 'image'; |
13
|
|
|
public const TYPE_AUDIO = 'audio'; |
14
|
|
|
public const TYPE_VIDEO = 'video'; |
15
|
|
|
|
16
|
|
|
private $type; |
17
|
|
|
private $path; |
18
|
|
|
private $parameters; |
19
|
|
|
|
20
|
13 |
|
public function __construct(string $type, string $path, array $parameters = []) |
21
|
|
|
{ |
22
|
13 |
|
$this->type = $type; |
23
|
13 |
|
$this->path = $path; |
24
|
13 |
|
$this->parameters = collect($parameters); |
25
|
13 |
|
} |
26
|
|
|
|
27
|
13 |
|
public static function make(string $type, string $path, array $parameters = []) |
28
|
|
|
{ |
29
|
13 |
|
return new static($type, $path, $parameters); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public static function file(string $path, array $parameters = []) |
33
|
|
|
{ |
34
|
|
|
return new static(self::TYPE_FILE, $path, $parameters); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public static function image(string $path, array $parameters = []) |
38
|
|
|
{ |
39
|
|
|
return new static(self::TYPE_IMAGE, $path, $parameters); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public static function audio(string $path, array $parameters = []) |
43
|
|
|
{ |
44
|
|
|
return new static(self::TYPE_AUDIO, $path, $parameters); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public static function video(string $path, array $parameters = []) |
48
|
|
|
{ |
49
|
|
|
return new static(self::TYPE_VIDEO, $path, $parameters); |
50
|
|
|
} |
51
|
|
|
|
52
|
12 |
|
public function getType(): string |
53
|
|
|
{ |
54
|
12 |
|
return $this->type; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function setType(string $type): Attachment |
58
|
|
|
{ |
59
|
|
|
$this->type = $type; |
60
|
|
|
|
61
|
|
|
return $this; |
62
|
|
|
} |
63
|
|
|
|
64
|
4 |
|
public function getPath(): string |
65
|
|
|
{ |
66
|
4 |
|
return $this->path; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function setPath(string $path): Attachment |
70
|
|
|
{ |
71
|
|
|
$this->path = $path; |
72
|
|
|
|
73
|
|
|
return $this; |
74
|
|
|
} |
75
|
|
|
|
76
|
4 |
|
public function getParameters(): Collection |
77
|
|
|
{ |
78
|
4 |
|
return $this->parameters; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function setParameters(array $parameters): Attachment |
82
|
|
|
{ |
83
|
|
|
$this->parameters = collect($parameters); |
84
|
|
|
|
85
|
|
|
return $this; |
86
|
|
|
} |
87
|
|
|
|
88
|
5 |
|
public static function possibleTypes(): array |
89
|
|
|
{ |
90
|
|
|
return [ |
91
|
5 |
|
static::TYPE_FILE, |
92
|
5 |
|
static::TYPE_IMAGE, |
93
|
5 |
|
static::TYPE_AUDIO, |
94
|
5 |
|
static::TYPE_VIDEO, |
95
|
|
|
]; |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|