| Conditions | 1 |
| Paths | 1 |
| Total Lines | 91 |
| Code Lines | 69 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 6 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 56 | public function startSystem(): bool |
||
| 57 | { |
||
| 58 | $this->di->getShared('registry')->booting = true; |
||
| 59 | |||
| 60 | $this->echoStartMsg(' - Start beanstalkd daemon...'); |
||
| 61 | $beanstalkConf = new BeanstalkConf(); |
||
| 62 | $beanstalkConf->reStart(); |
||
| 63 | $this->echoResultMsg(); |
||
| 64 | |||
| 65 | $this->echoStartMsg(' - Start redis daemon...'); |
||
| 66 | $redisConf = new RedisConf(); |
||
| 67 | $redisConf->reStart(); |
||
| 68 | $this->echoResultMsg(); |
||
| 69 | |||
| 70 | $system = new System(); |
||
| 71 | $this->echoStartMsg(' - Configuring timezone...'); |
||
| 72 | $system::timezoneConfigure(); |
||
| 73 | $this->echoResultMsg(); |
||
| 74 | |||
| 75 | $storage = new Storage(); |
||
| 76 | $this->echoStartMsg(' - Mount storage disk...'); |
||
| 77 | $storage->saveFstab(); |
||
| 78 | $storage->configure(); |
||
| 79 | $this->echoResultMsg(); |
||
| 80 | |||
| 81 | $this->echoStartMsg(' - Connect swap...'); |
||
| 82 | $storage->mountSwap(); |
||
| 83 | $this->echoResultMsg(); |
||
| 84 | |||
| 85 | $this->echoStartMsg(' - Start syslogd daemon...'); |
||
| 86 | $syslogConf = new SyslogConf(); |
||
| 87 | $syslogConf->reStart(); |
||
| 88 | $this->echoResultMsg(); |
||
| 89 | |||
| 90 | $dbUpdater = new UpdateDatabase(); |
||
| 91 | $dbUpdater->updateDatabaseStructure(); |
||
| 92 | |||
| 93 | $this->echoStartMsg(' - Create modules links and folders...'); |
||
| 94 | $storage->createWorkDirsAfterDBUpgrade(); |
||
| 95 | $this->echoResultMsg(); |
||
| 96 | |||
| 97 | $this->echoStartMsg(' - Update configs and applications...'."\n"); |
||
| 98 | $confUpdate = new UpdateSystemConfig(); |
||
| 99 | $confUpdate->updateConfigs(); |
||
| 100 | $this->echoStartMsg(' - Update configs...'); |
||
| 101 | $this->echoResultMsg(); |
||
| 102 | |||
| 103 | $this->echoStartMsg(' - Load kernel modules...'); |
||
| 104 | $resKernelModules = $system->loadKernelModules(); |
||
| 105 | $this->echoResultMsg($resKernelModules); |
||
| 106 | |||
| 107 | $this->echoStartMsg(' - Configuring VM tools...'); |
||
| 108 | $vmwareTools = new VMWareToolsConf(); |
||
| 109 | $resultVMTools = $vmwareTools->configure(); |
||
| 110 | $this->echoResultMsg($resultVMTools); |
||
| 111 | |||
| 112 | $this->echoStartMsg(' - Configuring hostname...'); |
||
| 113 | $network = new Network(); |
||
| 114 | $network->hostnameConfigure(); |
||
| 115 | $this->echoResultMsg(); |
||
| 116 | |||
| 117 | $this->echoStartMsg(' - Configuring resolv.conf...'); |
||
| 118 | $network->resolvConfGenerate(); |
||
| 119 | $this->echoResultMsg(); |
||
| 120 | |||
| 121 | $this->echoStartMsg(' - Configuring LAN interface...'); |
||
| 122 | $network->lanConfigure(); |
||
| 123 | $this->echoResultMsg(); |
||
| 124 | |||
| 125 | $this->echoStartMsg(' - Configuring Firewall...'); |
||
| 126 | $firewall = new IptablesConf(); |
||
| 127 | $firewall->applyConfig(); |
||
| 128 | $this->echoResultMsg(); |
||
| 129 | |||
| 130 | $this->echoStartMsg(' - Configuring ntpd...'); |
||
| 131 | NTPConf::configure(); |
||
| 132 | $this->echoResultMsg(); |
||
| 133 | |||
| 134 | $this->echoStartMsg(' - Configuring SSH console...'); |
||
| 135 | $sshConf = new SSHConf(); |
||
| 136 | $resSsh = $sshConf->configure(); |
||
| 137 | $this->echoResultMsg($resSsh); |
||
| 138 | |||
| 139 | $this->echoStartMsg(' - Configuring msmtp services...'); |
||
| 140 | $notifications = new Notifications(); |
||
| 141 | $notifications->configure(); |
||
| 142 | $this->echoResultMsg(); |
||
| 143 | |||
| 144 | $this->di->getShared('registry')->booting = false; |
||
| 145 | |||
| 146 | return true; |
||
| 147 | } |
||
| 194 | } |