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