diff options
author | Aurélien Tamisier <virtualtam+github@flibidi.net> | 2019-01-18 21:26:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-18 21:26:03 +0100 |
commit | ff3b5dc5542ec150f0d9b447394364a15e9156d0 (patch) | |
tree | 5e926e36816d510e3b3a10e20b94c23f43b55092 /application/History.php | |
parent | 1826e383ecf501302974132fd443cf1ca06e10f6 (diff) | |
parent | dea72c711ff740b3b829d238fcf85648465143a0 (diff) | |
download | Shaarli-ff3b5dc5542ec150f0d9b447394364a15e9156d0.tar.gz Shaarli-ff3b5dc5542ec150f0d9b447394364a15e9156d0.tar.zst Shaarli-ff3b5dc5542ec150f0d9b447394364a15e9156d0.zip |
Merge pull request #1248 from virtualtam/refactor/namespacing
Ensure all PHP classes are properly namespaced
Diffstat (limited to 'application/History.php')
-rw-r--r-- | application/History.php | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/application/History.php b/application/History.php index 35ec016a..a5846652 100644 --- a/application/History.php +++ b/application/History.php | |||
@@ -1,4 +1,8 @@ | |||
1 | <?php | 1 | <?php |
2 | namespace Shaarli; | ||
3 | |||
4 | use DateTime; | ||
5 | use Exception; | ||
2 | 6 | ||
3 | /** | 7 | /** |
4 | * Class History | 8 | * Class History |
@@ -66,7 +70,7 @@ class History | |||
66 | * History constructor. | 70 | * History constructor. |
67 | * | 71 | * |
68 | * @param string $historyFilePath History file path. | 72 | * @param string $historyFilePath History file path. |
69 | * @param int $retentionTime History content rentention time in seconds. | 73 | * @param int $retentionTime History content retention time in seconds. |
70 | * | 74 | * |
71 | * @throws Exception if something goes wrong. | 75 | * @throws Exception if something goes wrong. |
72 | */ | 76 | */ |
@@ -166,11 +170,11 @@ class History | |||
166 | */ | 170 | */ |
167 | protected function check() | 171 | protected function check() |
168 | { | 172 | { |
169 | if (! is_file($this->historyFilePath)) { | 173 | if (!is_file($this->historyFilePath)) { |
170 | FileUtils::writeFlatDB($this->historyFilePath, []); | 174 | FileUtils::writeFlatDB($this->historyFilePath, []); |
171 | } | 175 | } |
172 | 176 | ||
173 | if (! is_writable($this->historyFilePath)) { | 177 | if (!is_writable($this->historyFilePath)) { |
174 | throw new Exception(t('History file isn\'t readable or writable')); | 178 | throw new Exception(t('History file isn\'t readable or writable')); |
175 | } | 179 | } |
176 | } | 180 | } |
@@ -191,7 +195,7 @@ class History | |||
191 | */ | 195 | */ |
192 | protected function write() | 196 | protected function write() |
193 | { | 197 | { |
194 | $comparaison = new DateTime('-'. $this->retentionTime . ' seconds'); | 198 | $comparaison = new DateTime('-' . $this->retentionTime . ' seconds'); |
195 | foreach ($this->history as $key => $value) { | 199 | foreach ($this->history as $key => $value) { |
196 | if ($value['datetime'] < $comparaison) { | 200 | if ($value['datetime'] < $comparaison) { |
197 | unset($this->history[$key]); | 201 | unset($this->history[$key]); |