| Conditions | 8 |
| Paths | 60 |
| Total Lines | 56 |
| Code Lines | 43 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| 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 |
||
| 90 | private function addZikulaPathRequirements(SymfonyRequirements $symfonyRequirements, array $parameters = []): void |
||
| 91 | { |
||
| 92 | $fileSystem = new Filesystem(); |
||
| 93 | $projectDir = $parameters['kernel.project_dir']; |
||
| 94 | $symfonyRequirements->addRequirement( |
||
| 95 | is_writable($projectDir . '/config'), |
||
| 96 | 'config/ directory must be writable', |
||
| 97 | 'Change the permissions of "<strong>config/</strong>" directory so that the web server can write into it.' |
||
| 98 | ); |
||
| 99 | $symfonyRequirements->addRequirement( |
||
| 100 | is_writable($projectDir . '/config/dynamic'), |
||
| 101 | 'config/dynamic/ directory must be writable', |
||
| 102 | 'Change the permissions of "<strong>config/dynamic/</strong>" directory so that the web server can write into it.' |
||
| 103 | ); |
||
| 104 | $dataDir = $projectDir . '/' . $parameters['datadir']; |
||
| 105 | if (!is_dir($dataDir)) { |
||
| 106 | $fileSystem->mkdir($dataDir); |
||
| 107 | } |
||
| 108 | $symfonyRequirements->addRequirement( |
||
| 109 | is_writable($dataDir), |
||
| 110 | $parameters['datadir'] . '/ directory must be writable', |
||
| 111 | 'Change the permissions of "<strong>' . $parameters['datadir'] . '</strong>" directory so that the web server can write into it.' |
||
| 112 | ); |
||
| 113 | $customParametersPath = $projectDir . '/config/services_custom.yaml'; |
||
| 114 | if (file_exists($customParametersPath)) { |
||
| 115 | $symfonyRequirements->addRequirement( |
||
| 116 | is_writable($customParametersPath), |
||
| 117 | 'config/services_custom.yaml file must be writable', |
||
| 118 | 'Change the permissions of "<strong>config/services_custom.yaml</strong>" so that the web server can write into it.' |
||
| 119 | ); |
||
| 120 | } |
||
| 121 | $customEnvVarsPath = $projectDir . '/.env.local'; |
||
| 122 | if (!file_exists($customEnvVarsPath)) { |
||
| 123 | // try to create the file |
||
| 124 | try { |
||
| 125 | $fileSystem->touch($customEnvVarsPath); |
||
| 126 | } catch (IOExceptionInterface $exception) { |
||
| 127 | $symfonyRequirements->addRequirement( |
||
| 128 | false, |
||
| 129 | '.env.local file must exists', |
||
| 130 | 'Create an empty file "<strong>.env.local</strong>" in the root folder.' |
||
| 131 | ); |
||
| 132 | } |
||
| 133 | } |
||
| 134 | if (file_exists($customEnvVarsPath)) { |
||
| 135 | $content = file_get_contents($customEnvVarsPath); |
||
| 136 | if (false === mb_strpos($content, 'DATABASE_URL')) { |
||
| 137 | // no database credentials are set yet |
||
| 138 | try { |
||
| 139 | $fileSystem->dumpFile($customEnvVarsPath, 'Test'); |
||
| 140 | $fileSystem->dumpFile($customEnvVarsPath, ''); |
||
| 141 | } catch (IOExceptionInterface $exception) { |
||
| 142 | $symfonyRequirements->addRequirement( |
||
| 143 | false, |
||
| 144 | '.env.local file must be writable', |
||
| 145 | 'Change the permissions of "<strong>.env.local</strong>" so that the web server can write into it.' |
||
| 146 | ); |
||
| 152 |