Method getDateRangeByType
has 193 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getDateRangeByType($type, $dateObject = null)
{
$currentUser = \App\User::getCurrentUserModel();
$weekStartDay = $currentUser->getDetail('dayoftheweek');
Function getDateRangeByType
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
public static function getDateRangeByType($type, $dateObject = null)
{
$currentUser = \App\User::getCurrentUserModel();
$weekStartDay = $currentUser->getDetail('dayoftheweek');
- 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
File DateTimeRange.php
has 314 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Date time range class.
*
* @copyright YetiForce S.A.
The class DateTimeRange has an overall complexity of 69 which is very high. The configured complexity threshold is 50. Open
class DateTimeRange
{
/** Function that converts string to dates.
* @param $type :: type string
* @param mixed|null $dateObject
- Exclude checks
Function getPresentQuarterRange
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function getPresentQuarterRange($month = 0, &$dateObject = null)
{
$quarter = [];
if (!$month) {
$month = date('n');
- 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 getNextQuarterRange
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function getNextQuarterRange($month = 0, $dateObject = null)
{
$quarter = [];
if (!$month) {
$month = date('n');
- 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 getPreviousQuarterRange
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function getPreviousQuarterRange($month = 0, &$dateObject = null)
{
$quarter = [];
if (!$month) {
$month = date('n');
- 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
The method getDateRangeByType() has 197 lines of code. Current threshold is set to 100. Avoid really long methods. Open
public static function getDateRangeByType($type, $dateObject = null)
{
$currentUser = \App\User::getCurrentUserModel();
$weekStartDay = $currentUser->getDetail('dayoftheweek');
- Exclude checks
The method getDateRangeByType() has a Cyclomatic Complexity of 36. The configured cyclomatic complexity threshold is 10. Open
public static function getDateRangeByType($type, $dateObject = null)
{
$currentUser = \App\User::getCurrentUserModel();
$weekStartDay = $currentUser->getDetail('dayoftheweek');
- 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
Reduce the number of switch cases from 31 to at most 30. Open
switch ($type) {
- Read upRead up
- Exclude checks
When switch
statements have large sets of case
clauses, it is usually an attempt to map two sets of data. A real map
structure would be more readable and maintainable, and should be used instead.
This function "getDateRangeByType" has 196 lines, which is greater than the 150 lines authorized. Split it into smaller functions. Open
public static function getDateRangeByType($type, $dateObject = null)
- Read upRead up
- Exclude checks
A function that grows too large tends to aggregate too many responsibilities.
Such functions inevitably become harder to understand and therefore harder to maintain.
Above a specific threshold, it is strongly advised to refactor into smaller functions which focus on well-defined tasks.
Those smaller functions will not only be easier to understand, but also probably easier to test.
Missing class import via use statement (line '38', column '22'). Open
$dateObject = new DateTime($dateObject);
- 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 '296', column '22'). Open
$dateObject = new DateTime();
- 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 '35', column '22'). Open
$dateObject = new DateTime();
- 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 '253', column '22'). Open
$dateObject = new DateTime();
- 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 '236', column '22'). Open
$dateObject = new DateTime();
- 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 '238', column '22'). Open
$dateObject = new DateTime($dateObject);
- 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 '272', column '22'). Open
$dateObject = new DateTime();
- 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 '274', column '22'). Open
$dateObject = new DateTime($dateObject);
- 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 '255', column '22'). Open
$dateObject = new DateTime($dateObject);
- 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 '330', column '22'). Open
$dateObject = new DateTime();
- 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 '365', column '22'). Open
$dateObject = new DateTime();
- 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 '34', column '20'). Open
$timeZone = new DateTimeZone($currentUser->getDetail('time_zone'));
- 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 getNextQuarterRange uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else { // 4th Quarter - October - December
$dateObject->modify('next year');
$quarter[0] = $dateObject->format('Y-01-01');
$quarter[1] = $dateObject->format('Y-03-31');
}
- 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\Fields\Date' in method 'getDateRangeByType'. Open
$dateValue[0] = \App\Fields\Date::getWorkingDayFromDate($todayObject, '-1 day');
- 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 getDateRangeByType uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$dateObject->modify('-1 week ' . $weekStartDay);
}
- 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
The method getPresentQuarterRange uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else { // 4th Quarter - October - December
$quarter[0] = $dateObject->format('Y-10-01');
$quarter[1] = $dateObject->format('Y-12-31');
}
- 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
The method getPreviousQuarterRange uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else { // 4th Quarter - October - December
$quarter[0] = $dateObject->format('Y-07-01');
$quarter[1] = $dateObject->format('Y-09-30');
}
- 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\Fields\Date' in method 'getDateRangeByType'. Open
$dateValue[0] = \App\Fields\Date::getWorkingDayFromDate($todayObject, '+1 day');
- 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\User' in method 'getDateRangeByType'. Open
$currentUser = \App\User::getCurrentUserModel();
- 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 getDateRangeByType uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$dateObject->modify('this ' . $weekStartDay);
}
- 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
The method getDateRangeByType uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$dateObject->modify('-2 week ' . $weekStartDay);
}
- 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
Define a constant instead of duplicating this literal "Y-m-d" 22 times. Open
$today = $todayObject->format('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 "Y-09-30" 3 times. Open
$quarter[1] = $dateObject->format('Y-09-30');
- 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-07-01" 3 times. Open
$quarter[0] = $dateObject->format('Y-07-01');
- 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-10-01" 3 times. Open
$quarter[0] = $dateObject->format('Y-10-01');
- 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-03-31" 3 times. Open
$quarter[1] = $dateObject->format('Y-03-31');
- 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-01-01" 6 times. Open
return [$dateObject->format('Y-01-01'), $dateObject->format('Y-12-31')];
- 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-01" 3 times. Open
$currentMonthStart = $dateObject->format('Y-m-01');
- 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-t" 3 times. Open
$currentMonthEnd = $dateObject->format('Y-m-t');
- 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-12-31" 6 times. Open
return [$dateObject->format('Y-01-01'), $dateObject->format('Y-12-31')];
- 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-04-01" 3 times. Open
$quarter[0] = $dateObject->format('Y-04-01');
- 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-06-30" 3 times. Open
$quarter[1] = $dateObject->format('Y-06-30');
- 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 "+6 days" 4 times. Open
$dateObject->modify('+6 days');
- 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.
Saw misspelled annotation @returns.
Did you mean @return?
Open
* @returns $dateValue array in the following format
- Exclude checks
Variable $dateValue
was undeclared, but array fields are being added to it. Open
$dateValue[0] = $yesterday;
- Exclude checks
Variable $dateValue
was undeclared, but array fields are being added to it. Open
$dateValue[0] = \App\Fields\Date::getWorkingDayFromDate($todayObject, '+1 day');
- Exclude checks
Return type of getNextQuarterRange()
is undeclared type \date
Open
public static function getNextQuarterRange($month = 0, $dateObject = null)
- Exclude checks
Variable $dateValue
was undeclared, but array fields are being added to it. Open
$dateValue[0] = $thisWeekStart;
- Exclude checks
Return type of getPreviousYearRange()
is undeclared type \date
Open
public static function getPreviousYearRange(&$dateObject = null)
- Exclude checks
Variable $dateValue
was undeclared, but array fields are being added to it. Open
$dateValue[0] = $lastWeekStart;
- Exclude checks
Variable $dateValue
was undeclared, but array fields are being added to it. Open
$dateValue[0] = $today;
- Exclude checks
Return type of getPresentYearRange()
is undeclared type \date
Open
public static function getPresentYearRange(&$dateObject = null)
- Exclude checks
Variable $dateValue
was undeclared, but array fields are being added to it. Open
$dateValue[0] = $last60days;
- Exclude checks
Call to method getCurrentUserModel
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$currentUser = \App\User::getCurrentUserModel();
- Exclude checks
Variable $dateValue
was undeclared, but array fields are being added to it. Open
$dateValue[0] = $last7days;
- Exclude checks
Variable $dateValue
was undeclared, but array fields are being added to it. Open
$dateValue[0] = $last90days;
- Exclude checks
Argument 1 (month)
is string
but \DateTimeRange::getPreviousQuarterRange()
takes int
defined at /code/include/fields/DateTimeRange.php:323
Open
$dateValue = self::getPreviousQuarterRange($thisMonth, $dateObject);
- Exclude checks
Returning type array{0:string,1:string}
but getPreviousYearRange()
is declared to return \date
Open
return [$dateObject->format('Y-01-01'), $dateObject->format('Y-12-31')];
- Exclude checks
Returning type array{1:string,0:string}
but getPresentQuarterRange()
is declared to return \date
Open
return $quarter;
- Exclude checks
Return type of getPreviousQuarterRange()
is undeclared type \date
Open
public static function getPreviousQuarterRange($month = 0, &$dateObject = null)
- Exclude checks
Variable $dateValue
was undeclared, but array fields are being added to it. Open
$dateValue[0] = $today;
- Exclude checks
Variable $dateValue
was undeclared, but array fields are being added to it. Open
$dateValue[0] = $today;
- Exclude checks
Variable $dateValue
was undeclared, but array fields are being added to it. Open
$dateValue[0] = '';
- Exclude checks
Variable $dateValue
was undeclared, but array fields are being added to it. Open
$dateValue[0] = $tomorrow;
- Exclude checks
Variable $dateValue
was undeclared, but array fields are being added to it. Open
$dateValue[0] = date('Y-m-d', strtotime(0));
- Exclude checks
Argument 1 (month)
is string
but \DateTimeRange::getPresentQuarterRange()
takes int
defined at /code/include/fields/DateTimeRange.php:289
Open
$dateValue = self::getPresentQuarterRange($thisMonth, $dateObject);
- Exclude checks
Variable $dateValue
was undeclared, but array fields are being added to it. Open
$dateValue[0] = \App\Fields\Date::getWorkingDayFromDate($todayObject, '-1 day');
- Exclude checks
Returning type array{1:string,0:string}
but getPreviousQuarterRange()
is declared to return \date
Open
return $quarter;
- Exclude checks
Variable $dateValue
was undeclared, but array fields are being added to it. Open
$dateValue[0] = $nextMonthStart;
- Exclude checks
Variable $dateValue
was undeclared, but array fields are being added to it. Open
$dateValue[0] = $today;
- Exclude checks
Variable $dateValue
was undeclared, but array fields are being added to it. Open
$dateValue[0] = $last30days;
- Exclude checks
Variable $dateValue
was undeclared, but array fields are being added to it. Open
$dateValue[0] = $today;
- Exclude checks
Variable $dateValue
was undeclared, but array fields are being added to it. Open
$dateValue[0] = $lastMonthStart;
- Exclude checks
Variable $dateValue
was undeclared, but array fields are being added to it. Open
$dateValue[0] = $today;
- Exclude checks
Variable $dateValue
was undeclared, but array fields are being added to it. Open
$dateValue[0] = $today;
- Exclude checks
Argument 1 (month)
is string
but \DateTimeRange::getNextQuarterRange()
takes int
defined at /code/include/fields/DateTimeRange.php:358
Open
$dateValue = self::getNextQuarterRange($thisMonth, $dateObject);
- Exclude checks
Variable $dateValue
was undeclared, but array fields are being added to it. Open
$dateValue[0] = $nextWeekStart;
- Exclude checks
Variable $dateValue
was undeclared, but array fields are being added to it. Open
$dateValue[0] = $last120days;
- Exclude checks
Returning type array{0:string,1:string}
but getPresentYearRange()
is declared to return \date
Open
return [$dateObject->format('Y-01-01'), $dateObject->format('Y-12-31')];
- Exclude checks
Returning type array{0:string,1:string}
but getNextYearRange()
is declared to return \date
Open
return [$dateObject->format('Y-01-01'), $dateObject->format('Y-12-31')];
- Exclude checks
Returning type array{1:string,0:string}
but getNextQuarterRange()
is declared to return \date
Open
return $quarter;
- Exclude checks
Variable $dateValue
was undeclared, but array fields are being added to it. Open
$dateValue[0] = $currentMonthStart;
- Exclude checks
Variable $dateValue
was undeclared, but array fields are being added to it. Open
$dateValue[0] = $last15days;
- Exclude checks
Argument 1 (time)
is 0
but \strtotime()
takes string
Open
$dateValue[0] = date('Y-m-d', strtotime(0));
- Exclude checks
Return type of getNextYearRange()
is undeclared type \date
Open
public static function getNextYearRange(&$dateObject = null)
- Exclude checks
Return type of getPresentQuarterRange()
is undeclared type \date
Open
public static function getPresentQuarterRange($month = 0, &$dateObject = null)
- Exclude checks
Similar blocks of code found in 3 locations. Consider refactoring. Open
if ($month <= 3) { // 1st Quarter - January - March
$dateObject->modify('last year');
$quarter[0] = $dateObject->format('Y-10-01');
$quarter[1] = $dateObject->format('Y-12-31');
} elseif ($month > 3 && $month <= 6) { // 2nd Quarter - April - June
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 101.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
if ($month <= 3) { // 1st Quarter - January - March
$quarter[0] = $dateObject->format('Y-04-01');
$quarter[1] = $dateObject->format('Y-06-30');
} elseif ($month > 3 && $month <= 6) { // 2nd Quarter - April - June
$quarter[0] = $dateObject->format('Y-07-01');
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 101.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
if ($month <= 3) { // 1st Quarter - January - March
$quarter[0] = $dateObject->format('Y-01-01');
$quarter[1] = $dateObject->format('Y-03-31');
} elseif ($month > 3 && $month <= 6) { // 2nd Quarter - April - June
$quarter[0] = $dateObject->format('Y-04-01');
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 101.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
case 'lastweek':
if ($todayName == $weekStartDay) {
$dateObject->modify('-1 week ' . $weekStartDay);
} else {
$dateObject->modify('-2 week ' . $weekStartDay);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 100.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
case 'thisweek':
if ($todayName == $weekStartDay) {
$dateObject->modify('-0 week ' . $weekStartDay);
} else {
$dateObject->modify('-1 week ' . $weekStartDay);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 100.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
case 'nextweek':
if ($todayName == $weekStartDay) {
$dateObject->modify('+1 week ' . $weekStartDay);
} else {
$dateObject->modify('this ' . $weekStartDay);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 100.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class DateTimeRange
- Exclude checks
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 20 and the first side effect is on line 8. Open
<?php
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[0] = $today;
- 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 'thisweek':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($todayName == $weekStartDay) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'lastweek':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$nextWeekEnd = $dateObject->format('Y-m-d');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[0] = $currentMonthStart;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[1] = $next15days;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[1] = $next60days;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$last7days = $dateObject->format('Y-m-d');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject->modify('-59 days');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'nextfy':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[0] = \App\Fields\Date::getWorkingDayFromDate($todayObject, '-1 day');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[0] = \App\Fields\Date::getWorkingDayFromDate($todayObject, '+1 day');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
switch ($type) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[1] = $today;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject->modify('-0 week ' . $weekStartDay);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[1] = $lastWeekEnd;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[1] = $lastMonthEnd;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[1] = $nextMonthEnd;
- 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
$dateObject->modify('-6 days');
- 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 'last90days':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$last90days = $dateObject->format('Y-m-d');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'prevfy':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** Function that converts string to dates.
- 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
$thisMonth = $dateObject->format('m');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject->modify('+6 days');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($todayName == $weekStartDay) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject->modify('-1 week ' . $weekStartDay);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject->modify('this ' . $weekStartDay);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$next15days = $dateObject->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
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'next120days':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'last7days':
- 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
$dateValue[0] = $last120days;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue = self::getPresentYearRange($dateObject);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'previousworkingday':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[1] = $dateValue[0];
- 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
$thisWeekEnd = $dateObject->format('Y-m-d');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$lastWeekEnd = $dateObject->format('Y-m-d');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject->modify('+6 days');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[0] = $nextWeekStart;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currentMonthEnd = $dateObject->format('Y-m-t');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject->modify('first day of last month');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[0] = $today;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject->modify('+59 days');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[0] = $today;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[0] = $last15days;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$last120days = $dateObject->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
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* $dateValue = Array(0=>$startdate,1=>$enddate)
- 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
$timeZone = new DateTimeZone($currentUser->getDetail('time_zone'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject->modify('last day');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'nextweek':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'nextmonth':
- 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 'nextworkingday':
- 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
$dateValue[1] = $tomorrow;
- 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
$dateValue[0] = $lastWeekStart;
- 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
$dateValue[1] = $nextWeekEnd;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$nextMonthStart = $dateObject->format('Y-m-01');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[0] = $today;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[0] = $today;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[1] = $today;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'last30days':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[1] = $today;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[0] = date('Y-m-d', strtotime(0));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[0] = $yesterday;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject->modify('-1 week ' . $weekStartDay);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($todayName == $weekStartDay) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[0] = $lastMonthStart;
- 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
$dateValue[1] = $next30days;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$last15days = $dateObject->format('Y-m-d');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[1] = $today;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue = self::getNextYearRange($dateObject);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'thisfq':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject->setTimezone($timeZone);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$todayObject = clone $dateObject;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tomorrow = $dateObject->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
$dateValue[0] = $thisWeekStart;
- 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
$dateValue[0] = $today;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$next90days = $dateObject->format('Y-m-d');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[1] = $next90days;
- 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 'last120days':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'yesterday':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject->modify('-2 week ' . $weekStartDay);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$lastMonthEnd = $dateObject->format('Y-m-t');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[0] = $nextMonthStart;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$next7days = $dateObject->format('Y-m-d');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject->modify('+14 days');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'next90days':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[1] = $today;
- 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 'nextfq':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue = self::getNextQuarterRange($thisMonth, $dateObject);
- 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 mixed|null $dateObject
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject = new DateTime();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$yesterday = $dateObject->format('Y-m-d');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject->modify('+1 week ' . $weekStartDay);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currentMonthStart = $dateObject->format('Y-m-01');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[0] = $last7days;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[1] = $today;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[0] = $last60days;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[1] = $today;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'prevfq':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue = self::getPreviousQuarterRange($thisMonth, $dateObject);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject = new DateTime($dateObject);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$today = $todayObject->format('Y-m-d');
- 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
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'thismonth':
- 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
$dateValue[1] = $next120days;
- 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
$todayName = $todayObject->format('l');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'tomorrow':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'next7days':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject->modify('+6 days');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[1] = $next7days;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'next15days':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject->modify('+29 days');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'next60days':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$next120days = $dateObject->format('Y-m-d');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject->modify('-14 days');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject->modify('-29 days');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject->modify('-119 days');
- 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
return $dateValue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject = new DateTime();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif (\is_string($dateObject)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject = new DateTime($dateObject);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$quarter[0] = $dateObject->format('Y-07-01');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$quarter[1] = $dateObject->format('Y-09-30');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else { // 4th Quarter - October - December
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$quarter[0] = $dateObject->format('Y-07-01');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param object $dateObject
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[0] = $tomorrow;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject->modify('+6 days');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'lastmonth':
- 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
$next30days = $dateObject->format('Y-m-d');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[0] = $last30days;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'last60days':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$last60days = $dateObject->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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param object|string $dateObject - date object or string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject = new DateTime();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else { // 4th Quarter - October - December
- 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
} elseif (\is_string($dateObject)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'today':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject->modify('tomorrow');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject->modify('first day of next month');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$nextMonthEnd = $dateObject->format('Y-m-t');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[0] = $today;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'next30days':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'last15days':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[1] = $today;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[0] = $last90days;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'thisfy':
- 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
$dateValue = self::getPresentQuarterRange($thisMonth, $dateObject);
- 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 $month
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return date range of present quarter
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$quarter[0] = $dateObject->format('Y-10-01');
- 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
* @returns $dateValue array in the following format
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getDateRangeByType($type, $dateObject = null)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$dateObject) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[1] = $yesterday;
- 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
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$next60days = $dateObject->format('Y-m-d');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject->modify('+89 days');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject->modify('+119 days');
- 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
if (!$dateObject) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return [$dateObject->format('Y-01-01'), $dateObject->format('Y-12-31')];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$quarter[1] = $dateObject->format('Y-06-30');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$quarter[1] = $dateObject->format('Y-09-30');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param $type :: type string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currentUser = \App\User::getCurrentUserModel();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$weekStartDay = $currentUser->getDetail('dayoftheweek');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$thisWeekStart = $dateObject->format('Y-m-d');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[1] = $thisWeekEnd;
- 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
$lastWeekStart = $dateObject->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
$nextWeekStart = $dateObject->format('Y-m-d');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[1] = $currentMonthEnd;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$lastMonthStart = $dateObject->format('Y-m-01');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$last30days = $dateObject->format('Y-m-d');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject->modify('-89 days');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'untiltoday':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue = self::getPreviousYearRange($dateObject);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[1] = $dateValue[0];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return date range of present year
- 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
$quarter[0] = $dateObject->format('Y-01-01');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ($month > 3 && $month <= 6) { // 2nd Quarter - April - June
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$quarter[1] = $dateObject->format('Y-06-30');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ($month > 6 && $month <= 9) { // 3rd Quarter - July - September
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $quarter;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$quarter[1] = $dateObject->format('Y-12-31');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getNextQuarterRange($month = 0, $dateObject = null)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$month) {
- 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
$dateObject->modify('next year');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getPreviousYearRange(&$dateObject = null)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$quarter = [];
- 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 ($month <= 3) { // 1st Quarter - January - March
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$quarter[0] = $dateObject->format('Y-07-01');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else { // 4th Quarter - October - December
- 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 [$dateObject->format('Y-01-01'), $dateObject->format('Y-12-31')];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get start and end date of next calendar year.
- 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 [$dateObject->format('Y-01-01'), $dateObject->format('Y-12-31')];
- 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 object|string $dateObject - date object or 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
$quarter[0] = $dateObject->format('Y-04-01');
- 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
$quarter[0] = $dateObject->format('Y-04-01');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ($month > 3 && $month <= 6) { // 2nd Quarter - April - June
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[1] = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get start and end date of past calendar year.
- 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 start and end date of present calendar quarter.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param object $dateObject
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return date range of present quarter
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject->modify('last year');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ($month > 6 && $month <= 9) { // 3rd Quarter - July - September
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get start and end date of next calendar quarter.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $month
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $quarter;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject = new DateTime();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get start and end date of present calendar year.
- 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
public static function getPresentQuarterRange($month = 0, &$dateObject = null)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$quarter[1] = $dateObject->format('Y-06-30');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $quarter;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject->modify('next year');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateValue[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
if (!$dateObject) {
- 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 (!$dateObject) {
- 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 start and end date of previous calendar quarter.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$quarter[1] = $dateObject->format('Y-12-31');
- 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 (!$dateObject) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject = new 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
$quarter[1] = $dateObject->format('Y-03-31');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param object $dateObject
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$quarter[0] = $dateObject->format('Y-04-01');
- 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 getPresentYearRange(&$dateObject = null)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getNextYearRange(&$dateObject = null)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif (\is_string($dateObject)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$month) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$quarter = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$month) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$dateObject) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($month <= 3) { // 1st Quarter - January - March
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$quarter[1] = $dateObject->format('Y-03-31');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return date range of present quarter
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$quarter = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ($month > 6 && $month <= 9) { // 3rd Quarter - July - September
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$quarter[0] = $dateObject->format('Y-10-01');
- 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
$dateObject->modify('last year');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($month <= 3) { // 1st Quarter - January - March
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$quarter[0] = $dateObject->format('Y-10-01');
- 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
$quarter[0] = $dateObject->format('Y-01-01');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif (\is_string($dateObject)) {
- 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 date range of past year
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject = new DateTime($dateObject);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject = new DateTime($dateObject);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return date range of next year
- 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
$quarter[1] = $dateObject->format('Y-12-31');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$month = date('n');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $month
- 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
$quarter[0] = $dateObject->format('Y-01-01');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ($month > 3 && $month <= 6) { // 2nd Quarter - April - June
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$quarter[1] = $dateObject->format('Y-09-30');
- 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
$month = date('n');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param object|string $dateObject - date object or 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
$dateObject = new DateTime();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getPreviousQuarterRange($month = 0, &$dateObject = 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
$month = date('n');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateObject = new DateTime();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$dateObject) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$quarter[1] = $dateObject->format('Y-03-31');
- Exclude checks