]> git.mxchange.org Git - friendica.git/commitdiff
Reformat code
authorHypolite Petovan <hypolite@mrpetovan.com>
Sun, 17 Mar 2019 23:04:42 +0000 (19:04 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Wed, 20 Mar 2019 02:42:05 +0000 (22:42 -0400)
- Reformat Console\Storage
- Reformat Core\StorageManager
- Simplify logic in Worker\CronJobs

src/Core/Console/Storage.php
src/Core/StorageManager.php
src/Worker/CronJobs.php

index 52f453471eed4bc501da51bcd5d351df5e84e33e..a7a0ffd38b34a7183b47c3b2f53d3e4e893238b3 100644 (file)
@@ -49,36 +49,36 @@ HELP;
                        return -1;
                }
 
-               switch($this->args[0]) {
-               case 'list':
-                       return $this->do_list();
-                       break;
-               case 'set':
-                       return $this->do_set();
-                       break;
-               case 'move':
-                       return $this->do_move();
-                       break;
+               switch ($this->args[0]) {
+                       case 'list':
+                               return $this->doList();
+                               break;
+                       case 'set':
+                               return $this->doSet();
+                               break;
+                       case 'move':
+                               return $this->doMove();
+                               break;
                }
 
                $this->out(sprintf('Invalid action "%s"', $this->args[0]));
                return -1;
        }
 
-       protected function do_list()
+       protected function doList()
        {
                $rowfmt = ' %-3s | %-20s';
                $current = StorageManager::getBackend();
                $this->out(sprintf($rowfmt, 'Sel', 'Name'));
                $this->out('-----------------------');
                $isregisterd = false;
-               foreach(StorageManager::listBackends() as $name => $class) {
+               foreach (StorageManager::listBackends() as $name => $class) {
                        $issel = ' ';
                        if ($current === $class) {
                                $issel = '*';
                                $isregisterd = true;
                        };
-                       $this->out(sprintf($rowfmt, $issel , $name ));
+                       $this->out(sprintf($rowfmt, $issel, $name));
                }
 
                if ($current === '') {
@@ -92,7 +92,7 @@ HELP;
                return 0;
        }
 
-       protected function do_set()
+       protected function doSet()
        {
                if (count($this->args) !== 2) {
                        throw new CommandArgsException('Invalid arguments');
@@ -110,7 +110,7 @@ HELP;
                return 0;
        }
 
-       protected function do_move()
+       protected function doMove()
        {
                $tables = null;
                if (count($this->args) < 1 || count($this->args) > 2) {
index ef6cef480a355c28f2f3dace16914a163ec18c45..335c28f05126baf5e7801b70befda94425542849 100644 (file)
@@ -23,7 +23,7 @@ class StorageManager
 
        private static function setup()
        {
-               if (count(self::$backends)==0) {
+               if (count(self::$backends) == 0) {
                        self::$backends = Config::get('storage', 'backends', self::$default_backends);
                }
        }
index f723cf69f17a32fde4b69214b0708ae422741f1f..5ebe91cf406229811841f375d0397e0b113a2a37 100644 (file)
@@ -35,54 +35,42 @@ class CronJobs
 
                Logger::log("Starting cronjob " . $command, Logger::DEBUG);
 
-               // Call possible post update functions
-               // see src/Database/PostUpdate.php for more details
-               if ($command == 'post_update') {
-                       PostUpdate::update();
-                       return;
-               }
+               switch($command) {
+                       case 'post_update':
+                               PostUpdate::update();
+                               break;
 
-               // update nodeinfo data
-               if ($command == 'nodeinfo') {
-                       nodeinfo_cron();
-                       return;
-               }
+                       case 'nodeinfo':
+                               nodeinfo_cron();
+                               break;
 
-               // Expire and remove user entries
-               if ($command == 'expire_and_remove_users') {
-                       self::expireAndRemoveUsers();
-                       return;
-               }
+                       case 'expire_and_remove_users':
+                               self::expireAndRemoveUsers();
+                               break;
 
-               if ($command == 'update_contact_birthdays') {
-                       Contact::updateBirthdays();
-                       return;
-               }
+                       case 'update_contact_birthdays':
+                               Contact::updateBirthdays();
+                               break;
 
-               if ($command == 'update_photo_albums') {
-                       self::updatePhotoAlbums();
-                       return;
-               }
+                       case 'update_photo_albums':
+                               self::updatePhotoAlbums();
+                               break;
 
-               // Clear cache entries
-               if ($command == 'clear_cache') {
-                       self::clearCache($a);
-                       return;
-               }
+                       case 'clear_cache':
+                               self::clearCache($a);
+                               break;
 
-               // Repair missing Diaspora values in contacts
-               if ($command == 'repair_diaspora') {
-                       self::repairDiaspora($a);
-                       return;
-               }
+                       case 'repair_diaspora':
+                               self::repairDiaspora($a);
+                               break;
 
-               // Repair entries in the database
-               if ($command == 'repair_database') {
-                       self::repairDatabase();
-                       return;
-               }
+                       case 'repair_database':
+                               self::repairDatabase();
+                               break;
 
-               Logger::log("Xronjob " . $command . " is unknown.", Logger::DEBUG);
+                       default:
+                               Logger::log("Xronjob " . $command . " is unknown.", Logger::DEBUG);
+               }
 
                return;
        }