src/Process/Http/RequestBodyParser.php

Summary

Maintainability
A
2 hrs
Test Coverage

Method __invoke has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function __invoke(ServerRequestInterface $request, UnitTrackerInterface $unitTracker)
    {
        // Decode body
        $method = $request->getMethod();
        if ($method === 'POST') {
Severity: Minor
Found in src/Process/Http/RequestBodyParser.php - About 1 hr to fix

    Function __invoke has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public function __invoke(ServerRequestInterface $request, UnitTrackerInterface $unitTracker)
        {
            // Decode body
            $method = $request->getMethod();
            if ($method === 'POST') {
    Severity: Minor
    Found in src/Process/Http/RequestBodyParser.php - About 1 hr to fix

    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

            $method = $request->getMethod();
    Severity: Critical
    Found in src/Process/Http/RequestBodyParser.php by phan

    Call to method getBody from undeclared class \Psr\Http\Message\ServerRequestInterface
    Open

                    $bodyString = $request->getBody()->getContents();
    Severity: Critical
    Found in src/Process/Http/RequestBodyParser.php by phan

    @throws type of __invoke has undeclared type \Pluf\Scion\Process\Http\Exception\InvalidBodyContentException
    Open

        public function __invoke(ServerRequestInterface $request, UnitTrackerInterface $unitTracker)
    Severity: Minor
    Found in src/Process/Http/RequestBodyParser.php by phan

    Call to method withParsedBody from undeclared class \Psr\Http\Message\ServerRequestInterface
    Open

                            $request = $request->withParsedBody($bodyJson);
    Severity: Critical
    Found in src/Process/Http/RequestBodyParser.php by phan

    Call to method next from undeclared class \Pluf\Scion\UnitTrackerInterface
    Open

            return $unitTracker->next([
    Severity: Critical
    Found in src/Process/Http/RequestBodyParser.php by phan

    Parameter $request has undeclared type \Psr\Http\Message\ServerRequestInterface
    Open

        public function __invoke(ServerRequestInterface $request, UnitTrackerInterface $unitTracker)
    Severity: Minor
    Found in src/Process/Http/RequestBodyParser.php by phan

    Call to method __construct from undeclared class \Pluf\Scion\Process\Http\Exception\InvalidBodyContentException (Did you mean class \Pluf\Core\Exception\InvalidBodyContentException)
    Open

                                throw new InvalidBodyContentException("Fail to decode body as " . $parsedContentType);
    Severity: Critical
    Found in src/Process/Http/RequestBodyParser.php by phan

    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

         * @param RequestInterface $request
    Severity: Minor
    Found in src/Process/Http/RequestBodyParser.php by phan

    Parameter $unitTracker has undeclared type \Pluf\Scion\UnitTrackerInterface
    Open

        public function __invoke(ServerRequestInterface $request, UnitTrackerInterface $unitTracker)
    Severity: Minor
    Found in src/Process/Http/RequestBodyParser.php by phan

    Call to method __construct from undeclared class \Pluf\Scion\Process\Http\Exception\InvalidBodyContentException (Did you mean class \Pluf\Core\Exception\InvalidBodyContentException)
    Open

                            throw new InvalidBodyContentException("Not supported content type: " . $parsedContentType);
    Severity: Critical
    Found in src/Process/Http/RequestBodyParser.php by phan

    Call to method getHeader from undeclared class \Psr\Http\Message\ServerRequestInterface
    Open

                $contentTypes = $request->getHeader('Content-Type') ?? [];
    Severity: Critical
    Found in src/Process/Http/RequestBodyParser.php by phan

    Avoid excessively long variable names like $contentTypesWithParsedBodies. Keep variable name length under 20.
    Open

                $contentTypesWithParsedBodies = [

    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

    }

    Whitespace found at end of line
    Open

     *        

    There are no issues that match your filters.

    Category
    Status