<?php
+namespace Shaarli;
+
+use DateTime;
+use Exception;
/**
* Class History
* History constructor.
*
* @param string $historyFilePath History file path.
- * @param int $retentionTime History content rentention time in seconds.
+ * @param int $retentionTime History content retention time in seconds.
*
* @throws Exception if something goes wrong.
*/
*/
protected function check()
{
- if (! is_file($this->historyFilePath)) {
+ if (!is_file($this->historyFilePath)) {
FileUtils::writeFlatDB($this->historyFilePath, []);
}
- if (! is_writable($this->historyFilePath)) {
- throw new Exception('History file isn\'t readable or writable');
+ if (!is_writable($this->historyFilePath)) {
+ throw new Exception(t('History file isn\'t readable or writable'));
}
}
{
$this->history = FileUtils::readFlatDB($this->historyFilePath, []);
if ($this->history === false) {
- throw new Exception('Could not parse history file');
+ throw new Exception(t('Could not parse history file'));
}
}
*/
protected function write()
{
- $comparaison = new DateTime('-'. $this->retentionTime . ' seconds');
+ $comparaison = new DateTime('-' . $this->retentionTime . ' seconds');
foreach ($this->history as $key => $value) {
if ($value['datetime'] < $comparaison) {
unset($this->history[$key]);