The class Date has an overall complexity of 70 which is very high. The configured complexity threshold is 50. Open
class Date
{
public static $jsDateFormat = [
'dd-mm-yyyy' => 'd-m-Y',
'mm-dd-yyyy' => 'm-d-Y',
- Exclude checks
Function sanitizeDbFormat
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public static function sanitizeDbFormat(string $date, string $fromFormat)
{
$dbDate = '';
if ($date) {
[$y, $m, $d] = self::explode($date, $fromFormat);
- 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 formatToDb
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public static function formatToDb($value, $leadingZeros = false)
{
if ($leadingZeros) {
$delim = ['/', '.'];
foreach ($delim as $delimiter) {
- 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 explode
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public static function explode($date, $format = false)
{
if (empty($format)) {
$format = 'yyyy-mm-dd';
}
- 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 explode
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function explode($date, $format = false)
{
if (empty($format)) {
$format = 'yyyy-mm-dd';
}
Method sanitizeDbFormat
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function sanitizeDbFormat(string $date, string $fromFormat)
{
$dbDate = '';
if ($date) {
[$y, $m, $d] = self::explode($date, $fromFormat);
The method sanitizeDbFormat() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10. Open
public static function sanitizeDbFormat(string $date, string $fromFormat)
{
$dbDate = '';
if ($date) {
[$y, $m, $d] = self::explode($date, $fromFormat);
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method explode() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10. Open
public static function explode($date, $format = false)
{
if (empty($format)) {
$format = 'yyyy-mm-dd';
}
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
Missing class import via use statement (line '268', column '17'). Open
$query = (new \App\Db\Query())->from('vtiger_publicholiday');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '311', column '15'). Open
throw new \App\Exceptions\AppException('Exceeded the recursive limit, a loop might have been created.');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '168', column '15'). Open
return (new \DateTimeField($value))->getDBInsertDateValue();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '113', column '15'). Open
return (new \DateTimeField($value))->getDisplayDate();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method getDayFromDate has a boolean flag argument $shortName, which is a certain sign of a Single Responsibility Principle violation. Open
public static function getDayFromDate($date, $shortName = false, $translated = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method getShortDaysOfWeek has a boolean flag argument $byId, which is a certain sign of a Single Responsibility Principle violation. Open
public static function getShortDaysOfWeek(bool $byId = true)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method getDayFromDate has a boolean flag argument $translated, which is a certain sign of a Single Responsibility Principle violation. Open
public static function getDayFromDate($date, $shortName = false, $translated = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method getOnlyWorkingDayFromDate has a boolean flag argument $increase, which is a certain sign of a Single Responsibility Principle violation. Open
public static function getOnlyWorkingDayFromDate(\DateTime $date, int $counter, bool $increase = true, int $id = \App\Utils\BusinessHours::DEFAULT_BUSINESS_HOURS_ID): string
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method formatToDb has a boolean flag argument $leadingZeros, which is a certain sign of a Single Responsibility Principle violation. Open
public static function formatToDb($value, $leadingZeros = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method explode has a boolean flag argument $format, which is a certain sign of a Single Responsibility Principle violation. Open
public static function explode($date, $format = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method currentUserJSDateFormat has a boolean flag argument $format, which is a certain sign of a Single Responsibility Principle violation. Open
public static function currentUserJSDateFormat($format = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Avoid using static access to class '\App\Cache' in method 'getHolidays'. Open
if (\App\Cache::has('Date::getHolidays', $start . $end)) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method getShortDaysOfWeek uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$days[static::$shortDaysTranslations[$day]] = $id;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\App\Utils\BusinessHours' in method 'getWorkingDayFromDate'. Open
$businessHours = \App\Utils\BusinessHours::getBusinessHoursById($id);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Language' in method 'getDayFromDate'. Open
return \App\Language::translate(date($shortName ? 'D' : 'l', strtotime($date)), $shortName ? 'Vtiger' : 'Calendar');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Language' in method 'getHolidays'. Open
'day' => \App\Language::translate(date('l', strtotime($row['holidaydate'])), 'PublicHoliday'),
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Cache' in method 'getHolidays'. Open
return \App\Cache::get('Date::getHolidays', $start . $end);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The method sanitizeDbFormat uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$dbDate = $y . '-' . $m . '-' . $d;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\App\Cache' in method 'getHolidays'. Open
\App\Cache::save('Date::getHolidays', $start . $end, $holidays);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Define a constant instead of duplicating this literal "Date::getHolidays" 3 times. Open
if (\App\Cache::has('Date::getHolidays', $start . $end)) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "Y-m-d" 4 times. Open
'yyyy-mm-dd' => 'Y-m-d',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "mm-dd-yyyy" 3 times. Open
'mm-dd-yyyy' => 'm-d-Y',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "Tuesday" 3 times. Open
'Tuesday' => 2,
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "yyyy-mm-dd" 4 times. Open
'yyyy-mm-dd' => 'Y-m-d',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "Thursday" 3 times. Open
'Thursday' => 4,
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "holidaydate" 5 times. Open
$query->where(['between', 'holidaydate', $start, $end]);
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "Wednesday" 3 times. Open
'Wednesday' => 3,
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "Saturday" 3 times. Open
'Saturday' => 6,
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "dd-mm-yyyy" 3 times. Open
'dd-mm-yyyy' => 'd-m-Y',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "Sunday" 3 times. Open
'Sunday' => 0,
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "Monday" 3 times. Open
'Monday' => 1,
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "Friday" 3 times. Open
'Friday' => 5,
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Argument 1 (value)
is ?string
but \DateTimeField::__construct()
takes \type
defined at /code/include/fields/DateTimeField.php:31
Open
return (new \DateTimeField($value))->getDisplayDate();
- Exclude checks
Invalid offset true
of array type array{dd-mm-yyyy:'d-m-Y',mm-dd-yyyy:'m-d-Y',yyyy-mm-dd:'Y-m-d',dd.mm.yyyy:'d.m.Y',mm.dd.yyyy:'m.d.Y',yyyy.mm.dd:'Y.m.d',dd/mm/yyyy:'d/m/Y',mm/dd/yyyy:'m/d/Y',yyyy/mm/dd:'Y/m/d'}
Open
return static::$jsDateFormat[$format];
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$query = (new \App\Db\Query())->from('vtiger_publicholiday');
- Exclude checks
Argument 1 (value)
is string
but \DateTimeField::__construct()
takes \type
defined at /code/include/fields/DateTimeField.php:31
Open
return (new \DateTimeField($value))->getDBInsertDateValue();
- Exclude checks
Returning type null
but currentUserJSDateFormat()
is declared to return bool|string
Open
return static::$jsDateFormat[$format];
- Exclude checks
Call to method getCurrentUserModel
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
return static::$jsDateFormat[\App\User::getCurrentUserModel()->getDetail('date_format')] ?? false;
- Exclude checks
Avoid excessively long variable names like $shortDaysTranslations. Keep variable name length under 20. Open
public static $shortDaysTranslations = [
'Sunday' => 'LBL_SM_SUN',
'Monday' => 'LBL_SM_MON',
'Tuesday' => 'LBL_SM_TUE',
'Wednesday' => 'LBL_SM_WED',
- Read upRead up
- Exclude checks
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
Avoid variables with short names like $y. Configured minimum length is 3. Open
[$d, $m, $y] = array_pad(explode('-', $date, 3), 3, null);
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $x. Configured minimum length is 3. Open
$x = strpos($value, $delimiter);
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $id. Configured minimum length is 3. Open
public static function getOnlyWorkingDayFromDate(\DateTime $date, int $counter, bool $increase = true, int $id = \App\Utils\BusinessHours::DEFAULT_BUSINESS_HOURS_ID): string
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $m. Configured minimum length is 3. Open
&& ([$y, $m, $d] = self::explode($date, $format))
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $d. Configured minimum length is 3. Open
&& ([$y, $m, $d] = self::explode($date, $format))
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $m. Configured minimum length is 3. Open
[$y, $m, $d] = self::explode($date, $fromFormat);
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $y. Configured minimum length is 3. Open
&& ([$y, $m, $d] = self::explode($date, $format))
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $m. Configured minimum length is 3. Open
[$y, $m, $d] = explode('-', $value);
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $y. Configured minimum length is 3. Open
[$y, $m, $d] = self::explode($date, $fromFormat);
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $d. Configured minimum length is 3. Open
[$y, $m, $d] = self::explode($date, $fromFormat);
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $y. Configured minimum length is 3. Open
[$y, $m, $d] = explode('-', $value);
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $d. Configured minimum length is 3. Open
[$y, $m, $d] = explode('-', $value);
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $m. Configured minimum length is 3. Open
[$d, $m, $y] = array_pad(explode('-', $date, 3), 3, null);
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $d. Configured minimum length is 3. Open
[$d, $m, $y] = array_pad(explode('-', $date, 3), 3, null);
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $id. Configured minimum length is 3. Open
public static function getWorkingDayFromDate(\DateTime $date, string $modify, int $id = \App\Utils\BusinessHours::DEFAULT_BUSINESS_HOURS_ID): string
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Terminating statement must be indented to the same level as the CASE body Open
break;
- Exclude checks
Terminating statement must be indented to the same level as the CASE body Open
break;
- Exclude checks
Terminating statement must be indented to the same level as the CASE body Open
break;
- Exclude checks
Terminating statement must be indented to the same level as the CASE body Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return static::$jsDateFormat[$format];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Convert date from database format to user format.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Thursday' => 4,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool|string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Monday' => 1,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Wednesday' => 3,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Thursday' => 'LBL_SM_THU',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Saturday' => 'LBL_SM_SAT',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* As in the date value is on mm-dd-yyyy and user date format is dd-mm-yyyy then the mm-dd-yyyy
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function formatToDisplay($value)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return (new \DateTimeField($value))->getDisplayDate();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'mm-dd-yyyy' => 'm-d-Y',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Tuesday' => 2,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Wednesday' => 'LBL_SM_WED',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Friday' => 'LBL_SM_FRI',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* This function returns the date in user specified format.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'yyyy.mm.dd' => 'Y.m.d',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'dd/mm/yyyy' => 'd/m/Y',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static $dayOfWeekForJS = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Saturday' => 6,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* ISO-8601 numeric representation of the day of the week.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Tuesday' => 2,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Wednesday' => 3,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Saturday' => 6,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Thursday' => 4,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static $shortDaysTranslations = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return static::$jsDateFormat[\App\User::getCurrentUserModel()->getDetail('date_format')] ?? false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static $jsDateFormat = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Sunday' => 'LBL_SM_SUN',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'yyyy-mm-dd' => 'Y-m-d',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'mm.dd.yyyy' => 'm.d.Y',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Friday' => 5,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static $dayOfWeek = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Monday' => 'LBL_SM_MON',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Tuesday' => 'LBL_SM_TUE',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'mm/dd/yyyy' => 'm/d/Y',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'yyyy/mm/dd' => 'Y/m/d',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Sunday' => 7,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* limitation is that mm-dd-yyyy and dd-mm-yyyy will be considered same by this API.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* value will be return as the API will be considered as considered as in same format.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $value the date which should a changed to user date format
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Short days translations.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($format) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $range ['2018-02-03','2018-02-04']
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'dd.mm.yyyy' => 'd.m.Y',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Numeric representation of the day of the week.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* this due to the fact that this API tries to consider the where given date is in user date
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* format. we need a better gauge for this case.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$x = strpos($value, $delimiter);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (false !== $x) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[$m, $d, $y] = array_pad(explode('.', $date, 3), 3, null);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[$m, $d, $y] = array_pad(explode('/', $date, 3), 3, null);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $translated
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return date($shortName ? 'D' : 'l', strtotime($date));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \App\Cache::get('Date::getHolidays', $start . $end);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($range[0]) && !empty($range[1])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$y = '0' . $y;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'dd-mm-yyyy':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'mm-dd-yyyy':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (1 == \strlen($m)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (1 == \strlen($d)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $date
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->where(['between', 'holidaydate', $start, $end]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$holidays = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Convert date to single items.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array Array date list($y, $m, $d)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[$y, $m, $d] = array_pad(explode('.', $date, 3), 3, null);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Gets list of holidays.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'mm.dd.yyyy':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return [$y, $m, $d];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($start && $end) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get date value for db format.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = str_replace($delimiter, '-', $value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getDayFromDate($date, $shortName = false, $translated = false)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Sunday' => 0,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Monday' => 1,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Friday' => 5,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Current user JS date format.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($value) || '0000-00-00' === $value || '0000-00-00 00:00:00' === $value) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function formatRangeToDisplay($range)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::formatToDisplay($range[1]),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $leadingZeros
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = implode('-', [$y, $m, $d]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Line exceeds 120 characters; contains 128 characters Open
return \App\Language::translate(date($shortName ? 'D' : 'l', strtotime($date)), $shortName ? 'Vtiger' : 'Calendar');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getHolidays(string $start = '', string $end = ''): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($leadingZeros) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'yyyy/mm/dd':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get day from date or datetime.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::formatToDisplay($range[0]),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($delim as $delimiter) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
switch ($format) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'mm/dd/yyyy':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getShortDaysOfWeek(bool $byId = true)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $start
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\App\Cache::has('Date::getHolidays', $start . $end)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'dd-mm-yyyy' => 'd-m-Y',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @example date('N')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $format
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function currentUserJSDateFormat($format = false)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('now' === $value) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($format)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[$d, $m, $y] = array_pad(explode('-', $date, 3), 3, null);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[$y, $m, $d] = array_pad(explode('-', $date, 3), 3, null);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'dd/mm/yyyy':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[$y, $m, $d] = array_pad(explode('/', $date, 3), 3, null);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \App\Language::translate(date($shortName ? 'D' : 'l', strtotime($date)), $shortName ? 'Vtiger' : 'Calendar');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$days = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($byId) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$delim = ['/', '.'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $value Date
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$m = '0' . $m;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$d = '0' . $d;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function explode($date, $format = false)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$format = 'yyyy-mm-dd';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'yyyy-mm-dd':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
default:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach (static::$dayOfWeek as $day => $id) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\is_array($range)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (1 == \strlen($y)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($translated) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$days[static::$shortDaysTranslations[$day]] = $id;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $days;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->orderBy(['holidaydate' => SORT_ASC]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[$d, $m, $y] = array_pad(explode('.', $date, 3), 3, null);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[$d, $m, $y] = array_pad(explode('/', $date, 3), 3, null);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$days[$id] = static::$shortDaysTranslations[$day];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array|bool ['03.02.2018','04.02.2018'] or false
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function formatToDb($value, $leadingZeros = false)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $shortName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $byId associative array by day id
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $end
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query = (new \App\Db\Query())->from('vtiger_publicholiday');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[$y, $m, $d] = explode('-', $value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return (new \DateTimeField($value))->getDBInsertDateValue();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $date
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool|string $format Date format
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[$m, $d, $y] = array_pad(explode('-', $date, 3), 3, null);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'dd.mm.yyyy':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'yyyy.mm.dd':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get short days of week.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader = $query->createCommand()->query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $modify
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while ($counter-- > 0) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$formatToConvert = str_replace(['/', '.'], '-', $fromFormat);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'type' => $row['holidaytype'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \DateTime $date
- Exclude checks
Line exceeds 120 characters; contains 177 characters Open
public static function getOnlyWorkingDayFromDate(\DateTime $date, int $counter, bool $increase = true, int $id = \App\Utils\BusinessHours::DEFAULT_BUSINESS_HOURS_ID): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif (false !== strpos($date, '.')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
switch ($formatToConvert) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $date
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($businessHours['holidays'] ?? 1) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getOnlyWorkingDayFromDate(\DateTime $date, int $counter, bool $increase = true, int $id = \App\Utils\BusinessHours::DEFAULT_BUSINESS_HOURS_ID): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function isValid(string $date, ?string $format = null): bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getWorkingDayFromDate(\DateTime $date, string $modify, int $id = \App\Utils\BusinessHours::DEFAULT_BUSINESS_HOURS_ID): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while (isset($holidays[$value]) || !\in_array($date->format('N'), $workingDays)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = $date->format('Y-m-d');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$separator = '/';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($date) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[$y, $m, $d] = self::explode($date, $fromFormat);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$y || !$m || !$d) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif (false !== strpos($date, '/')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
default:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
&& ([$y, $m, $d] = self::explode($date, $format))
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Check if the date is correct.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return (false !== strpos($date, '-') || false !== strpos($date, '.') || false !== strpos($date, '/'))
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'name' => $row['holidayname'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::save('Date::getHolidays', $start . $end, $holidays);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $counter
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'dd-mm-yyyy':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = $date->modify($modify)->format('Y-m-d');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$iterator = 31;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Method to return date counted only using working days.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $value;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $fromFormat
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$separator = '-';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$separator = '.';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$holidays[$row['holidaydate']] = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'id' => $row['publicholidayid'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get closest working day from given data.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateToConvert = str_replace($separator, '-', $date);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[$m, $d, $y] = explode('-', $dateToConvert, 3);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while ($row = $dataReader->read()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $holidays;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$holidays = self::getHolidays();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function changes the date format to the database format without changing the time zone.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbDate = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[$y, $m, $d] = explode('-', $dateToConvert, 3);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'date' => $row['holidaydate'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader->close();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $value;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
&& checkdate($m, $d, $y) && strtotime("{$y}-{$m}-{$d}");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \DateTime $date
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'mm-dd-yyyy':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $id
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$businessHours = \App\Utils\BusinessHours::getBusinessHoursById($id);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$holidays = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\AppException('Exceeded the recursive limit, a loop might have been created.');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $increase
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $date
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function sanitizeDbFormat(string $date, string $fromFormat)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbDate = $y . '-' . $m . '-' . $d;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $dbDate;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
&& is_numeric($m) && is_numeric($d) && is_numeric($y)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'day' => \App\Language::translate(date('l', strtotime($row['holidaydate'])), 'PublicHoliday'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$workingDays = explode(',', $businessHours['working_days'] ?? '1,2,3,4,5');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = $date->modify($modify[0] . '1 day')->format('Y-m-d');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string|null $format
- Exclude checks
Line exceeds 120 characters; contains 152 characters Open
public static function getWorkingDayFromDate(\DateTime $date, string $modify, int $id = \App\Utils\BusinessHours::DEFAULT_BUSINESS_HOURS_ID): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = self::getWorkingDayFromDate($date, ($increase ? '+' : '-') . '1 day', $id);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (false !== strpos($date, '-')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbDate = $y . '-' . $m . '-' . $d;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (0 === --$iterator) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $id
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[$d, $m, $y] = explode('-', $dateToConvert, 3);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'yyyy-mm-dd':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Line indented incorrectly; expected 20 spaces, found 16 Open
case 'yyyy-mm-dd':
- Exclude checks
Closing brace indented incorrectly; expected 16 spaces, found 12 Open
}
- Exclude checks
Line indented incorrectly; expected 20 spaces, found 16 Open
default:
- Exclude checks
Line indented incorrectly; expected 20 spaces, found 16 Open
case 'mm-dd-yyyy':
- Exclude checks
Line indented incorrectly; expected 20 spaces, found 16 Open
case 'dd-mm-yyyy':
- Exclude checks
Line indented incorrectly; expected at least 24 spaces, found 20 Open
[$y, $m, $d] = explode('-', $dateToConvert, 3);
- Exclude checks
Line indented incorrectly; expected at least 24 spaces, found 20 Open
[$m, $d, $y] = explode('-', $dateToConvert, 3);
- Exclude checks
Line indented incorrectly; expected 16 spaces, found 12 Open
}
- Exclude checks
Line indented incorrectly; expected at least 24 spaces, found 20 Open
[$d, $m, $y] = explode('-', $dateToConvert, 3);
- Exclude checks