src/Process/Http/RequestBodyParser.php
Method __invoke
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function __invoke(ServerRequestInterface $request, UnitTrackerInterface $unitTracker)
{
// Decode body
$method = $request->getMethod();
if ($method === 'POST') {
Function __invoke
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
public function __invoke(ServerRequestInterface $request, UnitTrackerInterface $unitTracker)
{
// Decode body
$method = $request->getMethod();
if ($method === 'POST') {
- 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
Call to method getMethod
from undeclared class \Psr\Http\Message\ServerRequestInterface
Open
Open
$method = $request->getMethod();
- Exclude checks
Call to method getBody
from undeclared class \Psr\Http\Message\ServerRequestInterface
Open
Open
$bodyString = $request->getBody()->getContents();
- Exclude checks
@throws type of __invoke
has undeclared type \Pluf\Scion\Process\Http\Exception\InvalidBodyContentException
Open
Open
public function __invoke(ServerRequestInterface $request, UnitTrackerInterface $unitTracker)
- Exclude checks
Call to method withParsedBody
from undeclared class \Psr\Http\Message\ServerRequestInterface
Open
Open
$request = $request->withParsedBody($bodyJson);
- Exclude checks
Call to method next
from undeclared class \Pluf\Scion\UnitTrackerInterface
Open
Open
return $unitTracker->next([
- Exclude checks
Parameter $request
has undeclared type \Psr\Http\Message\ServerRequestInterface
Open
Open
public function __invoke(ServerRequestInterface $request, UnitTrackerInterface $unitTracker)
- Exclude checks
Call to method __construct
from undeclared class \Pluf\Scion\Process\Http\Exception\InvalidBodyContentException
(Did you mean class \Pluf\Core\Exception\InvalidBodyContentException) Open
Open
throw new InvalidBodyContentException("Fail to decode body as " . $parsedContentType);
- Exclude checks
Doc-block of $request
in __invoke
contains phpdoc param type \Psr\Http\Message\RequestInterface
which is incompatible with the param type \Psr\Http\Message\ServerRequestInterface
declared in the signature Open
Open
* @param RequestInterface $request
- Exclude checks
Parameter $unitTracker
has undeclared type \Pluf\Scion\UnitTrackerInterface
Open
Open
public function __invoke(ServerRequestInterface $request, UnitTrackerInterface $unitTracker)
- Exclude checks
Call to method __construct
from undeclared class \Pluf\Scion\Process\Http\Exception\InvalidBodyContentException
(Did you mean class \Pluf\Core\Exception\InvalidBodyContentException) Open
Open
throw new InvalidBodyContentException("Not supported content type: " . $parsedContentType);
- Exclude checks
Call to method getHeader
from undeclared class \Psr\Http\Message\ServerRequestInterface
Open
Open
$contentTypes = $request->getHeader('Content-Type') ?? [];
- Exclude checks
Avoid excessively long variable names like $contentTypesWithParsedBodies. Keep variable name length under 20. Open
Open
$contentTypesWithParsedBodies = [
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Expected 1 blank line at end of file; 2 found Open
Open
}
- Exclude checks
Whitespace found at end of line Open
Open
*
- Exclude checks