Function formatCurrencyValue
has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring. Open
private function formatCurrencyValue($value)
{
$currencyPattern = $this->currencyFormat;
$curSeparator = $this->currencySeparator;
$decSeparator = $this->decimalSeparator;
- 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 formatCurrencyValue
has 110 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function formatCurrencyValue($value)
{
$currencyPattern = $this->currencyFormat;
$curSeparator = $this->currencySeparator;
$decSeparator = $this->decimalSeparator;
The class CurrencyField has an overall complexity of 71 which is very high. The configured complexity threshold is 50. Open
class CurrencyField
{
private $CURRENCY_PATTERN_PLAIN = '123456789';
private $CURRENCY_PATTERN_SINGLE_GROUPING = '123456,789';
private $CURRENCY_PATTERN_THOUSAND_GROUPING = '123,456,789';
- Exclude checks
File CurrencyField.php
has 300 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/* +**********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
Function currencyDecimalFormat
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function currencyDecimalFormat($value, $user = null)
{
if (!$user) {
$user = \App\User::getCurrentUserModel();
}
- 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 $value;
Avoid too many return
statements within this method. Open
return $value;
The method formatCurrencyValue() has 152 lines of code. Current threshold is set to 100. Avoid really long methods. Open
private function formatCurrencyValue($value)
{
$currencyPattern = $this->currencyFormat;
$curSeparator = $this->currencySeparator;
$decSeparator = $this->decimalSeparator;
- Exclude checks
The method formatCurrencyValue() has an NPath complexity of 474320. The configured NPath complexity threshold is 200. Open
private function formatCurrencyValue($value)
{
$currencyPattern = $this->currencyFormat;
$curSeparator = $this->currencySeparator;
$decSeparator = $this->decimalSeparator;
- 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 formatCurrencyValue() has a Cyclomatic Complexity of 24. The configured cyclomatic complexity threshold is 10. Open
private function formatCurrencyValue($value)
{
$currencyPattern = $this->currencyFormat;
$curSeparator = $this->currencySeparator;
$decSeparator = $this->decimalSeparator;
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method currencyDecimalFormat() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
public function currencyDecimalFormat($value, $user = null)
{
if (!$user) {
$user = \App\User::getCurrentUserModel();
}
- 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
This function "formatCurrencyValue" has 151 lines, which is greater than the 150 lines authorized. Split it into smaller functions. Open
private function formatCurrencyValue($value)
- 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.
Reduce the number of returns of this function 5, down to the maximum allowed 3. Open
public function currencyDecimalFormat($value, $user = null)
- 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; }
Reduce the number of returns of this function 5, down to the maximum allowed 3. Open
private function formatCurrencyValue($value)
- 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; }
Refactor this function to reduce its Cognitive Complexity from 44 to the 15 allowed. Open
private function formatCurrencyValue($value)
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
The method convertToUserFormatSymbol has a boolean flag argument $currencySymbol, which is a certain sign of a Single Responsibility Principle violation. Open
public static function convertToUserFormatSymbol($value, $skipConversion = false, $currencySymbol = false, $skipFormatting = 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 '457', column '14'). Open
$id = (new \App\Db\Query())->select(['id'])->from('vtiger_currency_info')->where(['<', 'defaultid', 0])->scalar();
- 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 getDisplayValue has a boolean flag argument $skipFormatting, which is a certain sign of a Single Responsibility Principle violation. Open
public function getDisplayValue($user = null, $skipConversion = false, $skipFormatting = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method getDBInsertedValue has a boolean flag argument $skipConversion, which is a certain sign of a Single Responsibility Principle violation. Open
public function getDBInsertedValue($user = null, $skipConversion = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method convertToUserFormatSymbol has a boolean flag argument $skipFormatting, which is a certain sign of a Single Responsibility Principle violation. Open
public static function convertToUserFormatSymbol($value, $skipConversion = false, $currencySymbol = false, $skipFormatting = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method convertToDBFormat has a boolean flag argument $skipConversion, which is a certain sign of a Single Responsibility Principle violation. Open
public static function convertToDBFormat($value, $user = null, $skipConversion = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method getDisplayValueWithSymbol has a boolean flag argument $skipConversion, which is a certain sign of a Single Responsibility Principle violation. Open
public function getDisplayValueWithSymbol($user = null, $skipConversion = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method convertToUserFormat has a boolean flag argument $skipConversion, which is a certain sign of a Single Responsibility Principle violation. Open
public static function convertToUserFormat($value, $user = null, $skipConversion = false, $skipFormatting = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method convertToUserFormat has a boolean flag argument $skipFormatting, which is a certain sign of a Single Responsibility Principle violation. Open
public static function convertToUserFormat($value, $user = null, $skipConversion = false, $skipFormatting = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method getDisplayValue has a boolean flag argument $skipConversion, which is a certain sign of a Single Responsibility Principle violation. Open
public function getDisplayValue($user = null, $skipConversion = false, $skipFormatting = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method convertToUserFormatSymbol has a boolean flag argument $skipConversion, which is a certain sign of a Single Responsibility Principle violation. Open
public static function convertToUserFormatSymbol($value, $skipConversion = false, $currencySymbol = false, $skipFormatting = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
The method formatCurrencyValue uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$wholeNumberFirstPart = 0;
}
- 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\Double' in method 'currencyDecimalFormat'. Open
$value = \App\Fields\Double::truncateZeros($value);
- 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\Currency' in method 'initialize'. Open
$currencyData = \App\Fields\Currency::getById($this->currencyId);
- 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 formatCurrencyValue uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$numericParts[0] = $wholeNumberLastPart;
}
- 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\User' in method 'getDisplayValue'. Open
$user = \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
Avoid using static access to class '\App\User' in method 'currencyDecimalFormat'. Open
$user = \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
Avoid using static access to class '\App\User' in method 'initialize'. Open
$user = \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 formatCurrencyValue uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$sign = '';
}
- 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 formatCurrencyValue uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$numericParts[0] = $wholeNumberLastPart;
}
- 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\Config' in method 'initialize'. Open
$defaultCharset = App\Config::main('default_charset');
- 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\Purifier' in method 'currencyDecimalFormat'. Open
$fieldValue = explode(App\Purifier::decodeHtml($decSeparator), $value);
- 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 'getDBInsertedValue'. Open
$user = \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 initialize uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->currencyId = self::getDBCurrencyId();
}
- 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 formatCurrencyValue uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$numericParts[0] = 0;
}
- 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 "currency_decimal_separator" 3 times. Open
$this->decimalSeparator = str_replace("\xC2\xA0", ' ', html_entity_decode($user->getDetail('currency_decimal_separator'), ENT_QUOTES, $defaultCharset));
- 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 "no_of_currency_decimals" 3 times. Open
$this->numberOfDecimal = (empty($user->getDetail('no_of_currency_decimals')) && 0 !== (int) $user->getDetail('no_of_currency_decimals')) ? 2 : (int) $user->getDetail('no_of_currency_decimals');
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Argument 1 (value)
is false|float|int|string
but \CurrencyField::__construct()
takes \Number
defined at /code/include/fields/CurrencyField.php:92
Open
$self = new self($value);
- Exclude checks
Parameter $user
has undeclared type \App\User
(Did you mean class \Tests\App\User) Open
public function getDisplayValue($user = null, $skipConversion = false, $skipFormatting = false)
- Exclude checks
Argument 1 (currencyValue)
is string
but \CurrencyField::appendCurrencySymbol()
takes \Number
defined at /code/include/fields/CurrencyField.php:225
Open
return self::appendCurrencySymbol($formattedValue, $this->currencySymbol, $this->currencySymbolPlacement);
- Exclude checks
Call to method getDetail
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$this->decimalSeparator = str_replace("\xC2\xA0", ' ', html_entity_decode($user->getDetail('currency_decimal_separator'), ENT_QUOTES, $defaultCharset));
- Exclude checks
Call to method getCurrentUserModel
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$currencySymbolPlacement = \App\User::getCurrentUserModel()->getDetail('currency_symbol_placement');
- Exclude checks
Parameter $value
has undeclared type \Number
Open
private function formatCurrencyValue($value)
- Exclude checks
Returning type 0
but convertToDBFormat()
is declared to return \Number
Open
return 0;
- Exclude checks
Saw unextractable annotation for comment '* @var <type>'</type>
Open
* @var <type>
- Exclude checks
Property \CurrencyField->conversionRate
has undeclared type \Number
Open
public $conversionRate = 1;
- Exclude checks
Returning type 0|float
but getDBInsertedValue()
is declared to return \Number
Open
return $dbValue;
- Exclude checks
Call to method getDetail
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
if (!empty($user->getDetail('currency_id'))) {
- Exclude checks
Returning type float
but getDBInsertedValue()
is declared to return \Number
Open
return $dbValue;
- Exclude checks
Return type of convertToDBFormat()
is undeclared type \Number
Open
public static function convertToDBFormat($value, $user = null, $skipConversion = false)
- Exclude checks
Parameter $user
has undeclared type \App\User
(Did you mean class \Tests\App\User) Open
public function initialize($user = null)
- Exclude checks
Parameter $user
has undeclared type \App\User
(Did you mean class \Tests\App\User) Open
public static function convertToDBFormat($value, $user = null, $skipConversion = false)
- Exclude checks
The phpdoc comment for @param
cannot occur on a property
Open
* @param Number $value
- Exclude checks
Call to method getCurrentUserModel
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$user = \App\User::getCurrentUserModel();
- Exclude checks
Assigning int
to property but \CurrencyField->conversionRate
is \Number
Open
public $conversionRate = 1;
- Exclude checks
Argument 1 (str)
is float|int
but \substr()
takes string
Open
$value = substr($value, 1);
- Exclude checks
Argument 1 (currencyValue)
is string
but \CurrencyField::appendCurrencySymbol()
takes \Number
defined at /code/include/fields/CurrencyField.php:225
Open
$value = self::appendCurrencySymbol($formattedValue, $currencySymbol, $self->currencySymbolPlacement);
- Exclude checks
Assigning int
to property but \CurrencyField->maxNumberOfDecimals
is \Number
Open
public $maxNumberOfDecimals = 5;
- Exclude checks
Expected @param annotation for value
to be before the @param annotation for user
Open
* @param \App\User $user
- Exclude checks
Argument 1 (user)
is null
but \CurrencyField::getDisplayValue()
takes \App\User
defined at /code/include/fields/CurrencyField.php:183
Open
$formattedValue = $self->getDisplayValue(null, $skipConversion, $skipFormatting);
- Exclude checks
Parameter $user
has undeclared type \App\User
(Did you mean class \Tests\App\User) Open
public function getDisplayValueWithSymbol($user = null, $skipConversion = false)
- Exclude checks
Return type of getDBInsertedValue()
is undeclared type \Number
Open
public function getDBInsertedValue($user = null, $skipConversion = false)
- Exclude checks
Argument 1 (haystack)
is float|int
but \stripos()
takes string
Open
if (0 === stripos($value, '-')) {
- Exclude checks
Call to method getDetail
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$this->numberOfDecimal = (empty($user->getDetail('no_of_currency_decimals')) && 0 !== (int) $user->getDetail('no_of_currency_decimals')) ? 2 : (int) $user->getDetail('no_of_currency_decimals');
- Exclude checks
Parameter $user
has undeclared type \App\User
(Did you mean class \Tests\App\User) Open
public static function convertToUserFormat($value, $user = null, $skipConversion = false, $skipFormatting = false)
- Exclude checks
Parameter $currencyValue
has undeclared type \Number
Open
public static function appendCurrencySymbol($currencyValue, $currencySymbol, $currencySymbolPlacement = '')
- Exclude checks
Property \CurrencyField->maxNumberOfDecimals
has undeclared type \Number
Open
public $maxNumberOfDecimals = 5;
- Exclude checks
Argument 1 (value)
is false|string
but \CurrencyField::__construct()
takes \Number
defined at /code/include/fields/CurrencyField.php:92
Open
$self = new self($value);
- Exclude checks
Parameter $value
has undeclared type \Number
Open
public static function convertToDBFormat($value, $user = null, $skipConversion = false)
- Exclude checks
Call to method getDetail
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$this->currencyFormat = html_entity_decode($user->getDetail('currency_grouping_pattern'), ENT_QUOTES, $defaultCharset);
- Exclude checks
Call to method getDetail
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$this->currencySeparator = str_replace("\xC2\xA0", ' ', html_entity_decode($user->getDetail('currency_grouping_separator'), ENT_QUOTES, $defaultCharset));
- Exclude checks
Call to method getCurrentUserModel
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$user = \App\User::getCurrentUserModel();
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$id = (new \App\Db\Query())->select(['id'])->from('vtiger_currency_info')->where(['<', 'defaultid', 0])->scalar();
- Exclude checks
Returning type null
but getDBCurrencyId()
is declared to return int
Open
return null;
- Exclude checks
Call to method getDetail
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$this->currencySymbolPlacement = $user->getDetail('currency_symbol_placement');
- Exclude checks
Suspicious type \Number
of a variable or expression used to build a string. (Expected type to be able to cast to a string) Open
$returnValue = $currencyValue . ' ' . $currencySymbol;
- Exclude checks
Suspicious type \Number
of a variable or expression used to build a string. (Expected type to be able to cast to a string) Open
$returnValue = html_entity_decode($currencySymbol, ENT_COMPAT) . ' ' . $currencyValue;
- Exclude checks
Call to method getCurrentUserModel
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$user = \App\User::getCurrentUserModel();
- Exclude checks
Argument 3 (subject)
is \Number
but \str_replace()
takes array|string
Open
$dbValue = str_replace($curSeparator, '', $this->value);
- Exclude checks
Call to method getDetail
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
if (!empty($user->getDetail('currency_grouping_pattern'))) {
- Exclude checks
Call to method getDetail
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$this->currencyId = $user->getDetail('currency_id');
- Exclude checks
Parameter $user
has undeclared type \App\User
(Did you mean class \Tests\App\User) Open
public function getDBInsertedValue($user = null, $skipConversion = false)
- Exclude checks
Parameter $value
has undeclared type \Number
Open
public function __construct($value)
- Exclude checks
Argument 1 (number)
is \Number
but \number_format()
takes float|int
Open
$value = number_format($value, $currencyDecimalPlaces, '.', '');
- Exclude checks
Call to method getCurrentUserModel
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$user = \App\User::getCurrentUserModel();
- Exclude checks
Avoid excessively long variable names like $currencySymbolPlacement. Keep variable name length under 20. Open
public $currencySymbolPlacement;
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $CURRENCY_PATTERN_PLAIN. Keep variable name length under 20. Open
private $CURRENCY_PATTERN_PLAIN = '123456789';
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $wholeNumberFirstPartElements. Keep variable name length under 20. Open
$wholeNumberFirstPartElements = str_split($wholeNumberFirstPart, 2);
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $CURRENCY_PATTERN_MIXED_GROUPING. Keep variable name length under 20. Open
private $CURRENCY_PATTERN_MIXED_GROUPING = '12,34,56,789';
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $currencySymbolPlacement. Keep variable name length under 20. Open
public static function appendCurrencySymbol($currencyValue, $currencySymbol, $currencySymbolPlacement = '')
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $currencyDecimalPlaces. Keep variable name length under 20. Open
$currencyDecimalPlaces = $this->numberOfDecimal;
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $CURRENCY_PATTERN_SINGLE_GROUPING. Keep variable name length under 20. Open
private $CURRENCY_PATTERN_SINGLE_GROUPING = '123456,789';
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid excessively long variable names like $CURRENCY_PATTERN_THOUSAND_GROUPING. Keep variable name length under 20. Open
private $CURRENCY_PATTERN_THOUSAND_GROUPING = '123,456,789';
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class CurrencyField
- Exclude checks
The property $CURRENCY_PATTERN_MIXED_GROUPING is not named in camelCase. Open
class CurrencyField
{
private $CURRENCY_PATTERN_PLAIN = '123456789';
private $CURRENCY_PATTERN_SINGLE_GROUPING = '123456,789';
private $CURRENCY_PATTERN_THOUSAND_GROUPING = '123,456,789';
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $CURRENCY_PATTERN_SINGLE_GROUPING is not named in camelCase. Open
class CurrencyField
{
private $CURRENCY_PATTERN_PLAIN = '123456789';
private $CURRENCY_PATTERN_SINGLE_GROUPING = '123456,789';
private $CURRENCY_PATTERN_THOUSAND_GROUPING = '123,456,789';
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $CURRENCY_PATTERN_PLAIN is not named in camelCase. Open
class CurrencyField
{
private $CURRENCY_PATTERN_PLAIN = '123456789';
private $CURRENCY_PATTERN_SINGLE_GROUPING = '123456,789';
private $CURRENCY_PATTERN_THOUSAND_GROUPING = '123,456,789';
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $CURRENCY_PATTERN_THOUSAND_GROUPING is not named in camelCase. Open
class CurrencyField
{
private $CURRENCY_PATTERN_PLAIN = '123456789';
private $CURRENCY_PATTERN_SINGLE_GROUPING = '123456,789';
private $CURRENCY_PATTERN_THOUSAND_GROUPING = '123,456,789';
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
Avoid variables with short names like $id. Configured minimum length is 3. Open
$id = (new \App\Db\Query())->select(['id'])->from('vtiger_currency_info')->where(['<', 'defaultid', 0])->scalar();
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Spaces must be used for alignment; tabs are not allowed Open
public static function convertToUserFormat($value, $user = null, $skipConversion = false, $skipFormatting = false)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (0 === stripos($value, '-')) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$value = substr($value, 1);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$value = $self->getDisplayValue($user, $skipConversion, $skipFormatting);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (false === $skipConversion) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Function that converts the Number into Users Currency along with currency symbol.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param Number $currencyValue
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return bool|string Formatted Currency
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Function that converts the Number into Users Currency.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$negative = false;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$value = self::appendCurrencySymbol($formattedValue, $currencySymbol, $self->currencySymbolPlacement);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param bool $skipConversion
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$displayValue = $this->formatCurrencyValue($displayValue);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Static Function that appends the currency symbol to a given currency value, based on the preferred symbol placement.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
case '1.0$':
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$self = new self($value);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
// To support negative values
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$negative = true;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (empty($user)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return string Formatted Currency
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public static function appendCurrencySymbol($currencyValue, $currencySymbol, $currencySymbolPlacement = '')
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param string $currencySymbol
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$currencySymbolPlacement = \App\User::getCurrentUserModel()->getDetail('currency_symbol_placement');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
switch ($currencySymbolPlacement) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @deprecated Recommend using function \App\Fields\Currency::formatToDisplay
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (0 === stripos($value, '-')) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$value = substr($value, 1);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$formattedValue = $self->getDisplayValue(null, $skipConversion, $skipFormatting);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$user = \App\User::getCurrentUserModel();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$displayValue = 0;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$returnValue = $currencyValue . ' ' . $currencySymbol;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param mixed $skipFormatting
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param string $currencySymbolPlacement
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return string Formatted Currency
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$self = new self($value);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return ($negative) ? '-' . $value : $value;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (empty($displayValue)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$displayValue = self::convertFromDollar($displayValue, $this->conversionRate);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$negative = true;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public static function convertToUserFormatSymbol($value, $skipConversion = false, $currencySymbol = false, $skipFormatting = false)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param \App\User $user
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return string Formatted Currency
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (false === $skipFormatting) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function getDisplayValueWithSymbol($user = null, $skipConversion = false)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return self::appendCurrencySymbol($formattedValue, $this->currencySymbol, $this->currencySymbolPlacement);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Function that formats the Number based on the User configured Pattern, Currency separator and Decimal separator.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$currencySymbol = $self->currencySymbol;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (!$currencySymbolPlacement) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
case '$1.0':
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
private function formatCurrencyValue($value)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$currencyPattern = $this->currencyFormat;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
// To support negative values
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function getDisplayValue($user = null, $skipConversion = false, $skipFormatting = false)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param bool $skipConversion
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$returnValue = html_entity_decode($currencySymbol, ENT_COMPAT) . ' ' . $currencyValue;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param Number $value
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$negative = false;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (false === $currencySymbol) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->initialize($user);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return ($negative) ? '-' . $value : $value;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$displayValue = $this->value;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $this->currencyDecimalFormat($displayValue, $user);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return string Currency value appended with the currency symbol
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $returnValue;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param \App\User $user
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$formattedValue = $this->getDisplayValue($user, $skipConversion);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
default:
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$curSeparator = $this->currencySeparator;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (\strlen($wholeNumber) > 3) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
// Second Part of the number (last 3 digits) which should be separated from the First part using Currency Separator
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($currencyPattern == $this->CURRENCY_PATTERN_THOUSAND_GROUPING) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$wholeNumber = $numericParts[0];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($wholeNumber < 0 || $negativeNumber) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$negativeNumber = true;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($wholeNumber < 0 || $negativeNumber) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
// Second Part of the number (last 3 digits) which should be separated from the First part using Currency Separator
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
// Pad the rest of the length in the number string with Leading 0, to get it to the multiples of 2
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
//if its negative number, append-back the negative symbol to the whole number part
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$numericParts[0] = '-' . $numericParts[0];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (!empty($wholeNumberFirstPart)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
// Re-create the currency value combining the whole number and the decimal part using Decimal separator
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$negativeNumber = false;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$wholeNumberFirstPart = substr($wholeNumber, 0, \strlen($wholeNumber) - 3);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$wholeNumberFirstPart = ltrim($wholeNumberFirstPart, '0');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$sign = '';
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
// Re-create the whole number with user's configured currency separator
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$negativeNumber = true;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$negativeNumber = true;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$OddGroupLength = $numberLength % 3;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$wholeNumber = $numericParts[0];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$wholeNumber = $positiveValues[1];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param bool $skipConversion
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$decSeparator = ' ';
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $sign . $number;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$wholeNumber = $numericParts[0];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$wholeNumber = $positiveValues[1];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($OddGroupLength > 0) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
// Split the whole number into chunks of 3 digits
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
// Re-create the whole number with user's configured currency separator
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$numericParts[0] = ltrim($wholeNumber, '0');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$number = implode($decSeparator, $numericParts);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$numberLength = \strlen($wholeNumberFirstPart);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
// Re-create the whole number with user's configured currency separator
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return Number
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
// Re-create the currency value combining the whole number and the decimal part using Decimal separator
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
// Separate the numeric and decimal parts
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$gapsToBeFilled = 0;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$wholeNumberFirstPart = implode($curSeparator, $wholeNumberFirstPartElements);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$numericParts[0] = $wholeNumberFirstPart . $curSeparator . $wholeNumberLastPart;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$currencyDecimalPlaces = $this->numberOfDecimal;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$value = number_format($value, $currencyDecimalPlaces, '.', '');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$curSeparator = ' ';
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($value < 0) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$wholeNumberParts = str_split($wholeNumber, 3);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$numericParts = explode('.', $value);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
//check the whole number is negative value, then separate the negative symbol from whole number
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$wholeNumberFirstPart = str_pad($wholeNumberFirstPart, $numberLength + $gapsToBeFilled, '0', STR_PAD_LEFT);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function getDBInsertedValue($user = null, $skipConversion = false)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($value < 0) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($currencyPattern == $this->CURRENCY_PATTERN_PLAIN) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($currencyPattern == $this->CURRENCY_PATTERN_SINGLE_GROUPING) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$wholeNumberFirstPartElements = str_split($wholeNumberFirstPart, 2);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (empty($user)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
// Pad the rest of the length in the number string with Leading 0, to get it to the multiples of 3
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($negativeNumber) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($value < 0) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$gapsToBeFilled = 2 - $OddGroupLength;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$user = \App\User::getCurrentUserModel();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$wholeNumberLastPart = substr($wholeNumber, -3);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$numericParts[0] = $wholeNumberFirstPart . $curSeparator . $wholeNumberLastPart;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $sign . $number;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$numberLength = \strlen($wholeNumber);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$number = implode($decSeparator, $numericParts);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $value;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Returns the Currency value without formatting for DB Operations.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param \App\User $user
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$this->initialize($user);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$numericParts[0] = $wholeNumberLastPart;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$number = implode($decSeparator, $numericParts);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($currencyPattern == $this->CURRENCY_PATTERN_MIXED_GROUPING) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$positiveValues = explode('-', $wholeNumber);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $sign . $number;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (empty($decSeparator)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$numericParts = explode('.', $value);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (0 != $wholeNumber) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$numericParts[0] = 0;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$numericParts[0] = '-' . $numericParts[0];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
// First part of the number which needs separate division
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
// First grouping digits length
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$number = str_replace('.', $decSeparator, $value);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$wholeNumberFirstPart = substr($wholeNumber, 0, \strlen($wholeNumber) - 3);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
// First grouping digits length
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$negativeNumber = false;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (\strlen($wholeNumber) > 3) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (0 != $wholeNumberFirstPart) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
// Re-create the currency value combining the whole number and the decimal part using Decimal separator
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (empty($curSeparator)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$sign = '-';
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
// Replace '.' with Decimal Separator
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
//check the whole number is negative value, then separate the negative symbol from whole number
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$wholeNumber = str_pad($wholeNumber, $numberLength + $gapsToBeFilled, '0', STR_PAD_LEFT);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
//if its negative number, append-back the negative symbol to the whole number part
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$negativeNumber = true;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (!empty($wholeNumberFirstPart)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$OddGroupLength = $numberLength % 2;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
// Separate the numeric and decimal parts
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
// First part of the number which remains intact
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$decSeparator = $this->decimalSeparator;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$value = substr($value, 1);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$positiveValues = explode('-', $wholeNumber);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$gapsToBeFilled = 3 - $OddGroupLength;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$numericParts[0] = $wholeNumber = implode($curSeparator, $wholeNumberParts);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $sign . $number;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($OddGroupLength > 0) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
// Split the first part of tne number into chunks of 2 digits
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$wholeNumberFirstPart = 0;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
// Separate the numeric and decimal parts
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$numericParts = explode('.', $value);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$gapsToBeFilled = 0;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$wholeNumberLastPart = substr($wholeNumber, -3);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$numericParts[0] = $wholeNumberLastPart;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($negativeNumber) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$self = new self($value);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($user->getDetail('truncate_trailing_zeros')) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$dbValue = (float) preg_replace('/[^0-9\.-]/', '', $dbValue);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (false === $skipConversion) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return null;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (isset($fieldValue[1]) && 1 <= \strlen($fieldValue[1])) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$decSeparator = $this->decimalSeparator;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Returns the Currency value without formatting for DB Operations.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param \App\User $user
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public static function getDBCurrencyId()
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $amount / $conversionRate;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$curSeparator = ' ';
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return Number
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return 0;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Function to get the default CRM currency.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return round($amount * $conversionRate, $currencyField->maxNumberOfDecimals);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (!$user) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (0 !== strpos($value, $user->getDetail('currency_decimal_separator'))) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (empty($curSeparator)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$currencyField = new self($amount);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function currencyDecimalFormat($value, $user = null)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (0 === (int) $valueField || !isset($fieldValue[1]) || \strlen($fieldValue[1]) <= 1) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public static function convertFromDollar($amount, $conversionRate)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (empty($decSeparator)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$decSeparator = ' ';
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$dbValue = str_replace($curSeparator, '', $this->value);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param Number $value
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (0 == $conversionRate) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$valueField = $fieldValue[0];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $value = $valueField . $decSeparator . $fieldValue[1];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$curSeparator = $this->currencySeparator;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $value = $valueField;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$decSeparator = $user->getDetail('currency_decimal_separator');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$fieldValue = explode(App\Purifier::decodeHtml($decSeparator), $value);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $value = $valueField;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $dbValue;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public static function convertToDollar($amount, $conversionRate)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $self->getDBInsertedValue($user, $skipConversion);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return int Default system currency id
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($id) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $id;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$value = \App\Fields\Double::truncateZeros($value);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$dbValue = str_replace($decSeparator, '.', $dbValue);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (empty($value)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$user = \App\User::getCurrentUserModel();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $value;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param bool $skipConversion
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return 0;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (!isset($fieldValue[1])) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return preg_replace('/(?<=\\.[0-9])[0]+$/', '', $value);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$dbValue = self::convertToDollar($dbValue, $this->conversionRate);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public static function convertToDBFormat($value, $user = null, $skipConversion = false)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$id = (new \App\Db\Query())->select(['id'])->from('vtiger_currency_info')->where(['<', 'defaultid', 0])->scalar();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private $CURRENCY_PATTERN_MIXED_GROUPING = '12,34,56,789';
- 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 $currencySymbol;
- 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 $value
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- 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
private $CURRENCY_PATTERN_SINGLE_GROUPING = '123456,789';
- 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
* Currency Separator for example (comma, dot, hash).
- 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 $value;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- 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
* @var int
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Constructor.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private $CURRENCY_PATTERN_THOUSAND_GROUPING = '123,456,789';
- 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 $decimalSeparator = '.';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Currency Id.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Currency Symbol.
- 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 $currencyFormat = '123,456,789';
- 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
* @var string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $currencySymbolPlacement;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->value = $value;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Value to be converted.
- 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
private $CURRENCY_PATTERN_PLAIN = '123456789';
- 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 $currencyId = 1;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Maximum Number Of Currency Decimals.
- 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
* @var 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
public $numberOfDecimal = 3;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Currency Conversion Rate.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Number of Decimal Numbers.
- 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
* @var Number
- 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
* Currency Format(3,3,3) or (2,2,3).
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var <type>
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var int
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Currency Symbol Placement.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param Number $value
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \App\User $user
- 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 $currencySeparator = ',';
- 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
* Initializes the User's Currency Details.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Decimal Separator for example (dot, comma, space).
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var Number
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $conversionRate = 1;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function __construct($value)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $maxNumberOfDecimals = 5;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @deprecated Recommend using function \App\Fields\Currency::formatToDisplay
- Exclude checks
Line exceeds 120 characters; contains 123 characters Open
* Static Function that appends the currency symbol to a given currency value, based on the preferred symbol placement.
- Exclude checks
Line exceeds 120 characters; contains 135 characters Open
public static function convertToUserFormatSymbol($value, $skipConversion = false, $currencySymbol = false, $skipFormatting = false)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($user->getDetail('currency_grouping_pattern'))) {
- Exclude checks
Line exceeds 120 characters; contains 164 characters Open
$this->decimalSeparator = str_replace("\xC2\xA0", ' ', html_entity_decode($user->getDetail('currency_decimal_separator'), ENT_QUOTES, $defaultCharset));
- 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 function getCurrencySymbol()
- 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
$defaultCharset = App\Config::main('default_charset');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function initialize($user = null)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->currencyId = self::getDBCurrencyId();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->currencySymbol = $currencyData['currency_symbol'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @global Users $current_user
- 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
* @param mixed $skipFormatting
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->currencyFormat = html_entity_decode($user->getDetail('currency_grouping_pattern'), ENT_QUOTES, $defaultCharset);
- Exclude checks
Line exceeds 120 characters; contains 131 characters Open
$this->currencyFormat = html_entity_decode($user->getDetail('currency_grouping_pattern'), ENT_QUOTES, $defaultCharset);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($user)) {
- Exclude checks
Line exceeds 120 characters; contains 201 characters Open
$this->numberOfDecimal = (empty($user->getDetail('no_of_currency_decimals')) && 0 !== (int) $user->getDetail('no_of_currency_decimals')) ? 2 : (int) $user->getDetail('no_of_currency_decimals');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $skipConversion
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->numberOfDecimal = (empty($user->getDetail('no_of_currency_decimals')) && 0 !== (int) $user->getDetail('no_of_currency_decimals')) ? 2 : (int) $user->getDetail('no_of_currency_decimals');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->currencyId = $user->getDetail('currency_id');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->conversionRate = $currencyData['conversion_rate'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \App\User $user
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currencyData = \App\Fields\Currency::getById($this->currencyId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $value
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$user = \App\User::getCurrentUserModel();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($user->getDetail('currency_id'))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->currencySeparator = str_replace("\xC2\xA0", ' ', html_entity_decode($user->getDetail('currency_grouping_separator'), ENT_QUOTES, $defaultCharset));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->currencySymbol;
- 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
Line exceeds 120 characters; contains 166 characters Open
$this->currencySeparator = str_replace("\xC2\xA0", ' ', html_entity_decode($user->getDetail('currency_grouping_separator'), ENT_QUOTES, $defaultCharset));
- 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 the Formatted Currency value for the User.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->decimalSeparator = str_replace("\xC2\xA0", ' ', html_entity_decode($user->getDetail('currency_decimal_separator'), ENT_QUOTES, $defaultCharset));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->currencySymbolPlacement = $user->getDetail('currency_symbol_placement');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
// Second Part of the number (last 3 digits) which should be separated from the First part using Currency Separator
- Exclude checks
Line exceeds 120 characters; contains 123 characters Open
$wholeNumberFirstPart = str_pad($wholeNumberFirstPart, $numberLength + $gapsToBeFilled, '0', STR_PAD_LEFT);
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
// Second Part of the number (last 3 digits) which should be separated from the First part using Currency Separator
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
$id = (new \App\Db\Query())->select(['id'])->from('vtiger_currency_info')->where(['<', 'defaultid', 0])->scalar();
- Exclude checks
The variable $OddGroupLength is not named in camelCase. Open
private function formatCurrencyValue($value)
{
$currencyPattern = $this->currencyFormat;
$curSeparator = $this->currencySeparator;
$decSeparator = $this->decimalSeparator;
- 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 $OddGroupLength is not named in camelCase. Open
private function formatCurrencyValue($value)
{
$currencyPattern = $this->currencyFormat;
$curSeparator = $this->currencySeparator;
$decSeparator = $this->decimalSeparator;
- 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 $OddGroupLength is not named in camelCase. Open
private function formatCurrencyValue($value)
{
$currencyPattern = $this->currencyFormat;
$curSeparator = $this->currencySeparator;
$decSeparator = $this->decimalSeparator;
- 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 $OddGroupLength is not named in camelCase. Open
private function formatCurrencyValue($value)
{
$currencyPattern = $this->currencyFormat;
$curSeparator = $this->currencySeparator;
$decSeparator = $this->decimalSeparator;
- 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 $OddGroupLength is not named in camelCase. Open
private function formatCurrencyValue($value)
{
$currencyPattern = $this->currencyFormat;
$curSeparator = $this->currencySeparator;
$decSeparator = $this->decimalSeparator;
- 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 $OddGroupLength is not named in camelCase. Open
private function formatCurrencyValue($value)
{
$currencyPattern = $this->currencyFormat;
$curSeparator = $this->currencySeparator;
$decSeparator = $this->decimalSeparator;
- 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();
}
}