Conditions | 20 |
Paths | 5 |
Total Lines | 46 |
Code Lines | 30 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 declare(strict_types=1); |
||
47 | protected function execute(InputInterface $input, OutputInterface $output): int |
||
48 | { |
||
49 | $this->io = new SymfonyStyle($input, $output); |
||
50 | $context = Context::createDefaultContext(); |
||
51 | $this->io->writeln('Start theme compilation'); |
||
52 | |||
53 | $onlySalesChannel = ((array) $input->getOption('only')) ?: null; |
||
54 | $skipSalesChannel = ((array) $input->getOption('skip')) ?: null; |
||
55 | if ($onlySalesChannel !== null && $skipSalesChannel !== null |
||
56 | && \count(array_intersect($onlySalesChannel, $skipSalesChannel)) > 0) { |
||
57 | $this->io->error('The sales channel includes and skips contain contradicting entries:' . implode( |
||
58 | ', ', |
||
59 | array_intersect($onlySalesChannel, $skipSalesChannel) |
||
60 | )); |
||
61 | |||
62 | return self::FAILURE; |
||
63 | } |
||
64 | |||
65 | $onlyThemes = ((array) $input->getOption('only-themes')) ?: null; |
||
66 | $skipThemes = ((array) $input->getOption('skip-themes')) ?: null; |
||
67 | if ($onlyThemes !== null && $skipThemes !== null |
||
68 | && \count(array_intersect($onlyThemes, $skipThemes)) > 0) { |
||
69 | $this->io->error('The theme includes and skips contain contradicting entries:' . implode( |
||
70 | ', ', |
||
71 | array_intersect($onlyThemes, $skipThemes) |
||
72 | )); |
||
73 | |||
74 | return self::FAILURE; |
||
75 | } |
||
76 | |||
77 | foreach ($this->themeProvider->load($context, $input->getOption('active-only')) as $salesChannelId => $themeId) { |
||
78 | if ($onlySalesChannel !== null && !\in_array($salesChannelId, $onlySalesChannel, true) |
||
79 | || $skipSalesChannel !== null && \in_array($salesChannelId, $skipSalesChannel, true) |
||
80 | || $onlyThemes !== null && !\in_array($themeId, $onlyThemes, true) |
||
81 | || $skipThemes !== null && \in_array($themeId, $skipThemes, true)) { |
||
82 | continue; |
||
83 | } |
||
84 | |||
85 | $this->io->block(\sprintf('Compiling theme for sales channel for : %s', $salesChannelId)); |
||
86 | |||
87 | $start = microtime(true); |
||
88 | $this->themeService->compileTheme($salesChannelId, $themeId, $context, null, !$input->getOption('keep-assets')); |
||
89 | $this->io->note(sprintf('Took %f seconds', microtime(true) - $start)); |
||
90 | } |
||
91 | |||
92 | return self::SUCCESS; |
||
93 | } |
||
95 |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.