-
Notifications
You must be signed in to change notification settings - Fork 2
/
Settings.php
144 lines (114 loc) · 3.51 KB
/
Settings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
declare(strict_types=1);
namespace RedditImage;
class Settings
{
private const DEFAULT_IMAGEHEIGHT = 70;
private const DEFAULT_MUTEDVIDEO = true;
private const DEFAULT_DISPLAYIMAGE = true;
private const DEFAULT_DISPLAYVIDEO = true;
private const DEFAULT_DISPLAYORIGINAL = true;
private const DEFAULT_DISPLAYMETADATA = false;
private const DEFAULT_DISPLAYTHUMBNAILS = false;
private const DEFAULT_REDDITDELAY = 1;
private string $processor = 'no';
/** @var array<string, string|int|bool> */
private array $settings;
/**
* @param array<string, string|int|bool> $settings
*/
public function __construct(array $settings)
{
$this->settings = $settings;
}
public function hasImgurClientId(): bool
{
return $this->getImgurClientId() !== '';
}
public function getImgurClientId(): string
{
if (array_key_exists('imgurClientId', $this->settings)) {
return (string) $this->settings['imgurClientId'];
}
return '';
}
public function hasFlickrApiKey(): bool
{
return $this->getFlickrApiKey() !== '';
}
public function getFlickrApiKey(): string
{
if (array_key_exists('flickrApiKey', $this->settings)) {
return (string) $this->settings['flickrApiKey'];
}
return '';
}
public function getDefaultImageHeight(): int
{
return self::DEFAULT_IMAGEHEIGHT;
}
public function getImageHeight(): int
{
if (array_key_exists('imageHeight', $this->settings)) {
return (int) $this->settings['imageHeight'];
}
return self::DEFAULT_IMAGEHEIGHT;
}
public function getMutedVideo(): bool
{
if (array_key_exists('mutedVideo', $this->settings)) {
return (bool) $this->settings['mutedVideo'];
}
return self::DEFAULT_MUTEDVIDEO;
}
public function getDisplayImage(): bool
{
if (array_key_exists('displayImage', $this->settings)) {
return (bool) $this->settings['displayImage'];
}
return self::DEFAULT_DISPLAYIMAGE;
}
public function getDisplayVideo(): bool
{
if (array_key_exists('displayVideo', $this->settings)) {
return (bool) $this->settings['displayVideo'];
}
return self::DEFAULT_DISPLAYVIDEO;
}
public function getDisplayOriginal(): bool
{
if (array_key_exists('displayOriginal', $this->settings)) {
return (bool) $this->settings['displayOriginal'];
}
return self::DEFAULT_DISPLAYORIGINAL;
}
public function getDisplayMetadata(): bool
{
if (array_key_exists('displayMetadata', $this->settings)) {
return (bool) $this->settings['displayMetadata'];
}
return self::DEFAULT_DISPLAYMETADATA;
}
public function getDisplayThumbnails(): bool
{
if (array_key_exists('displayThumbnails', $this->settings)) {
return (bool) $this->settings['displayThumbnails'];
}
return self::DEFAULT_DISPLAYTHUMBNAILS;
}
public function getRedditDelay(): int
{
if (array_key_exists('redditDelay', $this->settings)) {
return (int) $this->settings['redditDelay'];
}
return self::DEFAULT_REDDITDELAY;
}
public function getProcessor(): string
{
return $this->processor;
}
public function setProcessor(string $processor): void
{
$this->processor = $processor;
}
}