fatcode/http-server

View on GitHub

Showing 10 of 10 total issues

HttpServerSettings has 22 functions (exceeds 20 allowed). Consider refactoring.
Open

class HttpServerSettings
{
    private $address;
    private $port;
    private $workers;
Severity: Minor
Found in src/Server/HttpServerSettings.php - About 2 hrs to fix

    Method toArray has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function toArray() : array
        {
            $output = [
                'address' => $this->getAddress(),
                'port' => $this->getPort(),
    Severity: Minor
    Found in src/Server/HttpServerSettings.php - About 1 hr to fix

      Method createServerRequest has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function createServerRequest($input = null) : ServerRequestInterface
          {
              try {
                  $body = (string) $input->rawContent();
              } catch (Throwable $throwable) {
      Severity: Minor
      Found in src/Server/Swoole/SwooleServerRequestFactory.php - About 1 hr to fix

        Method onRequest has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function onRequest($request, $response) : void
            {
                $psrRequest = $this->requestFactory->createServerRequest($request);
                $pipeline = clone $this->pipeline;
                $psrResponse = $pipeline->process($psrRequest, $pipeline);
        Severity: Minor
        Found in src/Server/Swoole/SwooleServerHandler.php - About 1 hr to fix

          Function process has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              public function process(ServerRequestInterface $request, RequestHandlerInterface $next) : ResponseInterface
              {
                  $this->setErrorHandler();
          
                  try {
          Severity: Minor
          Found in src/Server/ErrorMiddleware.php - About 55 mins 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

          Method __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  $uri = null,
                  HttpMethod $method = null,
                  $body = 'php://input',
                  array $headers = [],
                  array $uploadedFiles = [],
          Severity: Minor
          Found in src/ServerRequest.php - About 45 mins to fix

            Function toArray has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public function toArray() : array
                {
                    $output = [
                        'address' => $this->getAddress(),
                        'port' => $this->getPort(),
            Severity: Minor
            Found in src/Server/HttpServerSettings.php - About 45 mins 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

            Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    $streamOrFile,
                    int $size,
                    UploadStatus $status,
                    string $clientFilename = null,
                    string $clientMediaType = null
            Severity: Minor
            Found in src/UploadedFile.php - About 35 mins to fix

              Function onRequest has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function onRequest($request, $response) : void
                  {
                      $psrRequest = $this->requestFactory->createServerRequest($request);
                      $pipeline = clone $this->pipeline;
                      $psrResponse = $pipeline->process($psrRequest, $pipeline);
              Severity: Minor
              Found in src/Server/Swoole/SwooleServerHandler.php - About 35 mins 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

              Function translateSettings has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function translateSettings(HttpServerSettings $settings) : array
                  {
                      $hash = $settings->toArray();
              
                      $swooleSettings = [];
              Severity: Minor
              Found in src/Server/Swoole/SwooleServerHandler.php - About 25 mins 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

              Severity
              Category
              Status
              Source
              Language