]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - application/History.php
namespacing: \Shaarli\History
[github/shaarli/Shaarli.git] / application / History.php
index 5e3b1b72d475ce97fd05692bec751e661b13e182..8074a0172c634912adf507bcd2236d8419cffe81 100644 (file)
@@ -1,4 +1,9 @@
 <?php
+namespace Shaarli;
+
+use DateTime;
+use Exception;
+use FileUtils;
 
 /**
  * Class History
@@ -141,7 +146,7 @@ class History
      * Save a new event and write it in the history file.
      *
      * @param string $status Event key, should be defined as constant.
-     * @param mixed  $id     Event item identifier (e.g. link ID).
+     * @param mixed $id Event item identifier (e.g. link ID).
      */
     protected function addEvent($status, $id = null)
     {
@@ -166,12 +171,12 @@ class History
      */
     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'));
         }
     }
 
@@ -182,7 +187,7 @@ class History
     {
         $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'));
         }
     }
 
@@ -191,7 +196,7 @@ class History
      */
     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]);