Conditions | 1 |
Paths | 1 |
Total Lines | 53 |
Code Lines | 17 |
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:resolve') |
||
25 | ->setDescription('Resolves asset caches for the passed asset paths(s) and filter set name(s)') |
||
26 | ->addArgument('paths', InputArgument::REQUIRED | InputArgument::IS_ARRAY, |
||
27 | 'Asset paths to resolve caches for') |
||
28 | ->addOption('filter', 'f', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, |
||
29 | 'Filter name to resolve caches for (passing none will use all registered filters)') |
||
30 | ->addOption('force', 'F', InputOption::VALUE_NONE, |
||
31 | 'Force asset cache resolution (ignoring whether it already cached)') |
||
32 | ->addOption('machine-readable', 'm', InputOption::VALUE_NONE, |
||
33 | 'Enable machine parseable output (removing extraneous output and all text styles)') |
||
34 | ->addOption('filters', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, |
||
35 | 'Deprecated in 1.9.0 and removed in 2.0.0 (use the --filter option instead)') |
||
36 | ->setHelp(<<<'EOF' |
||
37 | The <comment>%command.name%</comment> command resolves asset cache for the passed image(s) and filter(s). |
||
38 | |||
39 | For an application that has only the two files "foo.ext" and "bar.ext", and only the filter sets |
||
40 | named "thumb_sm" and "thumb_lg", the following examples will behave as shown. |
||
41 | |||
42 | <comment># bin/console %command.name% foo.ext bar.ext</comment> |
||
43 | Resolves caches for <options=bold>both</> <options=bold>foo.ext</> and <options=bold>bar.ext</> using <options=bold>all configured filters</>, outputting: |
||
44 | <info>- foo.ext[thumb_sm] resolved: http://localhost/media/cache/thumb_sm/foo.ext</> |
||
45 | <info>- bar.ext[thumb_sm] resolved: http://localhost/media/cache/thumb_sm/bar.ext</> |
||
46 | <info>- foo.ext[thumb_lg] resolved: http://localhost/media/cache/thumb_lg/foo.ext</> |
||
47 | <info>- bar.ext[thumb_lg] resolved: http://localhost/media/cache/thumb_lg/bar.ext</> |
||
48 | |||
49 | <comment># bin/console %command.name% --filter=thumb_sm foo.ext</comment> |
||
50 | Resolves caches for <options=bold>foo.ext</> using <options=bold>only</> <options=bold>thumb_sm</> filter, outputting: |
||
51 | <info>- foo.ext[thumb_sm] resolved: http://localhost/media/cache/thumb_sm/foo.ext</> |
||
52 | |||
53 | <comment># bin/console %command.name% --filter=thumb_sm --filter=thumb_lg foo.ext</comment> |
||
54 | Resolves caches for <options=bold>foo.ext</> using <options=bold>both</> <options=bold>thumb_sm</> and <options=bold>thumb_lg</> filters, outputting: |
||
55 | <info>- foo.ext[thumb_sm] resolved: http://localhost/media/cache/thumb_sm/foo.ext</> |
||
56 | <info>- foo.ext[thumb_lg] resolved: http://localhost/media/cache/thumb_lg/foo.ext</> |
||
57 | |||
58 | <comment># bin/console %command.name% --force --filter=thumb_sm foo.ext</comment> |
||
59 | Resolving caches for <options=bold>foo.ext</> using <options=bold>thumb_sm</> filter when <options=bold>already cached</> will caused <options=bold>skipped</>, outputting: |
||
60 | <info>- foo.ext[thumb_sm] skipped: http://localhost/media/cache/thumb_sm/foo.ext</> |
||
61 | |||
62 | <comment># bin/console %command.name% --force --filter=thumb_sm foo.ext</comment> |
||
63 | Resolving caches for <options=bold>foo.ext</> using <options=bold>thumb_sm</> filter when <options=bold>already cached</> with <options=bold>force</> option <options=bold>re-resolves</> (ignoring cache), outputting: |
||
64 | <info>- foo.ext[thumb_sm] resolved: http://localhost/media/cache/thumb_sm/foo.ext</> |
||
65 | |||
66 | <comment># bin/console %command.name% --filter=does_not_exist --filter=thumb_sm foo.ext</comment> |
||
67 | Resolves caches for <options=bold>foo.ext</> using <options=bold>thumb_sm</> while <options=bold>failing inline</> on invalid filter (or other errors), outputting: |
||
68 | <info>- foo.ext[does_not_exist] failed: Could not find configuration for a filter: does_not_exist</> |
||
69 | <info>- foo.ext[thumb_sm] removed: http://localhost/media/cache/thumb_sm/foo.ext</> |
||
70 | |||
71 | EOF |
||
72 | ); |
||
73 | } |
||
74 | |||
124 |