nutgram/nutgram

View on GitHub

Showing 33 of 33 total issues

DeepLink has 44 functions (exceeds 20 allowed). Consider refactoring.
Open

class DeepLink
{
    protected const DEFAULT_BASEURL = 'https://t.me/';
    protected ?string $baseUrl;

Severity: Minor
Found in src/Support/DeepLink.php - About 6 hrs to fix

    Function word_wrap has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

        function word_wrap(string $string, int $width = 75, string $break = "\n", bool $cut = false): string
        {
            if ($string === '') {
                return '';
            }
    Severity: Minor
    Found in src/Support/Helpers.php - About 5 hrs 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

    File MessageListeners.php has 315 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace SergiX44\Nutgram\Handlers\Listeners;
    
    use InvalidArgumentException;
    Severity: Minor
    Found in src/Handlers/Listeners/MessageListeners.php - About 3 hrs to fix

      File DeepLink.php has 311 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      namespace SergiX44\Nutgram\Support;
      
      /**
      Severity: Minor
      Found in src/Support/DeepLink.php - About 3 hrs to fix

        Function fakeDataFor has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
        Open

            private function fakeDataFor(
                string $class,
                array $additional = [],
            ): array {
                $this->resolveStack[] = $class;
        Severity: Minor
        Found in src/Testing/TypeFaker.php - About 2 hrs 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

        File FakeNutgram.php has 262 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        namespace SergiX44\Nutgram\Testing;
        
        use GuzzleHttp\Handler\MockHandler;
        Severity: Minor
        Found in src/Testing/FakeNutgram.php - About 2 hrs to fix

          Function addHandlersBy has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function addHandlersBy(
                  array &$handlers,
                  string $type,
                  ?string $subType = null,
                  ?string $value = null
          Severity: Minor
          Found in src/Handlers/ResolveHandlers.php - About 2 hrs 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 requestMultipart has 53 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function requestMultipart(
                  string $endpoint,
                  array $multipart = [],
                  string $mapTo = stdClass::class,
                  array $options = []
          Severity: Major
          Found in src/Telegram/Client.php - About 2 hrs to fix

            Method inject has 49 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private static function inject(Nutgram $bot, MockHandler $mock, HandlerStack $handlerStack): void
                {
                    (function () use ($handlerStack, $mock) {
                        /** @psalm-scope-this \SergiX44\Nutgram\Testing\FakeNutgram */
                        $this->mockHandler = $mock;
            Severity: Minor
            Found in src/Testing/FakeNutgram.php - About 1 hr to fix

              Function continueConversation has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function continueConversation(Conversation|callable $conversation): array
                  {
                      $resolvedHandlers = [];
              
                      if (!$conversation instanceof Conversation || !$conversation->skipHandlers()) {
              Severity: Minor
              Found in src/Handlers/ResolveHandlers.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

              Function resolveHandlers has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function resolveHandlers(): array
                  {
                      $resolvedHandlers = [];
                      $updateType = $this->update?->getType();
              
              
              Severity: Minor
              Found in src/Handlers/ResolveHandlers.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

              Function requestMultipart has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function requestMultipart(
                      string $endpoint,
                      array $multipart = [],
                      string $mapTo = stdClass::class,
                      array $options = []
              Severity: Minor
              Found in src/Telegram/Client.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

              Method word_wrap has 47 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  function word_wrap(string $string, int $width = 75, string $break = "\n", bool $cut = false): string
                  {
                      if ($string === '') {
                          return '';
                      }
              Severity: Minor
              Found in src/Support/Helpers.php - About 1 hr to fix

                Function parseRequest has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function parseRequest(): self
                    {
                        $this->method = $this->request->getMethod();
                        $this->headers = $this->request->getHeaders();
                
                
                Severity: Minor
                Found in src/Testing/FormDataParser.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

                Method parseRequest has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function parseRequest(): self
                    {
                        $this->method = $this->request->getMethod();
                        $this->headers = $this->request->getHeaders();
                
                
                Severity: Minor
                Found in src/Testing/FormDataParser.php - About 1 hr to fix

                  Method bootstrap has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function bootstrap(string $token, Configuration $config): void
                      {
                          $this->token = $token;
                          $this->config = $config;
                          $this->container = new Container();
                  Severity: Minor
                  Found in src/Nutgram.php - About 1 hr to fix

                    Method fakeDataFor has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function fakeDataFor(
                            string $class,
                            array $additional = [],
                        ): array {
                            $this->resolveStack[] = $class;
                    Severity: Minor
                    Found in src/Testing/TypeFaker.php - About 1 hr to fix

                      Function parseHeaders has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                          protected function parseHeaders(string $headerContent): array
                          {
                              $headers = [];
                              $headerParts = preg_split('/\\R/s', $headerContent, -1, PREG_SPLIT_NO_EMPTY);
                              foreach ($headerParts as $headerPart) {
                      Severity: Minor
                      Found in src/Testing/FormDataParser.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

                      Method resolveHandlers has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected function resolveHandlers(): array
                          {
                              $resolvedHandlers = [];
                              $updateType = $this->update?->getType();
                      
                      
                      Severity: Minor
                      Found in src/Handlers/ResolveHandlers.php - About 1 hr to fix

                        Method requestJson has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function requestJson(
                                string $endpoint,
                                array $json = [],
                                string $mapTo = stdClass::class,
                                array $options = []
                        Severity: Minor
                        Found in src/Telegram/Client.php - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language