davide-casiraghi/laravel-events-calendar

View on GitHub
src/LaravelEventsCalendar.php

Summary

Maintainability
C
1 day
Test Coverage

File LaravelEventsCalendar.php has 320 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace DavideCasiraghi\LaravelEventsCalendar;

use Carbon\Carbon;
Severity: Minor
Found in src/LaravelEventsCalendar.php - About 3 hrs to fix

    Method decodeOnMonthlyKind has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function decodeOnMonthlyKind(string $onMonthlyKindCode)
        {
            $ret = '';
            $onMonthlyKindCodeArray = explode('|', $onMonthlyKindCode);
            $weekDays = [
    Severity: Minor
    Found in src/LaravelEventsCalendar.php - About 1 hr to fix

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

          public static function getRepetitionTextString(Event $event, EventRepetition $firstRpDates)
          {
              $ret = '';
      
              switch ($event->repeat_type) {
      Severity: Minor
      Found in src/LaravelEventsCalendar.php - About 1 hr to fix

        Method getMapMarkerIconColor has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function getMapMarkerIconColor(int $eventCategoryId)
            {
                $ret = '';
                switch ($eventCategoryId) {
                    case 1: //Regular Jam
        Severity: Minor
        Found in src/LaravelEventsCalendar.php - About 1 hr to fix

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

              public static function getMapMarkerIconColor(int $eventCategoryId)
              {
                  $ret = '';
                  switch ($eventCategoryId) {
                      case 1: //Regular Jam
          Severity: Minor
          Found in src/LaravelEventsCalendar.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 cleanString has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function cleanString(string $text)
              {
                  // Transform whitespaces to %20 for the URL
                  $text = str_replace(' ', '%20', $text);
                  $text = str_replace('ß', '%DF', $text);
          Severity: Minor
          Found in src/LaravelEventsCalendar.php - About 1 hr to fix

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

                public static function uploadImageOnServer($imageFile, string $imageName, string $imageSubdir, int $imageWidth, int $thumbWidth): void
            Severity: Minor
            Found in src/LaravelEventsCalendar.php - About 35 mins to fix

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

                  public static function getRepetitionTextString(Event $event, EventRepetition $firstRpDates)
                  {
                      $ret = '';
              
                      switch ($event->repeat_type) {
              Severity: Minor
              Found in src/LaravelEventsCalendar.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

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

                  public static function weekOfMonthFromTheEnd(int $when)
                  {
                      $numberOfDayOfTheMonth = strftime('%e', $when); // Day of the month 1-31
                      $lastDayOfMonth = strftime('%e', strtotime(date('Y-m-t', $when))); // the last day of the month of the specified date
                      $dayDifference = (int) $lastDayOfMonth - (int) $numberOfDayOfTheMonth;
              Severity: Minor
              Found in src/LaravelEventsCalendar.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

              There are no issues that match your filters.

              Category
              Status