Conditions | 1 |
Paths | 1 |
Total Lines | 70 |
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 |
||
31 | protected function configure() :void |
||
32 | { |
||
33 | $this->setName('lighthouse-audit') |
||
34 | ->setDefinition([new InputArgument( |
||
35 | 'path', |
||
36 | InputArgument::REQUIRED, |
||
37 | 'Specify the path of a directory to analyse.' |
||
38 | )]) |
||
39 | ->addOption( |
||
40 | 'url-prefix', |
||
41 | null, |
||
42 | InputOption::VALUE_OPTIONAL, |
||
43 | 'Define the url prefix that should be used when testing.', |
||
44 | self::DEFAULT_URL_PREFIX |
||
45 | ) |
||
46 | ->addOption( |
||
47 | 'mode', |
||
48 | null, |
||
49 | InputOption::VALUE_OPTIONAL, |
||
50 | 'Define the mode to run Lighthouse audit. Option: mobile,desktop', |
||
51 | self::DEFAULT_MODE |
||
52 | ) |
||
53 | ->addOption( |
||
54 | 'performance', |
||
55 | null, |
||
56 | InputOption::VALUE_OPTIONAL, |
||
57 | 'Define the minimal performance score for audit to pass', |
||
58 | self::DEFAULT_PERFORMANCE |
||
59 | ) |
||
60 | ->addOption( |
||
61 | 'best-practices', |
||
62 | null, |
||
63 | InputOption::VALUE_OPTIONAL, |
||
64 | 'Define the minimal best-practices score for audit to pass', |
||
65 | self::DEFAULT_BEST_PRACTICES |
||
66 | ) |
||
67 | ->addOption( |
||
68 | 'accessibility', |
||
69 | null, |
||
70 | InputOption::VALUE_OPTIONAL, |
||
71 | 'Define the minimal accessibility score for audit to pass', |
||
72 | self::DEFAULT_ACCESSIBILITY |
||
73 | ) |
||
74 | ->addOption( |
||
75 | 'seo', |
||
76 | null, |
||
77 | InputOption::VALUE_OPTIONAL, |
||
78 | 'Define the minimal seo score for audit to pass', |
||
79 | self::DEFAULT_SEO |
||
80 | ) |
||
81 | ->addOption( |
||
82 | 'pwa', |
||
83 | null, |
||
84 | InputOption::VALUE_OPTIONAL, |
||
85 | 'Define the minimal pwa score for audit to pass', |
||
86 | self::DEFAULT_PWA |
||
87 | ) |
||
88 | ->addOption( |
||
89 | 'except', |
||
90 | null, |
||
91 | InputOption::VALUE_OPTIONAL, |
||
92 | 'Provide a list of filenames that you wish to exclude, separated by commas.'.PHP_EOL |
||
93 | ) |
||
94 | ->addOption( |
||
95 | 'chrome-flags', |
||
96 | null, |
||
97 | InputOption::VALUE_OPTIONAL, |
||
98 | 'Custom flags to pass to Chrome (space-delimited). For a full list of flags, '.PHP_EOL.'see http://peter.sh/experiments/chromium-command-line-switches/.'.PHP_EOL |
||
99 | ); |
||
100 | } |
||
101 | |||
158 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: