forked from Victrid/freshrss-image-cache-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Settings.php
114 lines (90 loc) · 3.13 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
<?php
namespace ImageCache;
class Settings
{
const DEFAULT_CACHE_URL = "https://example.com/pic?url=";
const DEFAULT_CACHE_POST_URL = "https://example.com/prepare";
const DEFAULT_CACHE_DISABLED_URL = "";
const DEFAULT_RECACHE_URL = "";
const DEFAULT_CACHE_ACCESS_TOKEN = "";
const DEFAULT_VIDEO_VOLUME = 1;
const DEFAULT_UPLOAD_RETRY_COUNT = 0;
const DEFAULT_UPLOAD_RETRY_DELAY = 0;
const DEFAULT_MAX_CACHE_ELEMENTS = 5000;
const DEFAULT_REMOVE_WRONG_TAG = false;
private array $settings;
public function __construct(array $settings)
{
$this->settings = $settings;
}
public function getImageCacheUrl(): string
{
if (array_key_exists('image_cache_url', $this->settings)) {
return (string)$this->settings['image_cache_url'];
}
return self::DEFAULT_CACHE_URL;
}
public function getImageCachePostUrl(): string
{
if (array_key_exists('image_cache_post_url', $this->settings)) {
return (string)$this->settings['image_cache_post_url'];
}
return self::DEFAULT_CACHE_POST_URL;
}
public function getImageCacheAccessToken(): string
{
if (array_key_exists('image_cache_access_token', $this->settings)) {
return (string)$this->settings['image_cache_access_token'];
}
return self::DEFAULT_CACHE_ACCESS_TOKEN;
}
public function getImageDisabledUrl(): string
{
if (array_key_exists('image_cache_disabled_url', $this->settings)) {
return (string)$this->settings['image_cache_disabled_url'];
}
return self::DEFAULT_CACHE_DISABLED_URL;
}
public function getImageRecacheUrl(): string
{
if (array_key_exists('image_recache_url', $this->settings)) {
return (string)$this->settings['image_recache_url'];
}
return self::DEFAULT_RECACHE_URL;
}
public function getVideoDefaultVolume(): float
{
if (array_key_exists('video_default_volume', $this->settings)) {
return (float)$this->settings['video_default_volume'];
}
return self::DEFAULT_VIDEO_VOLUME;
}
public function getUploadRetryCount(): int
{
if (array_key_exists('upload_retry_count', $this->settings)) {
return (int)$this->settings['upload_retry_count'];
}
return self::DEFAULT_UPLOAD_RETRY_COUNT;
}
public function getUploadRetryDelay(): int
{
if (array_key_exists('upload_retry_delay', $this->settings)) {
return (int)$this->settings['upload_retry_delay'];
}
return self::DEFAULT_UPLOAD_RETRY_DELAY;
}
public function getMaxCacheElements(): int
{
if (array_key_exists('max_cache_elements', $this->settings)) {
return (int)$this->settings['max_cache_elements'];
}
return self::DEFAULT_MAX_CACHE_ELEMENTS;
}
public function isRemoveWrongTag(): bool
{
if (array_key_exists('remove_wrong_tag', $this->settings)) {
return (bool)$this->settings['remove_wrong_tag'];
}
return self::DEFAULT_REMOVE_WRONG_TAG;
}
}