src/Illuminate/Http/Client/PendingRequest.php
File PendingRequest.php
has 720 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php
namespace Illuminate\Http\Client;
use Closure;
PendingRequest
has 78 functions (exceeds 20 allowed). Consider refactoring. Open
Open
class PendingRequest
{
use Conditionable, Macroable;
/**
Method send
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function send(string $method, string $url, array $options = [])
{
if (! Str::startsWith($url, ['http://', 'https://'])) {
$url = ltrim(rtrim($this->baseUrl, '/').'/'.ltrim($url, '/'), '/');
}
Method handlePromiseResponse
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected function handlePromiseResponse(Response|ConnectionException|TransferException $response, $method, $url, $options, $attempt)
{
if ($response instanceof Response && $response->successful()) {
return $response;
}
Function handlePromiseResponse
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
protected function handlePromiseResponse(Response|ConnectionException|TransferException $response, $method, $url, $options, $attempt)
{
if ($response instanceof Response && $response->successful()) {
return $response;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method handlePromiseResponse
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
protected function handlePromiseResponse(Response|ConnectionException|TransferException $response, $method, $url, $options, $attempt)
Function parseHttpOptions
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
protected function parseHttpOptions(array $options)
{
if (isset($options[$this->bodyFormat])) {
if ($this->bodyFormat === 'multipart') {
$options[$this->bodyFormat] = $this->parseMultipartBodyFormat($options[$this->bodyFormat]);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this method. Open
Open
return $response instanceof Response ? $response->toException() : $response;
Avoid too many return
statements within this method. Open
Open
return $response;