Conditions | 1 |
Paths | 1 |
Total Lines | 115 |
Code Lines | 94 |
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 |
||
43 | protected function configure() |
||
44 | { |
||
45 | $this |
||
46 | ->setName(self::NAME) |
||
47 | ->setDescription('Will create a composer configuration file') |
||
48 | ->addArgument( |
||
49 | self::ARGUMENT_CONFIGURATION_DEST_FOLDER, |
||
50 | InputArgument::OPTIONAL, |
||
51 | 'Configuration file destination folder', |
||
52 | '.' |
||
53 | ) |
||
54 | ->addArgument( |
||
55 | InputTransformer::KEY_PACKAGE_NAME, |
||
56 | InputArgument::OPTIONAL, |
||
57 | 'Name for the composer package. Optionnal if a template containing package-name is given.' |
||
58 | ) |
||
59 | ->addOption( |
||
60 | InputTransformer::KEY_TYPE, |
||
61 | null, |
||
62 | InputOption::VALUE_REQUIRED, |
||
63 | 'Package type. Ex : "library" / "project"' |
||
64 | ) |
||
65 | ->addOption( |
||
66 | InputTransformer::KEY_LICENSE, |
||
67 | null, |
||
68 | InputOption::VALUE_REQUIRED, |
||
69 | 'Package license type' |
||
70 | ) |
||
71 | ->addOption( |
||
72 | InputTransformer::KEY_PACKAGE_VERSION, |
||
73 | null, |
||
74 | InputOption::VALUE_REQUIRED, |
||
75 | 'Package version number. Ex : "X.Y.Z"' |
||
76 | ) |
||
77 | ->addOption( |
||
78 | InputTransformer::KEY_DESCRIPTION, |
||
79 | null, |
||
80 | InputOption::VALUE_REQUIRED, |
||
81 | 'Package description' |
||
82 | ) |
||
83 | ->addOption( |
||
84 | InputTransformer::KEY_KEYWORD, |
||
85 | null, |
||
86 | InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
||
87 | 'Package keywords' |
||
88 | ) |
||
89 | ->addOption( |
||
90 | InputTransformer::KEY_AUTHOR, |
||
91 | null, |
||
92 | InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
||
93 | 'Package authors. Format "name[#email[#role]]' |
||
94 | ) |
||
95 | ->addOption( |
||
96 | InputTransformer::KEY_PROVIDED_PACKAGE, |
||
97 | null, |
||
98 | InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
||
99 | 'List of packages provided by this one. Ex : "package-name#version"' |
||
100 | ) |
||
101 | ->addOption( |
||
102 | InputTransformer::KEY_SUGGESTED_PACKAGE, |
||
103 | null, |
||
104 | InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
||
105 | 'List of packages suggested by this one. Ex : "package-name#description"' |
||
106 | ) |
||
107 | ->addOption( |
||
108 | InputTransformer::KEY_SUPPORT, |
||
109 | null, |
||
110 | InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
||
111 | 'List of package support urls. Ex : "type#url"' |
||
112 | ) |
||
113 | ->addOption( |
||
114 | InputTransformer::KEY_AUTOLOAD_PSR0, |
||
115 | null, |
||
116 | InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
||
117 | 'List of PSR-0 autoload. Ex : "namespace#path"' |
||
118 | ) |
||
119 | ->addOption( |
||
120 | InputTransformer::KEY_AUTOLOAD_PSR4, |
||
121 | null, |
||
122 | InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
||
123 | 'List of PSR-4 autoload. Ex : "namespace#path"' |
||
124 | ) |
||
125 | ->addOption( |
||
126 | InputTransformer::KEY_AUTOLOAD_DEV_PSR0, |
||
127 | null, |
||
128 | InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
||
129 | 'List of PSR-0 dev autoload. Ex : "namespace#path"' |
||
130 | ) |
||
131 | ->addOption( |
||
132 | InputTransformer::KEY_AUTOLOAD_DEV_PSR4, |
||
133 | null, |
||
134 | InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
||
135 | 'List of PSR-4 dev autoload. Ex : "namespace#path"' |
||
136 | ) |
||
137 | ->addOption( |
||
138 | InputTransformer::KEY_REQUIRE, |
||
139 | null, |
||
140 | InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
||
141 | 'List of required packages. Ex "vendor/package-name#~x.y"' |
||
142 | ) |
||
143 | ->addOption( |
||
144 | InputTransformer::KEY_REQUIRE_DEV, |
||
145 | null, |
||
146 | InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
||
147 | 'List of required dev packages. Ex "vendor/package-name#~x.y"' |
||
148 | ) |
||
149 | ->addOption( |
||
150 | InputTransformer::KEY_SCRIPT, |
||
151 | null, |
||
152 | InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
||
153 | 'List of scripts for the package. Ex : "script-name#command"' |
||
154 | ) |
||
155 | ; |
||
156 | parent::configure(); |
||
157 | } |
||
158 | |||
211 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.