Conditions | 1 |
Paths | 1 |
Total Lines | 68 |
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 |
||
18 | protected function configure() |
||
19 | { |
||
20 | $this->setName('scan') |
||
21 | ->setDescription('Check the http status code of all links on a website.') |
||
22 | ->addArgument( |
||
23 | 'url', |
||
24 | InputArgument::REQUIRED, |
||
25 | 'The url to check' |
||
26 | ) |
||
27 | ->addOption( |
||
28 | 'concurrency', |
||
29 | 'c', |
||
30 | InputOption::VALUE_REQUIRED, |
||
31 | 'The amount of concurrent connections to use', |
||
32 | 10 |
||
33 | ) |
||
34 | ->addOption( |
||
35 | 'output', |
||
36 | 'o', |
||
37 | InputOption::VALUE_REQUIRED, |
||
38 | 'Log all non-2xx and non-3xx responses in this file' |
||
39 | ) |
||
40 | ->addOption( |
||
41 | 'csv', |
||
42 | 'f', |
||
43 | InputOption::VALUE_REQUIRED, |
||
44 | 'Log all responses in this csv file' |
||
45 | ) |
||
46 | ->addOption( |
||
47 | 'dont-crawl-external-links', |
||
48 | 'x', |
||
49 | InputOption::VALUE_NONE, |
||
50 | 'Dont crawl external links' |
||
51 | ) |
||
52 | ->addOption( |
||
53 | 'timeout', |
||
54 | 't', |
||
55 | InputOption::VALUE_OPTIONAL, |
||
56 | 'The maximum number of seconds the request can take', |
||
57 | 10 |
||
58 | ) |
||
59 | ->addOption( |
||
60 | 'user-agent', |
||
61 | 'u', |
||
62 | InputOption::VALUE_OPTIONAL, |
||
63 | 'The User Agent to pass for the request', |
||
64 | '' |
||
65 | ) |
||
66 | ->addOption( |
||
67 | 'skip-verification', |
||
68 | 's', |
||
69 | InputOption::VALUE_NONE, |
||
70 | 'Skips checking the SSL certificate' |
||
71 | ) |
||
72 | ->addOption( |
||
73 | 'options', |
||
74 | 'opt', |
||
75 | InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, |
||
76 | 'Additional options to the request', |
||
77 | [] |
||
78 | ) |
||
79 | ->addOption( |
||
80 | 'ignore-robots', |
||
81 | null, |
||
82 | InputOption::VALUE_NONE, |
||
83 | 'Ignore robots checks' |
||
84 | ); |
||
85 | } |
||
86 | |||
169 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.