]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - application/updater/UpdaterUtils.php
Apply the new system (Bookmark + Service) to the whole code base
[github/shaarli/Shaarli.git] / application / updater / UpdaterUtils.php
index 34d4f422c26a59cc96e2b3eb982da7a77ae1445e..828a49fc02ae5909e6ab4c5c3502421af581ec81 100644 (file)
@@ -1,39 +1,44 @@
 <?php
 
-/**
- * Read the updates file, and return already done updates.
- *
- * @param string $updatesFilepath Updates file path.
- *
- * @return array Already done update methods.
- */
-function read_updates_file($updatesFilepath)
+namespace Shaarli\Updater;
+
+class UpdaterUtils
 {
-    if (! empty($updatesFilepath) && is_file($updatesFilepath)) {
-        $content = file_get_contents($updatesFilepath);
-        if (! empty($content)) {
-            return explode(';', $content);
+    /**
+     * Read the updates file, and return already done updates.
+     *
+     * @param string $updatesFilepath Updates file path.
+     *
+     * @return array Already done update methods.
+     */
+    public static function read_updates_file($updatesFilepath)
+    {
+        if (! empty($updatesFilepath) && is_file($updatesFilepath)) {
+            $content = file_get_contents($updatesFilepath);
+            if (! empty($content)) {
+                return explode(';', $content);
+            }
         }
+        return array();
     }
-    return array();
-}
 
-/**
- * Write updates file.
- *
- * @param string $updatesFilepath Updates file path.
- * @param array  $updates         Updates array to write.
- *
* @throws Exception Couldn't write version number.
- */
-function write_updates_file($updatesFilepath, $updates)
-{
-    if (empty($updatesFilepath)) {
-        throw new Exception(t('Updates file path is not set, can\'t write updates.'));
-    }
+    /**
    * Write updates file.
    *
    * @param string $updatesFilepath Updates file path.
    * @param array  $updates         Updates array to write.
    *
    * @throws \Exception Couldn't write version number.
    */
+    public static function write_updates_file($updatesFilepath, $updates)
+    {
+        if (empty($updatesFilepath)) {
+            throw new \Exception('Updates file path is not set, can\'t write updates.');
+        }
 
-    $res = file_put_contents($updatesFilepath, implode(';', $updates));
-    if ($res === false) {
-        throw new Exception(t('Unable to write updates in '. $updatesFilepath . '.'));
+        $res = file_put_contents($updatesFilepath, implode(';', $updates));
+        if ($res === false) {
+            throw new \Exception('Unable to write updates in '. $updatesFilepath . '.');
+        }
     }
 }