Conditions | 7 |
Paths | 240 |
Total Lines | 57 |
Code Lines | 45 |
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 |
||
64 | public static function sendCall(string $method, string $uri, array $options = []): mixed |
||
65 | { |
||
66 | $config = []; |
||
67 | if ($uri) { |
||
68 | $config['base_url'] = $uri; |
||
69 | } |
||
70 | if (isset($options['query'])) { |
||
71 | $config['query'] = $options['query']; |
||
72 | } |
||
73 | |||
74 | $client = new UnleashedAPI($config); |
||
75 | |||
76 | if (UnleashedAPI::config()->debug) { |
||
77 | $options['debug'] = true; |
||
78 | } |
||
79 | |||
80 | try { |
||
81 | $response = $client->request($method, $uri, $options); |
||
82 | if (UnleashedAPI::config()->logsuccessfulcalls) { |
||
83 | $line_formatter = new LineFormatter( |
||
84 | null, // Format of message in log, default [%datetime%] %channel%.%level_name%: %message% %context% %extra%\n |
||
85 | null, // Datetime format |
||
86 | true, // allowInlineLineBreaks option, default false |
||
87 | true // discard empty Square brackets in the end, default false |
||
88 | ); |
||
89 | $logger = new Logger('unleashed-successful'); |
||
90 | $stream_handler = new StreamHandler('./z_unleashed-successful.log', Logger::INFO); |
||
91 | $stream_handler->setFormatter($line_formatter); |
||
92 | $logger->pushHandler($stream_handler); |
||
93 | $logger->info(_t('UnleashedAPI.RequestSuccessTitle', 'Request successful') . '\n'); |
||
94 | $logger->info(_t('UnleashedAPI.Method', 'Request method: ') . $method); |
||
95 | $logger->info(_t('UnleashedAPI.Uri', 'Request uri: ') . $uri); |
||
96 | $logger->info(_t('UnleashedAPI.Options', 'Request options: ')); |
||
97 | $logger->info(print_r($options, true)); |
||
98 | $logger->info(_t('UnleashedAPI.ResponseContent', 'Response Content: ')); |
||
99 | $logger->info(print_r($response->getBody()->getContents(), true)); |
||
100 | } |
||
101 | return $response; |
||
102 | } catch (ClientException $e) { |
||
103 | if (UnleashedAPI::config()->logfailedcalls) { |
||
104 | $line_formatter = new LineFormatter( |
||
105 | null, // Format of message in log, default [%datetime%] %channel%.%level_name%: %message% %context% %extra%\n |
||
106 | null, // Datetime format |
||
107 | true, // allowInlineLineBreaks option, default false |
||
108 | true // discard empty Square brackets in the end, default false |
||
109 | ); |
||
110 | $logger = new Logger('unleashed-client-exception'); |
||
111 | $stream_handler = new StreamHandler('./z_unleashed-client-exception.log', Logger::INFO); |
||
112 | $stream_handler->setFormatter($line_formatter); |
||
113 | $logger->pushHandler($stream_handler); |
||
114 | $logger->info(_t('UnleashedAPI.ClientExceptionTitle', 'Request failed'). '\n'); |
||
115 | $logger->info($e->getMessage()); |
||
116 | $logger->info(print_r($e->getResponse()->getBody()->getContents(), true)); |
||
117 | $logger->info($e->getRequest()->getMethod()); |
||
118 | $logger->info(print_r($e->getRequest()->getHeaders(), true)); |
||
119 | } |
||
120 | return $e; |
||
121 | } |
||
160 |
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