Conditions | 1 |
Paths | 1 |
Total Lines | 52 |
Code Lines | 15 |
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 |
||
21 | protected function configure() |
||
22 | { |
||
23 | $this |
||
24 | ->setName('liip:imagine:cache:remove') |
||
25 | ->setDescription('Remove asset caches for the passed asset paths(s) and filter name(s)') |
||
26 | ->addArgument('paths', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, |
||
27 | 'Asset paths to remove caches of (passing none will use all paths).') |
||
28 | ->addOption('filter', 'f', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, |
||
29 | 'Filter name to remove caches of (passing none will use all registered filters)') |
||
30 | ->addOption('machine-readable', 'm', InputOption::VALUE_NONE, |
||
31 | 'Enable machine parseable output (removing extraneous output and all text styles)') |
||
32 | ->addOption('filters', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, |
||
33 | 'Deprecated in 1.9.0 and removed in 2.0.0 (use the --filter option instead)') |
||
34 | ->setHelp(<<<'EOF' |
||
35 | The <comment>%command.name%</comment> command removes asset cache for the passed image(s) and filter(s). |
||
36 | |||
37 | For an application that has only the two files "foo.ext" and "bar.ext", and only the filter sets |
||
38 | named "thumb_sm" and "thumb_lg", the following examples will behave as shown. |
||
39 | |||
40 | <comment># bin/console %command.name% foo.ext</comment> |
||
41 | Removes caches for <options=bold>foo.ext</> using <options=bold>all configured filters</>, outputting: |
||
42 | <info>- foo.ext[thumb_sm] removed</> |
||
43 | <info>- foo.ext[thumb_lg] removed</> |
||
44 | |||
45 | <comment># bin/console %command.name% --filter=thumb_sm --filter=thumb_lg foo.ext bar.ext</comment> |
||
46 | Removes caches for both <options=bold>foo.ext</> and <options=bold>bar.ext</> using <options=bold>thumb_sm</> and <options=bold>thumb_lg</> filters, outputting: |
||
47 | <info>- foo.ext[thumb_sm] removed</> |
||
48 | <info>- foo.ext[thumb_lg] removed</> |
||
49 | <info>- bar.ext[thumb_sm] removed</> |
||
50 | <info>- bar.ext[thumb_lg] removed</> |
||
51 | |||
52 | <comment># bin/console %command.name% --filter=thumb_sm</comment> |
||
53 | Removes <options=bold>all caches</> for <options=bold>thumb_sm</> filter, outputting: |
||
54 | <info>- *[thumb_sm] glob-removal</> |
||
55 | |||
56 | <comment># bin/console %command.name%</comment> |
||
57 | Removes <options=bold>all caches</> for <options=bold>all configured filters</>, removing all cached assets, outputting: |
||
58 | <info>- *[thumb_sm] glob-removal</> |
||
59 | <info>- *[thumb_lg] glob-removal</> |
||
60 | |||
61 | <comment># bin/console %command.name% --force --filter=thumb_sm foo.ext</comment> |
||
62 | Removing caches for <options=bold>foo.ext</> using <options=bold>thumb_sm</> filter when <options=bold>already removed</> will caused <options=bold>skipping</>, outputting: |
||
63 | <info>- foo.ext[thumb_sm] skipped</> |
||
64 | |||
65 | <comment># bin/console %command.name% --filter=does_not_exist --filter=thumb_sm foo.ext</comment> |
||
66 | Removes caches for <options=bold>foo.ext</> for <options=bold>thumb_sm</> while <options=bold>failing inline</> on invalid filter (or other errors), outputting: |
||
67 | <info>- foo.ext[does_not_exist] failure: Could not find configuration for a filter: does_not_exist</> |
||
68 | <info>- foo.ext[thumb_sm] removed</> |
||
69 | |||
70 | EOF |
||
71 | ); |
||
72 | } |
||
73 | |||
141 |