-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConfigService.php
91 lines (76 loc) · 2.01 KB
/
ConfigService.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
<?php
/**
* NbFeed
*
* @author Stefan Wessel, NetBrothers GmbH
* @date 23.06.23
*/
namespace NetBrothers\NbFeed\Service;
use NetBrothers\NbFeed\Helper\StorageHelper;
/**
* Class ConfigService
* @package NetBrothers\NbFeed\Service
*/
class ConfigService
{
/** number of items to save
*
* set to 0 to save all
*/
private int $maxEntriesToSave = 0;
/** cache in seconds
*
* If there is a file on the hard disk that is not older than allowed, the results are pulled from the cache
*
* @var int Seconds
*/
private int $cacheMaxAge = 1800;
/** @var string|null Storage-Path for saving files */
private ?string $storagePath = null;
private string $feedFileName = 'nb-feed';
public function getMaxEntriesToSave(): int
{
return $this->maxEntriesToSave;
}
public function setMaxEntriesToSave(int $maxEntriesToSave): void
{
$this->maxEntriesToSave = $maxEntriesToSave;
}
public function getCacheMaxAge(): int
{
return $this->cacheMaxAge;
}
public function setCacheMaxAge(int $cacheMaxAge): void
{
$this->cacheMaxAge = $cacheMaxAge;
}
public function getStoragePath(): string
{
if ($this->storagePath === null) {
throw new \RuntimeException('Storage path ist not initialized yet.');
}
return $this->storagePath;
}
/**
* @param string $storagePath
* @throws \RuntimeException thrown on I/O errors
*/
public function setStoragePath(string $storagePath): void
{
$this->storagePath = StorageHelper::createPath($storagePath);
}
/**
* @return string target file name without file extension
*/
public function getFeedFileName(): string
{
return $this->feedFileName;
}
/**
* @param string $feedFileName target file name without file extension
*/
public function setFeedFileName(string $feedFileName): void
{
$this->feedFileName = $feedFileName;
}
}