diff options
Diffstat (limited to 'application/History.php')
-rw-r--r-- | application/History.php | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/application/History.php b/application/History.php index 35ec016a..8074a017 100644 --- a/application/History.php +++ b/application/History.php | |||
@@ -1,4 +1,9 @@ | |||
1 | <?php | 1 | <?php |
2 | namespace Shaarli; | ||
3 | |||
4 | use DateTime; | ||
5 | use Exception; | ||
6 | use FileUtils; | ||
2 | 7 | ||
3 | /** | 8 | /** |
4 | * Class History | 9 | * Class History |
@@ -141,7 +146,7 @@ class History | |||
141 | * Save a new event and write it in the history file. | 146 | * Save a new event and write it in the history file. |
142 | * | 147 | * |
143 | * @param string $status Event key, should be defined as constant. | 148 | * @param string $status Event key, should be defined as constant. |
144 | * @param mixed $id Event item identifier (e.g. link ID). | 149 | * @param mixed $id Event item identifier (e.g. link ID). |
145 | */ | 150 | */ |
146 | protected function addEvent($status, $id = null) | 151 | protected function addEvent($status, $id = null) |
147 | { | 152 | { |
@@ -166,11 +171,11 @@ class History | |||
166 | */ | 171 | */ |
167 | protected function check() | 172 | protected function check() |
168 | { | 173 | { |
169 | if (! is_file($this->historyFilePath)) { | 174 | if (!is_file($this->historyFilePath)) { |
170 | FileUtils::writeFlatDB($this->historyFilePath, []); | 175 | FileUtils::writeFlatDB($this->historyFilePath, []); |
171 | } | 176 | } |
172 | 177 | ||
173 | if (! is_writable($this->historyFilePath)) { | 178 | if (!is_writable($this->historyFilePath)) { |
174 | throw new Exception(t('History file isn\'t readable or writable')); | 179 | throw new Exception(t('History file isn\'t readable or writable')); |
175 | } | 180 | } |
176 | } | 181 | } |
@@ -191,7 +196,7 @@ class History | |||
191 | */ | 196 | */ |
192 | protected function write() | 197 | protected function write() |
193 | { | 198 | { |
194 | $comparaison = new DateTime('-'. $this->retentionTime . ' seconds'); | 199 | $comparaison = new DateTime('-' . $this->retentionTime . ' seconds'); |
195 | foreach ($this->history as $key => $value) { | 200 | foreach ($this->history as $key => $value) { |
196 | if ($value['datetime'] < $comparaison) { | 201 | if ($value['datetime'] < $comparaison) { |
197 | unset($this->history[$key]); | 202 | unset($this->history[$key]); |