@@ -48,6 +48,9 @@ |
||
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | + /** |
|
| 52 | + * @param string $environment |
|
| 53 | + */ |
|
| 51 | 54 | public function getAllValuesForEnvironment(?string $environment = null): array |
| 52 | 55 | { |
| 53 | 56 | $result = []; |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Karma\Configuration; |
| 6 | 6 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | public function setDefaultEnvironment(string $environment): void |
| 44 | 44 | { |
| 45 | - if(! empty($environment) && is_string($environment)) |
|
| 45 | + if( ! empty($environment) && is_string($environment)) |
|
| 46 | 46 | { |
| 47 | 47 | $this->defaultEnvironment = $environment; |
| 48 | 48 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | }, $value); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - if(! is_string($value)) |
|
| 94 | + if( ! is_string($value)) |
|
| 95 | 95 | { |
| 96 | 96 | return $value; |
| 97 | 97 | } |
@@ -32,6 +32,11 @@ discard block |
||
| 32 | 32 | protected |
| 33 | 33 | $environment; |
| 34 | 34 | |
| 35 | + /** |
|
| 36 | + * @param string $name |
|
| 37 | + * @param string $description |
|
| 38 | + * @param string $outputTitle |
|
| 39 | + */ |
|
| 35 | 40 | public function __construct(Application $app, $name, $description, $outputTitle) |
| 36 | 41 | { |
| 37 | 42 | $this->name = $name; |
@@ -169,6 +174,9 @@ discard block |
||
| 169 | 174 | } |
| 170 | 175 | } |
| 171 | 176 | |
| 177 | + /** |
|
| 178 | + * @param string $optionName |
|
| 179 | + */ |
|
| 172 | 180 | private function parseOptionWithAssignments(InputInterface $input, $optionName) |
| 173 | 181 | { |
| 174 | 182 | $strings = $input->getOption($optionName); |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | { |
| 147 | 147 | $processor->setSystemEnvironment($this->systemEnvironment); |
| 148 | 148 | |
| 149 | - $this->app['logger']->info(sprintf( |
|
| 149 | + $this->app['logger']->info(sprintf( |
|
| 150 | 150 | 'Hydrate <important>system</important> variables with <important>%s</important> values', |
| 151 | 151 | $this->systemEnvironment |
| 152 | 152 | )); |
@@ -197,9 +197,9 @@ discard block |
||
| 197 | 197 | foreach($overrides as $variable => $value) |
| 198 | 198 | { |
| 199 | 199 | $logger->info(sprintf( |
| 200 | - 'Override <important>%s</important> with value <important>%s</important>', |
|
| 201 | - $variable, |
|
| 202 | - $value |
|
| 200 | + 'Override <important>%s</important> with value <important>%s</important>', |
|
| 201 | + $variable, |
|
| 202 | + $value |
|
| 203 | 203 | )); |
| 204 | 204 | |
| 205 | 205 | $value = $this->parseList($value); |
@@ -216,9 +216,9 @@ discard block |
||
| 216 | 216 | foreach($data as $variable => $value) |
| 217 | 217 | { |
| 218 | 218 | $logger->info(sprintf( |
| 219 | - 'Set custom data <important>%s</important> with value <important>%s</important>', |
|
| 220 | - $variable, |
|
| 221 | - $value |
|
| 219 | + 'Set custom data <important>%s</important> with value <important>%s</important>', |
|
| 220 | + $variable, |
|
| 221 | + $value |
|
| 222 | 222 | )); |
| 223 | 223 | |
| 224 | 224 | $reader->setCustomData($variable, $this->filterValue($value)); |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Karma\Console; |
| 6 | 6 | |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | $sourcePath = $profile->getSourcePath(); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - if(! is_array($sourcePath)) |
|
| 110 | + if( ! is_array($sourcePath)) |
|
| 111 | 111 | { |
| 112 | 112 | $sourcePath = [$sourcePath]; |
| 113 | 113 | } |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | { |
| 174 | 174 | $strings = $input->getOption($optionName); |
| 175 | 175 | |
| 176 | - if(! is_array($strings)) |
|
| 176 | + if( ! is_array($strings)) |
|
| 177 | 177 | { |
| 178 | 178 | $strings = [$strings]; |
| 179 | 179 | } |
@@ -253,6 +253,10 @@ discard block |
||
| 253 | 253 | } |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | + /** |
|
| 257 | + * @param string $environment |
|
| 258 | + * @param string $delimiter |
|
| 259 | + */ |
|
| 256 | 260 | private function generateContentForListDirective($variable, $environment, $delimiter, array $wrapper) |
| 257 | 261 | { |
| 258 | 262 | $values = $this->readValueToInject($variable, $environment); |
@@ -276,11 +280,19 @@ discard block |
||
| 276 | 280 | ); |
| 277 | 281 | } |
| 278 | 282 | |
| 283 | + /** |
|
| 284 | + * @param string $fileContent |
|
| 285 | + */ |
|
| 279 | 286 | private function removeFileDirectives($fileContent) |
| 280 | 287 | { |
| 281 | 288 | return preg_replace('~(<%\s*karma:[^%]*%>\s*)~i', '', $fileContent); |
| 282 | 289 | } |
| 283 | 290 | |
| 291 | + /** |
|
| 292 | + * @param string $sourceFile |
|
| 293 | + * @param string $content |
|
| 294 | + * @param string $environment |
|
| 295 | + */ |
|
| 284 | 296 | private function injectValues($sourceFile, $content, $environment, $replacementCounter = 0) |
| 285 | 297 | { |
| 286 | 298 | $replacementCounter += $this->injectScalarValues($content, $environment); |
@@ -110,7 +110,7 @@ |
||
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | $this->info(sprintf( |
| 113 | - '%d files generated', |
|
| 113 | + '%d files generated', |
|
| 114 | 114 | count($files) |
| 115 | 115 | )); |
| 116 | 116 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Karma; |
| 6 | 6 | |
@@ -258,12 +258,12 @@ discard block |
||
| 258 | 258 | $values = $this->readValueToInject($variable, $environment); |
| 259 | 259 | $formatter = $this->getFormatterForCurrentTargetFile(); |
| 260 | 260 | |
| 261 | - if(! is_array($values)) |
|
| 261 | + if( ! is_array($values)) |
|
| 262 | 262 | { |
| 263 | 263 | $values = array($values); |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - array_walk($values, function (& $value) use ($formatter) { |
|
| 266 | + array_walk($values, function(& $value) use ($formatter) { |
|
| 267 | 267 | $value = $formatter->format($value); |
| 268 | 268 | }); |
| 269 | 269 | |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | { |
| 373 | 373 | $values = $this->readValueToInject($matches['variableName'], $environment); |
| 374 | 374 | |
| 375 | - if(!is_array($values)) |
|
| 375 | + if( ! is_array($values)) |
|
| 376 | 376 | { |
| 377 | 377 | throw new \RuntimeException(sprintf( |
| 378 | 378 | "Nested variable detected [%s] while writing %s at line %d", |
@@ -266,8 +266,7 @@ |
||
| 266 | 266 | { |
| 267 | 267 | $formatter = $this->getFormatterForCurrentTargetFile(); |
| 268 | 268 | |
| 269 | - $content = preg_replace_callback(self::VARIABLE_REGEX, function(array $matches) use($environment, $formatter) |
|
| 270 | - { |
|
| 269 | + $content = preg_replace_callback(self::VARIABLE_REGEX, function(array $matches) use($environment, $formatter) { |
|
| 271 | 270 | $value = $this->readValueToInject($matches['variableName'], $environment); |
| 272 | 271 | |
| 273 | 272 | if(is_array($value)) |
@@ -118,7 +118,7 @@ |
||
| 118 | 118 | |
| 119 | 119 | $targetContent = $this->injectValues($file, $content, $environment, $replacementCounter); |
| 120 | 120 | |
| 121 | - $this->debug("Write $this->currentTargetFile"); |
|
| 121 | + $this->debug("write $this->currentTargetFile"); |
|
| 122 | 122 | |
| 123 | 123 | if($this->dryRun === false) |
| 124 | 124 | { |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Karma; |
| 6 | 6 | |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Karma\Filters; |
| 6 | 6 | |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Karma; |
| 6 | 6 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Karma; |
| 6 | 6 | |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | $paths = $c['sources.path']; |
| 112 | 112 | |
| 113 | - if(! is_array($paths)) |
|
| 113 | + if( ! is_array($paths)) |
|
| 114 | 114 | { |
| 115 | 115 | $paths = [$paths]; |
| 116 | 116 | } |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | |
| 137 | 137 | $this['target.fileSystem.adapter'] = $this->factory(function(Container $c) { |
| 138 | 138 | |
| 139 | - if(! empty($c['target.path'])) |
|
| 139 | + if( ! empty($c['target.path'])) |
|
| 140 | 140 | { |
| 141 | 141 | $c['hydrator.allowNonDistFilesOverwrite'] = true; |
| 142 | 142 | |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | return new \Psr\Log\NullLogger(); |
| 210 | 210 | }); |
| 211 | 211 | |
| 212 | - $this['formatter.provider'] = function (Container $c) { |
|
| 212 | + $this['formatter.provider'] = function(Container $c) { |
|
| 213 | 213 | return new ProfileProvider($c['profile']); |
| 214 | 214 | }; |
| 215 | 215 | |
@@ -223,19 +223,19 @@ discard block |
||
| 223 | 223 | return $hydrator; |
| 224 | 224 | }); |
| 225 | 225 | |
| 226 | - $this['generator.nameTranslator'] = function (Container $c) { |
|
| 226 | + $this['generator.nameTranslator'] = function(Container $c) { |
|
| 227 | 227 | $translator = new FilePrefixTranslator(); |
| 228 | 228 | $translator->changeMasterFile($c['configuration.masterFile']); |
| 229 | 229 | |
| 230 | 230 | return $translator; |
| 231 | 231 | }; |
| 232 | 232 | |
| 233 | - $this['generator.variableProvider'] = $this->factory(function (Container $c) { |
|
| 233 | + $this['generator.variableProvider'] = $this->factory(function(Container $c) { |
|
| 234 | 234 | $provider = new VariableProvider($c['parser']); |
| 235 | 235 | |
| 236 | 236 | $profile = $c['profile']; |
| 237 | 237 | $options = $profile->getGeneratorOptions(); |
| 238 | - if(! isset($options['translator']) || $options['translator'] === 'prefix') |
|
| 238 | + if( ! isset($options['translator']) || $options['translator'] === 'prefix') |
|
| 239 | 239 | { |
| 240 | 240 | $provider->setNameTranslator($c['generator.nameTranslator']); |
| 241 | 241 | } |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | return $provider; |
| 244 | 244 | }); |
| 245 | 245 | |
| 246 | - $this['configurationFilesGenerator'] = function (Container $c) { |
|
| 246 | + $this['configurationFilesGenerator'] = function(Container $c) { |
|
| 247 | 247 | return new YamlGenerator($c['generate.sources.fileSystem'], $c['configuration'], $c['generator.variableProvider']); |
| 248 | 248 | }; |
| 249 | 249 | } |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | private function writeLevel($level) |
| 51 | 51 | { |
| 52 | 52 | $message = str_pad(sprintf( |
| 53 | - '[%s]', |
|
| 54 | - strtoupper($level) |
|
| 53 | + '[%s]', |
|
| 54 | + strtoupper($level) |
|
| 55 | 55 | ), 10); |
| 56 | 56 | |
| 57 | 57 | $this->output->write($this->colorizeMessage($level, $message)); |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | if(isset($colors[$level])) |
| 68 | 68 | { |
| 69 | 69 | $message = sprintf( |
| 70 | - '<%1$s>%2$s</%1$s>', |
|
| 70 | + '<%1$s>%2$s</%1$s>', |
|
| 71 | 71 | 'fg=' . $colors[$level], |
| 72 | 72 | $message |
| 73 | 73 | ); |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Karma\Logging; |
| 6 | 6 | |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types = 1); |
|
| 3 | +declare(strict_types=1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Karma\Logging; |
| 6 | 6 | |