Method formatDateDiffInStrings
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function formatDateDiffInStrings($dateTime)
{
// http://www.php.net/manual/en/datetime.diff.php#101029
$seconds = strtotime('now') - strtotime($dateTime);
if (0 === $seconds) {
Function formatDateIntoStrings
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public static function formatDateIntoStrings($date, $time = false)
{
$currentUser = Users_Record_Model::getCurrentUserModel();
$dateTimeInUserFormat = App\Fields\DateTime::formatToDisplay($date . ' ' . $time);
- 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 formatDateIntoStrings
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function formatDateIntoStrings($date, $time = false)
{
$currentUser = Users_Record_Model::getCurrentUserModel();
$dateTimeInUserFormat = App\Fields\DateTime::formatToDisplay($date . ' ' . $time);
Function formatDateDiffInStrings
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public static function formatDateDiffInStrings($dateTime)
{
// http://www.php.net/manual/en/datetime.diff.php#101029
$seconds = strtotime('now') - strtotime($dateTime);
if (0 === $seconds) {
- 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
Avoid too many return
statements within this method. Open
return $prefix . self::pluralize($months, 'LBL_MONTH') . $suffix;
Avoid too many return
statements within this method. Open
return $prefix . self::pluralize($days, 'LBL_DAY') . $suffix;
Avoid too many return
statements within this method. Open
return $prefix . $result . $suffix;
The method formatDateDiffInStrings() has an NPath complexity of 576. The configured NPath complexity threshold is 200. Open
public static function formatDateDiffInStrings($dateTime)
{
// http://www.php.net/manual/en/datetime.diff.php#101029
$seconds = strtotime('now') - strtotime($dateTime);
if (0 === $seconds) {
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method formatDateDiffInStrings() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10. Open
public static function formatDateDiffInStrings($dateTime)
{
// http://www.php.net/manual/en/datetime.diff.php#101029
$seconds = strtotime('now') - strtotime($dateTime);
if (0 === $seconds) {
- 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 returns of this function 7, down to the maximum allowed 3. Open
public static function formatDateDiffInStrings($dateTime)
- Read upRead up
- Exclude checks
Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.
Noncompliant Code Example
With the default threshold of 3:
function myFunction(){ // Noncompliant as there are 4 return statements if (condition1) { return true; } else { if (condition2) { return false; } else { return true; } } return false; }
The method formatDateIntoStrings has a boolean flag argument $time, which is a certain sign of a Single Responsibility Principle violation. Open
public static function formatDateIntoStrings($date, $time = 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
Missing class import via use statement (line '166', column '15'). Open
return (new \App\Db\Query())->from('vtiger_currency_info')->where(['<', 'defaultid', '0'])->one();
- 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 '225', column '15'). Open
return (new App\Db\Query())->from('vtiger_users')
- 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
Avoid using static access to class '\App\Language' in method 'formatDateIntoStrings'. Open
$dayInfo = \App\Language::translate('LBL_' . date('D', $date));
- 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 'formatDateDiffInStrings'. Open
return \App\Language::translate('LBL_JUSTNOW');
- 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 'DateTimeField' in method 'formatDateIntoStrings'. Open
$userDate = DateTimeField::__convertToUserFormat($date, $currentUser->get('date_format'));
- 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 'pluralize'. Open
return $count . ' ' . ((1 === $count) ? \App\Language::translate("$text") : \App\Language::translate("{$text}S"));
- 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 'Vtiger_Time_UIType' in method 'formatDateIntoStrings'. Open
$displayTime = Vtiger_Time_UIType::getTimeValueInAMorPM($displayTime);
- 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 'formatDateIntoStrings'. Open
$todayInfo .= ' ' . \App\Language::translate('LBL_AT') . ' ' . $displayTime;
- 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 'formatDateIntoStrings'. Open
$tomorrowInfo = \App\Language::translate('LBL_TOMORROW');
- 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 'pluralize'. Open
return $count . ' ' . ((1 === $count) ? \App\Language::translate("$text") : \App\Language::translate("{$text}S"));
- 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\Config' in method 'getActiveAdminCurrentDateTime'. Open
$default_timezone = \App\Config::main('default_timezone');
- 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 'formatDateDiffInStrings'. Open
$suffix = ' ' . \App\Language::translate('LBL_AGO');
- 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 'formatDateIntoStrings'. Open
$dayInfo .= ' ' . \App\Language::translate('LBL_AT') . ' ' . $displayTime;
- 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 formatDateIntoStrings uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
if ('mm-dd-yyyy' === $currentUser->get('date_format')) {
$dateInUserFormat = str_replace('-', '/', $dateInUserFormat);
}
$date = strtotime($dateInUserFormat);
- 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 'Users' in method 'getActiveAdminCurrentDateTime'. Open
$admin = Users::getActiveAdminUser();
- 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 'formatDateIntoStrings'. Open
$todayInfo = \App\Language::translate('LBL_TODAY');
- 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 'Users_Privileges_Model' in method 'convertTimeIntoUsersDisplayFormat'. Open
$userModel = Users_Privileges_Model::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
Avoid using static access to class '\App\Language' in method 'formatDateDiffInStrings'. Open
$prefix = \App\Language::translate('LBL_DUE') . ' ';
- 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\Fields\Date' in method 'formatDateIntoStrings'. Open
$today = App\Fields\Date::formatToDisplay(date('Y-m-d H:i:s'));
- 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 'formatDateIntoStrings'. Open
$tomorrowInfo .= ' ' . \App\Language::translate('LBL_AT') . ' ' . $displayTime;
- 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\Fields\DateTime' in method 'formatDateIntoStrings'. Open
$dateTimeInUserFormat = App\Fields\DateTime::formatToDisplay($date . ' ' . $time);
- 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 convertTimeIntoUsersDisplayFormat uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$userModel = Users_Privileges_Model::getCurrentUserModel();
}
- 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 'Users_Record_Model' in method 'formatDateIntoStrings'. Open
$currentUser = Users_Record_Model::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
Avoid using static access to class 'App\Fields\Date' in method 'formatDateIntoStrings'. Open
$tomorrow = App\Fields\Date::formatToDisplay(date('Y-m-d H:i:s', strtotime('tomorrow')));
- 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 'Vtiger_Time_UIType' in method 'convertTimeIntoUsersDisplayFormat'. Open
$time = Vtiger_Time_UIType::getTimeValueInAMorPM($time);
- 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 'Users_Privileges_Model' in method 'convertTimeIntoUsersDisplayFormat'. Open
$userModel = Users_Privileges_Model::getInstanceFromUserObject($userObject);
- 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 "Y-m-d H:i:s" 3 times. Open
$today = App\Fields\Date::formatToDisplay(date('Y-m-d H:i:s'));
- 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 "LBL_AT" 3 times. Open
$todayInfo .= ' ' . \App\Language::translate('LBL_AT') . ' ' . $displayTime;
- 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 unextractable annotation for comment '* @param <vtiger_users_model> $userObject'</vtiger_users_model>
Open
* @param <Vtiger_Users_Model> $userObject
- Exclude checks
Saw unextractable annotation for comment '* @param <time> $time'</time>
Open
* @param <Time> $time
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
return (new App\Db\Query())->from('vtiger_users')
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
return (new \App\Db\Query())->from('vtiger_currency_info')->where(['<', 'defaultid', '0'])->one();
- Exclude checks
Reference to undeclared property \Users->time_zone
Open
$adminTimeZone = $admin->time_zone;
- Exclude checks
Saw unextractable annotation for comment '* @param <number> $count'</number>
Open
* @param <Number> $count
- Exclude checks
Saw unextractable annotation for comment '* @param <time> $time'</time>
Open
* @param <Time> $time
- Exclude checks
Saw unextractable annotation for comment '* @param <date> $date'</date>
Open
* @param <Date> $date
- Exclude checks
Saw unextractable annotation for comment '* @param <date time> $dateTime'</date>
Open
* @param <Date Time> $dateTime
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Vtiger_Util_Helper
- Exclude checks
The class Vtiger_Util_Helper is not named in CamelCase. Open
class Vtiger_Util_Helper
{
/**
* Function parses date into readable format.
*
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
Spaces must be used to indent lines; tabs are not allowed Open
* Function parses date into readable format.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ($seconds < 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$hours = floor($minutes / 60);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$monthAgo = self::pluralize($month, 'LBL_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
$seconds = strtotime('now') - strtotime($dateTime);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$minutes = floor($seconds / 60);
- 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 $prefix . self::pluralize($days, 'LBL_DAY') . $suffix;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $prefix . self::pluralize($months, 'LBL_MONTH') . $suffix;
- 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 ($seconds > 0) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($minutes < 60) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$month = $months % 12;
- 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 \App\Language::translate('LBL_JUSTNOW');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($seconds < 60) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$prefix = \App\Language::translate('LBL_DUE') . ' ';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($months > 11) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = self::pluralize(floor($months / 12), 'LBL_YEAR') . ' ' . $monthAgo;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param <Date Time> $dateTime
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (0 === $seconds) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $prefix . self::pluralize($seconds, 'LBL_SECOND') . $suffix;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $prefix . self::pluralize($hours, 'LBL_HOUR') . $suffix;
- 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
[$dateInUserFormat, $timeInUserFormat] = explode(' ', $dateTimeInUserFormat);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($time) {
- 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 str_replace(' ', '_', $string);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function decodes the utf-8 characters.
- 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 convertTimeIntoUsersDisplayFormat($time, $userObject = 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
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$prefix = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$suffix = ' ' . \App\Language::translate('LBL_AGO');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$days = floor($hours / 24);
- 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
$dateTimeInUserFormat = App\Fields\DateTime::formatToDisplay($date . ' ' . $time);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$userDate = DateTimeField::__convertToUserFormat($date, $currentUser->get('date_format'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($time) {
- 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 replace spaces with under scores.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param <Time> $time
- 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
$suffix = '';
- 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 <Time> $time
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$displayTime = Vtiger_Time_UIType::getTimeValueInAMorPM($displayTime);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$formatedDate = $userDate . " ($tomorrowInfo)";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dayInfo = \App\Language::translate('LBL_' . date('D', $date));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
date_default_timezone_set($default_timezone);
- 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
->andWhere(['or', ['deleted' => 1], ['status' => 'Inactive']])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($months < 12) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$monthAgo = '';
- 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 $count . ' ' . ((1 === $count) ? \App\Language::translate("$text") : \App\Language::translate("{$text}S"));
- 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
$displayTime = $hours . ':' . $minutes;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($time) {
- 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
if ($userObject) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function isUserDeleted($userid)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function formatDateDiffInStrings($dateTime)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$seconds = -($seconds);
- 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
$months = floor($days / 30);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $prefix . self::pluralize($minutes, 'LBL_MINUTE') . $suffix;
- 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 ($hours < 24) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($days < 30) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function pluralize($count, $text)
- 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
date_default_timezone_set($adminTimeZone);
- 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 ('12' === $userModel->get('hour_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
if (0 !== $month) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $prefix . $result . $suffix;
- 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 <Number> $count
- 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 toVtiger6SafeHTML($input)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('12' === $currentUser->get('hour_format')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$formatedDate = $userDate . " ($todayInfo)";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dateInUserFormat = str_replace('-', '/', $dateInUserFormat);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$date = strtotime($dateInUserFormat);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dayInfo .= ' ' . \App\Language::translate('LBL_AT') . ' ' . $displayTime;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$formatedDate = $userDate . " ($dayInfo)";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function replaceSpaceWithUnderScores($string)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$userModel = Users_Privileges_Model::getCurrentUserModel();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['id' => $userid])
- 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
$currentUser = Users_Record_Model::getCurrentUserModel();
- 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
}
- 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
* Function to get the time value in user preferred hour format.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$userModel = Users_Privileges_Model::getInstanceFromUserObject($userObject);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$time = Vtiger_Time_UIType::getTimeValueInAMorPM($time);
- 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
// http://www.php.net/manual/en/datetime.diff.php#101029
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
return $count . ' ' . ((1 === $count) ? \App\Language::translate("$text") : \App\Language::translate("{$text}S"));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $input - html data
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to parses date into string format.
- 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
public static function getBaseCurrency()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getDecodedValue($string)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$default_timezone = \App\Config::main('default_timezone');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$date = date('Y-m-d H:i:s');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $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
return (new App\Db\Query())->from('vtiger_users')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $text
- 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
$today = App\Fields\Date::formatToDisplay(date('Y-m-d H:i:s'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($dateInUserFormat == $today) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$todayInfo .= ' ' . \App\Language::translate('LBL_AT') . ' ' . $displayTime;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tomorrowInfo = \App\Language::translate('LBL_TOMORROW');
- 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 $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
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tomorrowInfo .= ' ' . \App\Language::translate('LBL_AT') . ' ' . $displayTime;
- 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 html_entity_decode($string, ENT_COMPAT, 'UTF-8');
- 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 <Vtiger_Users_Model> $userObject
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getAllSkins()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function returns singular or plural text.
- 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 ('mm-dd-yyyy' === $currentUser->get('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
} else {
- 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
* Function that will strip all the tags while displaying.
- 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 getActiveAdminCurrentDateTime()
- 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 time with hour format
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'gray' => '#d1d1db',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->exists();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$allowableTags = '<a><br />';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function formatDateIntoStrings($date, $time = false)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[$hours, $minutes] = explode(':', $timeInUserFormat);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tomorrow = App\Fields\Date::formatToDisplay(date('Y-m-d H:i:s', strtotime('tomorrow')));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $formatedDate;
- 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 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
$admin = Users::getActiveAdminUser();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'blue' => '#0078d4',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return strip_tags($input, $allowableTags);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param <Date> $date
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$todayInfo = \App\Language::translate('LBL_TODAY');
- 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 gets the CRM's base Currency information.
- 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
$adminTimeZone = $admin->time_zone;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $time;
- 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 vtiger6 displayable data
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ($dateInUserFormat == $tomorrow) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return (new \App\Db\Query())->from('vtiger_currency_info')->where(['<', 'defaultid', '0'])->one();
- 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
'twilight' => '#404952',
- Exclude checks
Class name "Vtiger_Util_Helper" is not in camel caps format Open
class Vtiger_Util_Helper
- Exclude checks
The variable $default_timezone is not named in camelCase. Open
public static function getActiveAdminCurrentDateTime()
{
$default_timezone = \App\Config::main('default_timezone');
$admin = Users::getActiveAdminUser();
$adminTimeZone = $admin->time_zone;
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $default_timezone is not named in camelCase. Open
public static function getActiveAdminCurrentDateTime()
{
$default_timezone = \App\Config::main('default_timezone');
$admin = Users::getActiveAdminUser();
$adminTimeZone = $admin->time_zone;
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}