| Conditions | 10 |
| Paths | 13 |
| Total Lines | 33 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 5 | ||
| Bugs | 0 | Features | 2 |
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 |
||
| 39 | public function boot() |
||
| 40 | { |
||
| 41 | parent::boot(); |
||
| 42 | |||
| 43 | if (php_sapi_name() == 'cli') { |
||
| 44 | return null; |
||
| 45 | } |
||
| 46 | |||
| 47 | $bundleVersion = null; |
||
| 48 | |||
| 49 | // need to be installed |
||
| 50 | if ($this->getNeedInstallation() && $this->container->getParameter('versions.checkNeedInstallation')) { |
||
| 51 | $bundleVersion = $this->container->get('versions.bundle')->getVersion($this->getName()); |
||
| 52 | if ($bundleVersion->isInstalled() === false) { |
||
| 53 | if ($this->getName() == 'VersionsBundle') { |
||
| 54 | $message = 'Bundle "' . $this->getName() . '" needs to be installed. Exec "php app/console bundle:install ' . $this->getName() . ' --force".'; |
||
| 55 | } else { |
||
| 56 | $message = 'Bundle "' . $this->getName() . '" needs to be installed. Exec "php app/console bundle:install ' . $this->getName() . '".'; |
||
| 57 | } |
||
| 58 | throw new VersionException($message); |
||
| 59 | } |
||
| 60 | } |
||
| 61 | |||
| 62 | // need to be updated |
||
| 63 | if ($this->getNeedUpToDate() && $this->container->getParameter('versions.checkNeedUpToDate')) { |
||
| 64 | if ($bundleVersion === null) { |
||
| 65 | $bundleVersion = $this->container->get('versions.bundle')->getVersion($this->getName()); |
||
| 66 | } |
||
| 67 | if ($bundleVersion->needUpdate()) { |
||
| 68 | throw new VersionException('Bundle "' . $this->getName() . '" needs to be updated. Exec "php app/console bundle:update ' . $this->getName() . '".'); |
||
| 69 | } |
||
| 70 | } |
||
| 71 | } |
||
| 72 | |||
| 127 |