File LaravelEventsCalendar.php
has 320 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace DavideCasiraghi\LaravelEventsCalendar;
use Carbon\Carbon;
Method decodeOnMonthlyKind
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function decodeOnMonthlyKind(string $onMonthlyKindCode)
{
$ret = '';
$onMonthlyKindCodeArray = explode('|', $onMonthlyKindCode);
$weekDays = [
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) {
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
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
- 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
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);
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
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) {
- 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
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;
- 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"