Conditions | 1 |
Paths | 1 |
Total Lines | 135 |
Code Lines | 92 |
Lines | 0 |
Ratio | 0 % |
Changes | 8 | ||
Bugs | 0 | Features | 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 |
||
22 | public function properlyMapsSimplifiedConfig(): void |
||
23 | { |
||
24 | $config = [ |
||
25 | 'app_options' => [ |
||
26 | 'disable_track_param' => 'foo', |
||
27 | ], |
||
28 | |||
29 | 'entity_manager' => [ |
||
30 | 'connection' => [ |
||
31 | 'driver' => 'mysql', |
||
32 | 'host' => 'shlink_db', |
||
33 | 'port' => '3306', |
||
34 | ], |
||
35 | ], |
||
36 | ]; |
||
37 | $simplified = [ |
||
38 | 'disable_track_param' => 'bar', |
||
39 | 'short_domain_schema' => 'https', |
||
40 | 'short_domain_host' => 'doma.in', |
||
41 | 'validate_url' => true, |
||
42 | 'delete_short_url_threshold' => 50, |
||
43 | 'invalid_short_url_redirect_to' => 'foobar.com', |
||
44 | 'regular_404_redirect_to' => 'bar.com', |
||
45 | 'base_url_redirect_to' => 'foo.com', |
||
46 | 'redis_servers' => [ |
||
47 | 'tcp://1.1.1.1:1111', |
||
48 | 'tcp://1.2.2.2:2222', |
||
49 | ], |
||
50 | 'db_config' => [ |
||
51 | 'dbname' => 'shlink', |
||
52 | 'user' => 'foo', |
||
53 | 'password' => 'bar', |
||
54 | 'port' => '1234', |
||
55 | ], |
||
56 | 'base_path' => '/foo/bar', |
||
57 | 'task_worker_num' => 50, |
||
58 | 'visits_webhooks' => [ |
||
59 | 'http://my-api.com/api/v2.3/notify', |
||
60 | 'https://third-party.io/foo', |
||
61 | ], |
||
62 | 'default_short_codes_length' => 8, |
||
63 | 'geolite_license_key' => 'kjh23ljkbndskj345', |
||
64 | 'mercure_public_hub_url' => 'public_url', |
||
65 | 'mercure_internal_hub_url' => 'internal_url', |
||
66 | 'mercure_jwt_secret' => 'super_secret_value', |
||
67 | 'anonymize_remote_addr' => false, |
||
68 | 'redirect_status_code' => 301, |
||
69 | 'redirect_cache_lifetime' => 90, |
||
70 | 'port' => 8888, |
||
71 | ]; |
||
72 | $expected = [ |
||
73 | 'app_options' => [ |
||
74 | 'disable_track_param' => 'bar', |
||
75 | ], |
||
76 | |||
77 | 'entity_manager' => [ |
||
78 | 'connection' => [ |
||
79 | 'driver' => 'mysql', |
||
80 | 'host' => 'shlink_db', |
||
81 | 'dbname' => 'shlink', |
||
82 | 'user' => 'foo', |
||
83 | 'password' => 'bar', |
||
84 | 'port' => '1234', |
||
85 | ], |
||
86 | ], |
||
87 | |||
88 | 'url_shortener' => [ |
||
89 | 'domain' => [ |
||
90 | 'schema' => 'https', |
||
91 | 'hostname' => 'doma.in', |
||
92 | ], |
||
93 | 'validate_url' => true, |
||
94 | 'visits_webhooks' => [ |
||
95 | 'http://my-api.com/api/v2.3/notify', |
||
96 | 'https://third-party.io/foo', |
||
97 | ], |
||
98 | 'default_short_codes_length' => 8, |
||
99 | 'anonymize_remote_addr' => false, |
||
100 | 'redirect_status_code' => 301, |
||
101 | 'redirect_cache_lifetime' => 90, |
||
102 | ], |
||
103 | |||
104 | 'delete_short_urls' => [ |
||
105 | 'visits_threshold' => 50, |
||
106 | 'check_visits_threshold' => true, |
||
107 | ], |
||
108 | |||
109 | 'dependencies' => [ |
||
110 | 'aliases' => [ |
||
111 | 'lock_store' => 'redis_lock_store', |
||
112 | ], |
||
113 | ], |
||
114 | |||
115 | 'cache' => [ |
||
116 | 'redis' => [ |
||
117 | 'servers' => [ |
||
118 | 'tcp://1.1.1.1:1111', |
||
119 | 'tcp://1.2.2.2:2222', |
||
120 | ], |
||
121 | ], |
||
122 | ], |
||
123 | |||
124 | 'router' => [ |
||
125 | 'base_path' => '/foo/bar', |
||
126 | ], |
||
127 | |||
128 | 'not_found_redirects' => [ |
||
129 | 'invalid_short_url' => 'foobar.com', |
||
130 | 'regular_404' => 'bar.com', |
||
131 | 'base_url' => 'foo.com', |
||
132 | ], |
||
133 | |||
134 | 'mezzio-swoole' => [ |
||
135 | 'swoole-http-server' => [ |
||
136 | 'port' => 8888, |
||
137 | 'options' => [ |
||
138 | 'task_worker_num' => 50, |
||
139 | ], |
||
140 | ], |
||
141 | ], |
||
142 | |||
143 | 'geolite2' => [ |
||
144 | 'license_key' => 'kjh23ljkbndskj345', |
||
145 | ], |
||
146 | |||
147 | 'mercure' => [ |
||
148 | 'public_hub_url' => 'public_url', |
||
149 | 'internal_hub_url' => 'internal_url', |
||
150 | 'jwt_secret' => 'super_secret_value', |
||
151 | ], |
||
152 | ]; |
||
153 | |||
154 | $result = ($this->postProcessor)(array_merge($config, $simplified)); |
||
155 | |||
156 | self::assertEquals(array_merge($expected, $simplified), $result); |
||
157 | } |
||
159 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths