Method getCRMConversionRate
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getCRMConversionRate($from, $to, $date = '')
{
$mainCurrencyCode = \App\Fields\Currency::getDefault()['currency_code'];
$activeBankId = self::getActiveBankId();
$exchange = false;
Function getCRMConversionRate
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function getCRMConversionRate($from, $to, $date = '')
{
$mainCurrencyCode = \App\Fields\Currency::getDefault()['currency_code'];
$activeBankId = self::getActiveBankId();
$exchange = false;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
File Module.php
has 262 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* @copyright YetiForce S.A.
* @license YetiForce Public License 6.5 (licenses/LicenseEN.txt or yetiforce.com)
Function refreshBanks
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function refreshBanks()
{
$db = App\Db::getInstance();
$dataReader = (new \App\Db\Query())->select(['id', 'bank_name'])
->from('yetiforce_currencyupdate_banks')
- 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 fetchCurrencyRates
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function fetchCurrencyRates($dateCur, $cron = false)
{
if (!\App\RequestUtil::isNetConnection()) {
return false;
}
Function fetchCurrencyRates
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function fetchCurrencyRates($dateCur, $cron = false)
{
if (!\App\RequestUtil::isNetConnection()) {
return false;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
The method getCRMConversionRate() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10. Open
public function getCRMConversionRate($from, $to, $date = '')
{
$mainCurrencyCode = \App\Fields\Currency::getDefault()['currency_code'];
$activeBankId = self::getActiveBankId();
$exchange = false;
- 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
Refactor this function to reduce its Cognitive Complexity from 23 to the 15 allowed. Open
public function getCRMConversionRate($from, $to, $date = '')
- 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
Avoid using undefined variables such as '$unsupported' which will lead to PHP notices. Open
return array_diff($unsupported, $supported);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$unsupported' which will lead to PHP notices. Open
$unsupported[$name] = $code;
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Missing class import via use statement (line '111', column '21'). Open
$isExists = (new \App\Db\Query())->from('yetiforce_currencyupdate_banks')->where(['bank_name' => $bankClassName])->exists();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '334', column '18'). Open
$query = new App\Db\Query();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '403', column '15'). Open
return (new \App\Db\Query())->select(['bank_name'])->from('yetiforce_currencyupdate_banks')->where(['active' => 1])->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
Missing class import via use statement (line '295', column '18'). Open
$query = new App\Db\Query();
- 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 fetchCurrencyRates has a boolean flag argument $cron, which is a certain sign of a Single Responsibility Principle violation. Open
public function fetchCurrencyRates($dateCur, $cron = 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 '306', column '18'). Open
$query = new App\Db\Query();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '319', column '17'). Open
$query = new App\Db\Query();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '237', column '22'). Open
$dataReader = (new \App\Db\Query())->select(['currency_name', 'currency_code'])
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '106', column '16'). Open
foreach (new DirectoryIterator(ROOT_DIRECTORY . '/modules/Settings/CurrencyUpdate/bankmodels/') as $fileInfo) {
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '28', column '15'). Open
return (new \App\Db\Query())
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '60', column '22'). Open
$dataReader = (new \App\Db\Query())->select(['id', 'currency_code'])
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '77', column '20'). Open
$currNum = (new \App\Db\Query())->from('yetiforce_currencyupdate')
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '164', column '15'). Open
return (new \App\Db\Query())->select(['id'])
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '287', column '17'). Open
$query = new App\Db\Query();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '95', column '22'). Open
$dataReader = (new \App\Db\Query())->select(['id', 'bank_name'])
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '181', column '17'). Open
$query = (new App\Db\Query())->select(['exchange', 'currency_name', 'currency_code', 'currency_symbol', 'fetch_date', 'exchange_date'])
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '375', column '15'). Open
return (new \App\Db\Query())->select(['id'])->from('yetiforce_currencyupdate_banks')->where(['active' => 1])->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 convertFromTo has a boolean flag argument $date, which is a certain sign of a Single Responsibility Principle violation. Open
public function convertFromTo($amount, $from, $to, $date = 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 getCRMConversionRate uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$exchange = $fromExchange * $convertToMainCurrency;
}
- 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\Currency' in method 'getCRMConversionRate'. Open
}
- 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\RequestUtil' in method 'fetchCurrencyRates'. Open
if (!\App\RequestUtil::isNetConnection()) {
- 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 getRatesHistory uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$query->andWhere(['exchange_date' => $dateCur]);
}
- 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\Currency' in method 'getCRMConversionRate'. Open
}
- 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\Db' in method 'refreshBanks'. Open
$db = App\Db::getInstance();
- 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\RequestUtil' in method 'getSupportedCurrencies'. Open
if (!\App\RequestUtil::isNetConnection()) {
- 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\RequestUtil' in method 'getUnSupportedCurrencies'. Open
if (!\App\RequestUtil::isNetConnection()) {
- 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 getCRMConversionRate uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
else {
if (\App\RequestUtil::isNetConnection()) {
$query = new App\Db\Query();
$query->from('yetiforce_currencyupdate')
->innerJoin('vtiger_currency_info', 'vtiger_currency_info.id = yetiforce_currencyupdate.currency_id AND deleted = :del', [':del' => 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\Db' in method 'setActiveBankById'. Open
$db = \App\Db::getInstance();
- 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\Log' in method 'getSupportedCurrencies'. Open
\App\Log::error('Error during downloading table: ' . PHP_EOL . $ex->__toString() . PHP_EOL, 'CurrencyUpdate');
- 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 'getCRMConversionRate'. Open
}
- 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\RequestUtil' in method 'getCRMConversionRate'. Open
if (\App\RequestUtil::isNetConnection()) {
- 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 'getCurrencyNum'. Open
return \count(\App\Fields\Currency::getAll(true));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Define a constant instead of duplicating this literal "active" 6 times. Open
$db->createCommand()->insert('yetiforce_currencyupdate_banks', ['bank_name' => $bankClassName, 'active' => 0])->execute();
- 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 "conversion_rate" 3 times. Open
->update('vtiger_currency_info', ['conversion_rate' => $rate], ['currency_code' => $currency])
- 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 "_BankModel" 3 times. Open
$activeBankName = 'Settings_CurrencyUpdate_' . $this->getActiveBankName() . '_BankModel';
- 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 "vtiger_currency_info.id = yetiforce_currencyupdate.currency_id AND deleted = :del" 3 times. Open
->innerJoin('vtiger_currency_info', 'vtiger_currency_info.id = yetiforce_currencyupdate.currency_id AND deleted = :del', [':del' => 0])
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "currency_name" 4 times. Open
->select(['currency_name'])
- 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 "currency_code" 13 times. Open
->where(['currency_code' => $code])
- 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 "yetiforce_currencyupdate.exchange_date" 3 times. Open
->where(['yetiforce_currencyupdate.exchange_date' => $date,
- 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 "bank_name" 6 times. Open
$dataReader = (new \App\Db\Query())->select(['id', 'bank_name'])
- 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 "yetiforce_currencyupdate" 8 times. Open
$currNum = (new \App\Db\Query())->from('yetiforce_currencyupdate')
- 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 "Settings_CurrencyUpdate_" 3 times. Open
$activeBankName = 'Settings_CurrencyUpdate_' . $this->getActiveBankName() . '_BankModel';
- 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 "exchange_date" 7 times. Open
->where(['exchange_date' => $dateCur, 'currency_id' => $currIds, 'bank_id' => $selectBankId])
- 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 "yetiforce_currencyupdate.bank_id" 4 times. Open
->where(['yetiforce_currencyupdate.bank_id' => $bankId]);
- 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 "yetiforce_currencyupdate_banks" 10 times. Open
->from('yetiforce_currencyupdate_banks')
- 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 "bank_id" 3 times. Open
->where(['exchange_date' => $dateCur, 'currency_id' => $currIds, 'bank_id' => $selectBankId])
- 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 "currency_id" 3 times. Open
->where(['exchange_date' => $dateCur, 'currency_id' => $currIds, 'bank_id' => $selectBankId])
- 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 "vtiger_currency_info.currency_code" 3 times. Open
'vtiger_currency_info.currency_code' => $to, ])
- 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 "vtiger_currency_info" 9 times. Open
->from('vtiger_currency_info')
- 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 "exchange" 3 times. Open
->update('yetiforce_currencyupdate', ['exchange' => $exchange], ['id' => $id])
- 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.
Avoid unused parameters such as '$cron'. Open
public function fetchCurrencyRates($dateCur, $cron = false)
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Call to undeclared method \App\Db\Query::from
Open
$isExists = (new \App\Db\Query())->from('yetiforce_currencyupdate_banks')->where(['bank_name' => $bankClassName])->exists();
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->update('yetiforce_currencyupdate_banks', ['active' => 1], ['bank_name' => 'NBP'])->execute();
- Exclude checks
Saw unextractable annotation for comment '* @return <array> - array of supported currencies'</array>
Open
* @return <Array> - array of supported currencies
- Exclude checks
Saw unextractable annotation for comment '* @return <array> - array of unsupported currencies'</array>
Open
* @return <Array> - array of unsupported currencies
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$currNum = (new \App\Db\Query())->from('yetiforce_currencyupdate')
- Exclude checks
Saw unextractable annotation for comment '* @param <float> $exchange - exchange rate'</float>
Open
* @param <Float> $exchange - exchange rate
- Exclude checks
Saw unextractable annotation for comment '* @param <float> $exchange - exchange rate'</float>
Open
* @param <Float> $exchange - exchange rate
- Exclude checks
Call to method error
from undeclared class \App\Log
Open
\App\Log::error('Error during downloading table: ' . PHP_EOL . $ex->__toString() . PHP_EOL, 'CurrencyUpdate');
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->update('yetiforce_currencyupdate_banks', ['active' => 0])->execute();
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
return (new \App\Db\Query())
- Exclude checks
Expected @param annotation for dateCur
to be before the @param annotation for cron
Open
* @param bool $cron - true if fired by server, and so updates systems currency conversion rates
- Exclude checks
Saw unextractable annotation for comment '* @param <integer> $currId - currency id'</integer>
Open
* @param <Integer> $currId - currency id
- Exclude checks
Saw unextractable annotation for comment '* @param <integer> $bankId - id of bank'</integer>
Open
* @param <Integer> $bankId - id of bank
- Exclude checks
Variable $unsupported
was undeclared, but array fields are being added to it. Open
$unsupported[$name] = $code;
- Exclude checks
Saw unextractable annotation for comment '* @param <integer> $bankId - bank id'</integer>
Open
* @param <Integer> $bankId - bank id
- Exclude checks
Saw unextractable annotation for comment '* @param <integer> $currencyId - systems currency id'</integer>
Open
* @param <Integer> $currencyId - systems currency id
- Exclude checks
Saw unextractable annotation for comment '* @param <date> $date - date for which to fetch exchange rates'</date>
Open
* @param <Date> $date - date for which to fetch exchange rates
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
\App\Db::getInstance()->createCommand()->insert('yetiforce_currencyupdate', [
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
return (new \App\Db\Query())->select(['bank_name'])->from('yetiforce_currencyupdate_banks')->where(['active' => 1])->scalar();
- Exclude checks
Saw unextractable annotation for comment '* @param <date> $exchangeDate - date of exchange rate'</date>
Open
* @param <Date> $exchangeDate - date of exchange rate
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
return (new \App\Db\Query())->select(['id'])->from('yetiforce_currencyupdate_banks')->where(['active' => 1])->scalar();
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$result = $db->createCommand()->update('yetiforce_currencyupdate_banks', ['active' => 1], ['id' => $bankId])->execute();
- Exclude checks
Saw unextractable annotation for comment '* @param <integer> $id - exchange rate id'</integer>
Open
* @param <Integer> $id - exchange rate id
- Exclude checks
Saw unextractable annotation for comment '* @return <integer> - bank id'</integer>
Open
* @return <Integer> - bank id
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$query->select(['conversion_rate'])
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$query->select(['yetiforce_currencyupdate.exchange'])
- Exclude checks
Saw unextractable annotation for comment '* @return <float> - floating point number'</float>
Open
* @return <Float> - floating point number
- Exclude checks
Saw unextractable annotation for comment '* @return <integer> - number of currencies'</integer>
Open
* @return <Integer> - number of currencies
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$dataReader = (new \App\Db\Query())->select(['currency_name', 'currency_code'])
- Exclude checks
Saw unextractable annotation for comment '* @param <float> $exchange - exchange rate'</float>
Open
* @param <Float> $exchange - exchange rate
- Exclude checks
Saw unextractable annotation for comment '* @param <date> $dateCur - date, if empty show this months history'</date>
Open
* @param <Date> $dateCur - date, if empty show this months history
- Exclude checks
Saw unextractable annotation for comment '* @return <float> - conversion rate'</float>
Open
* @return <Float> - conversion rate
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
\App\Db::getInstance()->createCommand()
- Exclude checks
Saw unextractable annotation for comment '* @param <date> $exchangeDate - exchange date'</date>
Open
* @param <Date> $exchangeDate - exchange date
- Exclude checks
Saw unextractable annotation for comment '* @param <integer> $bankId - bank id'</integer>
Open
* @param <Integer> $bankId - bank id
- Exclude checks
Saw unextractable annotation for comment '* @return <array> - array containing currency rates'</array>
Open
* @return <Array> - array containing currency rates
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
\App\Db::getInstance()->createCommand()
- Exclude checks
Saw unextractable annotation for comment '* @param <integer> $bankId - bank id'</integer>
Open
* @param <Integer> $bankId - bank id
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
return (new \App\Db\Query())->select(['id'])
- Exclude checks
Call to undeclared method \App\Db\Query::count
Open
$num = (float) ($query->count());
- Exclude checks
Saw unextractable annotation for comment '* @param <date> $date - date of the exchange rate'</date>
Open
* @param <Date> $date - date of the exchange rate
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$dataReader = (new \App\Db\Query())->select(['id', 'currency_code'])
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->delete('yetiforce_currencyupdate_banks', ['id' => $id])->execute();
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$query = (new App\Db\Query())->select(['exchange', 'currency_name', 'currency_code', 'currency_symbol', 'fetch_date', 'exchange_date'])
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$query->select(['yetiforce_currencyupdate.exchange'])
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->insert('yetiforce_currencyupdate_banks', ['bank_name' => $bankClassName, 'active' => 0])->execute();
- Exclude checks
Saw unextractable annotation for comment '* @return <integer> - currency rate id'</integer>
Open
* @return <Integer> - currency rate id
- Exclude checks
Saw unextractable annotation for comment '* @param <float> $amount - number to convert'</float>
Open
* @param <Float> $amount - number to convert
- Exclude checks
Saw unextractable annotation for comment '* @param <date> $date - date of the exchange rate'</date>
Open
* @param <Date> $date - date of the exchange rate
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$query->select(['conversion_rate'])
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$dataReader = (new \App\Db\Query())->select(['id', 'bank_name'])
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$query->from('yetiforce_currencyupdate')
- Exclude checks
Avoid excessively long variable names like $convertToMainCurrency. Keep variable name length under 20. Open
$convertToMainCurrency = 1 / $exchange;
- 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 Settings_CurrencyUpdate_Module_Model extends \App\Base
- Exclude checks
The class Settings_CurrencyUpdate_Module_Model is not named in CamelCase. Open
class Settings_CurrencyUpdate_Module_Model extends \App\Base
{
// Returns objects instance
public static function getCleanInstance()
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
Avoid variables with short names like $to. Configured minimum length is 3. Open
public function getCRMConversionRate($from, $to, $date = '')
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $id. Configured minimum length is 3. Open
$id = $row['id'];
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $db. Configured minimum length is 3. Open
$db = App\Db::getInstance();
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $id. Configured minimum length is 3. Open
public function updateCurrencyRate($id, $exchange)
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $db. Configured minimum length is 3. Open
$db = \App\Db::getInstance();
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $id. Configured minimum length is 3. Open
$id = $row['id'];
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $to. Configured minimum length is 3. Open
public function convertFromTo($amount, $from, $to, $date = false)
- 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 to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$bank->getRates($otherCurrencyCode, $dateCur, false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->update('yetiforce_currencyupdate_banks', ['active' => 1], ['bank_name' => 'NBP'])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'bank_id' => $bankId,
- Exclude checks
Spaces must 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 <Integer> $currencyId - systems currency id
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string - currency name
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Returns list of active currencies in CRM.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$notifyNewRates = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while ($row = $dataReader->read()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader->close();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['exchange_date' => $dateCur, 'currency_id' => $currIds, 'bank_id' => $selectBankId])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->delete('yetiforce_currencyupdate_banks', ['id' => $id])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$isExists = (new \App\Db\Query())->from('yetiforce_currencyupdate_banks')->where(['bank_name' => $bankClassName])->exists();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getCleanInstance()
- Exclude checks
Spaces must 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 <Date> $date - date for which to fetch exchange rates
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function fetchCurrencyRates($dateCur, $cron = false)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$numToConvert = $dataReader->count();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$code = $row['currency_code'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$isExists) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param <Integer> $id - exchange rate 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
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'fetch_date' => date('Y-m-d'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return new self();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return (new \App\Db\Query())
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $cron - true if fired by server, and so updates systems currency conversion rates
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool - true if fetched new exchange rates, false otherwise
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!\App\RequestUtil::isNetConnection()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$this->getActiveBankId()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Update currency rate in archives.
- Exclude checks
Spaces must 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
$activeBankName = 'Settings_CurrencyUpdate_' . $this->getActiveBankName() . '_BankModel';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// download only if its not in archives
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($currNum != $numToConvert && class_exists($activeBankName)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db = App\Db::getInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while ($row = $dataReader->read()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must 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 <Integer> $bankId - bank id
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getCRMCurrencyName($code)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currIds = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$id = $row['id'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach (new DirectoryIterator(ROOT_DIRECTORY . '/modules/Settings/CurrencyUpdate/bankmodels/') as $fileInfo) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'exchange_date' => $exchangeDate,
- Exclude checks
Spaces must 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 $dateCur
- Exclude checks
Spaces must 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 138 characters Open
$db->createCommand()->insert('yetiforce_currencyupdate_banks', ['bank_name' => $bankClassName, 'active' => 0])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function addCurrencyRate($currId, $exchangeDate, $exchange, $bankId)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Returns currency exchange rate id.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('vtiger_currencies')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \count(\App\Fields\Currency::getAll(true));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->count(1);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$notifyNewRates = true;
- Exclude checks
Spaces must 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 function refreshBanks()
- Exclude checks
Spaces must 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
$dataReader = (new \App\Db\Query())->select(['id', 'currency_code'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$otherCurrencyCode[$code] = $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
*
- Exclude checks
Spaces must 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 CRMS active currency name by currency code.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->scalar();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getCurrencyNum()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Returns currency exchange rates for systems active currencies from bank.
- Exclude checks
Spaces must 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
// Synchronises database banks list with the bank classes existing on ftp
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$bankClassName = $fileInfo->getBasename('.php');
- Exclude checks
Spaces must 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 <Float> $exchange - exchange rate
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param <Float> $exchange - exchange rate
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param <Date> $exchangeDate - date of exchange rate
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// Returns objects instance
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$bank = new $activeBankName();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!file_exists($bankPath)) { // delete bank from database
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
continue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Db::getInstance()->createCommand()->insert('yetiforce_currencyupdate', [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'currency_id' => $currId,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->andWhere(['<>', 'defaultid', -11])->createCommand()->query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('yetiforce_currencyupdate_banks')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->createCommand()->query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$fileInfo->isFile() || 'php' !== $fileInfo->getExtension()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Db::getInstance()->createCommand()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->update('yetiforce_currencyupdate', ['exchange' => $exchange], ['id' => $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
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$selectBankId = $this->getActiveBankId();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$bankPath = ROOT_DIRECTORY . "/modules/Settings/CurrencyUpdate/bankmodels/{$row['bank_name']}.php";
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
$db->createCommand()->update('yetiforce_currencyupdate_banks', ['active' => 1], ['bank_name' => 'NBP'])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return <Integer> - number of currencies
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currIds[] = $id;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $notifyNewRates;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader = (new \App\Db\Query())->select(['id', 'bank_name'])
- Exclude checks
Line exceeds 120 characters; contains 136 characters Open
$isExists = (new \App\Db\Query())->from('yetiforce_currencyupdate_banks')->where(['bank_name' => $bankClassName])->exists();
- Exclude checks
Spaces must 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 <Integer> $bankId - id of bank
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $code
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->select(['currency_name'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['currency_status' => 'Active', 'deleted' => 0])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($numToConvert >= 1) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$id = $row['id'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currNum = (new \App\Db\Query())->from('yetiforce_currencyupdate')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->insert('yetiforce_currencyupdate_banks', ['bank_name' => $bankClassName, 'active' => 0])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Adds currency exchange rate to archive.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param <Integer> $currId - currency id
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['currency_code' => $code])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('vtiger_currency_info')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$otherCurrencyCode = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader->close();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function updateCurrencyRate($id, $exchange)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param <Date> $exchangeDate - exchange date
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'exchange' => $exchange,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('yetiforce_currencyupdate')
- Exclude checks
Spaces must 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 function getRatesHistory($bankId, $dateCur, App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return <Array> - array of supported currencies
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getSupportedCurrencies($bankName = null)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$bankName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function setCRMConversionRate($currency, $exchange)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($from != $mainCurrencyCode) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('vtiger_currency_info')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!\App\RequestUtil::isNetConnection()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$bank = new $bankName();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$unsupported[$name] = $code;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Sets systems exchange rate for chosen currency.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $currency - currency code
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->select(['conversion_rate'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->innerJoin('vtiger_currency_info', 'vtiger_currency_info.id = yetiforce_currencyupdate.currency_id')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// filter by date - if not exists then display this months history
- Exclude checks
Spaces must 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 <Float> $exchange - exchange rate
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query = new App\Db\Query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\App\RequestUtil::isNetConnection()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->innerJoin('vtiger_currency_info', 'vtiger_currency_info.id = yetiforce_currencyupdate.currency_id AND deleted = :del', [':del' => 0])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $to - currency code or id (converted to code)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($date)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['currency_code' => $to])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'yetiforce_currencyupdate.bank_id' => $activeBankId,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
try {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return [];
- Exclude checks
Spaces must 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
$rate = (float) $exchange;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (is_numeric($to)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$to = \App\Fields\Currency::getAll(true)[$to]['currency_code'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->limit(1);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['yetiforce_currencyupdate.exchange_date' => $date,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return <Integer> - currency rate 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
->scalar();
- Exclude checks
Spaces must 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
$query->from('yetiforce_currencyupdate')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('yetiforce_currencyupdate')
- Exclude checks
Line exceeds 120 characters; contains 129 characters Open
->innerJoin('yetiforce_currencyupdate_banks', 'yetiforce_currencyupdate_banks.id = yetiforce_currencyupdate.bank_id')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \App\Request $request
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($request->isEmpty('duedate') && $dateCur) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->innerJoin('yetiforce_currencyupdate_banks', 'yetiforce_currencyupdate_banks.id = yetiforce_currencyupdate.bank_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
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$supported = $bank->getSupportedCurrencies($bankName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $bankName - bank name
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return <Float> - conversion rate
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$from = \App\Fields\Currency::getAll(true)[$from]['currency_code'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['currency_status' => 'Active', 'deleted' => 0])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('vtiger_currency_info')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->createCommand()->query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->limit(1);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fromExchange = (float) ($query->scalar());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$exchange = 1 / ($fromExchange * $convertToMainCurrency);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query = new App\Db\Query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return (new \App\Db\Query())->select(['id'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Returns currency rates from archive.
- Exclude checks
Spaces must 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 <Integer> $bankId - bank id
- Exclude checks
Line exceeds 120 characters; contains 143 characters Open
$query = (new App\Db\Query())->select(['exchange', 'currency_name', 'currency_code', 'currency_symbol', 'fetch_date', 'exchange_date'])
- 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
$query->andWhere(['exchange_date' => $dateCur]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $query->orderBy(['exchange_date' => SORT_DESC, 'currency_code' => SORT_ASC])->all();
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
\App\Log::error('Error during downloading table: ' . PHP_EOL . $ex->__toString() . PHP_EOL, 'CurrencyUpdate');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $currencies;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$bankName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader = (new \App\Db\Query())->select(['currency_name', 'currency_code'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('vtiger_currency_info')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $from - currency code or id (converted to code)
- Exclude checks
Spaces must 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
$query = new App\Db\Query();
- Exclude checks
Line exceeds 120 characters; contains 155 characters Open
->innerJoin('vtiger_currency_info', 'vtiger_currency_info.id = yetiforce_currencyupdate.currency_id AND deleted = :del', [':del' => 0])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query = (new App\Db\Query())->select(['exchange', 'currency_name', 'currency_code', 'currency_symbol', 'fetch_date', 'exchange_date'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$bankName = 'Settings_CurrencyUpdate_' . $this->getActiveBankName() . '_BankModel';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return <Array> - array of unsupported currencies
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getUnSupportedCurrencies($bankName = null)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$bankName = 'Settings_CurrencyUpdate_' . $this->getActiveBankName() . '_BankModel';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$bank = new $bankName();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getCurrencyRateId($currencyId, $exchangeDate, $bankId)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while ($row = $dataReader->read()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['exchange_date' => $exchangeDate, 'currency_id' => $currencyId, 'bank_id' => $bankId])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function that retrieves conversion rate from and to specified currency.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param <Date> $date - date of the exchange rate
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (is_numeric($from)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$convertToMainCurrency = 1 / $exchange;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return <Array> - array containing currency rates
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['currency_code' => $from])
- 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
\App\Log::error('Error during downloading table: ' . PHP_EOL . $ex->__toString() . PHP_EOL, 'CurrencyUpdate');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$name = $row['currency_name'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->update('vtiger_currency_info', ['conversion_rate' => $rate], ['currency_code' => $currency])
- Exclude checks
Spaces must 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
\App\Db::getInstance()->createCommand()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getCRMConversionRate($from, $to, $date = '')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$exchange = (float) ($query->scalar());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['yetiforce_currencyupdate.bank_id' => $bankId]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Returns list of supported currencies by active bank.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $bankName - bank name
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} catch (\Throwable $ex) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$activeBankId = self::getActiveBankId();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$exchange = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} // get conversion rate from archive
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param <Date> $dateCur - date, if empty show this months history
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currencies = $bank->getSupportedCurrencies();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!\App\RequestUtil::isNetConnection()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$code = $row['currency_code'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader->close();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->select(['conversion_rate'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currencies = [];
- Exclude checks
Spaces must 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
return array_diff($unsupported, $supported);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->andWhere(['between', 'exchange_date', date('Y-m-01'), date('Y-m-t')]);
- Exclude checks
Spaces must 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 list of unsupported currencies by active bank.
- Exclude checks
Spaces must 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
$mainCurrencyCode = \App\Fields\Currency::getDefault()['currency_code'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// get present conversion rate from crm
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// no exchange rate in archive, fetch new rates
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Convert given amount in one currency to another.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($result) {
- Exclude checks
Line exceeds 120 characters; contains 151 characters Open
->innerJoin('vtiger_currency_info', 'vtiger_currency_info.id = yetiforce_currencyupdate.currency_id AND deleted = :del', [':del' => 0])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['yetiforce_currencyupdate.exchange_date' => $date,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'vtiger_currency_info.currency_code' => $from, ])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($from != $mainCurrencyCode && $to != $mainCurrencyCode) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query = new App\Db\Query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Returns id of active bank.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = $db->createCommand()->update('yetiforce_currencyupdate_banks', ['active' => 1], ['id' => $bankId])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (0 == $num) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $from - currency code
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return (new \App\Db\Query())->select(['id'])->from('yetiforce_currencyupdate_banks')->where(['active' => 1])->scalar();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db = \App\Db::getInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Returns active banks name.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $to - currency code
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->innerJoin('vtiger_currency_info', 'vtiger_currency_info.id = yetiforce_currencyupdate.currency_id AND deleted = :del', [':del' => 0])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$exchange = (float) ($query->scalar());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($from != $mainCurrencyCode) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('yetiforce_currencyupdate')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('yetiforce_currencyupdate')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->select(['yetiforce_currencyupdate.exchange'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query = new App\Db\Query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'vtiger_currency_info.currency_code' => $to, ])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'yetiforce_currencyupdate.bank_id' => $activeBankId,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return <Float> - floating point 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
$convertToMainCurrency = 0 == $exchange ? 1 : 1 / $exchange;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->limit(1);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$exchange = $fromExchange / $convertToMainCurrency;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$exchange = $fromExchange * $convertToMainCurrency;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $exchange = round($exchange, 5);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function convertFromTo($amount, $from, $to, $date = false)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param <Integer> $bankId - bank id
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getActiveBankName()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->limit(1);
- 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
* @param <Float> $amount - number to convert
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param <Date> $date - date of the exchange rate
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return <Integer> - bank 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
self::fetchCurrencyRates($date);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->innerJoin('vtiger_currency_info', 'vtiger_currency_info.id = yetiforce_currencyupdate.currency_id AND deleted = :del', [':del' => 0])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$exchange = 1 / $exchange;
- Exclude checks
Line exceeds 120 characters; contains 155 characters Open
->innerJoin('vtiger_currency_info', 'vtiger_currency_info.id = yetiforce_currencyupdate.currency_id AND deleted = :del', [':del' => 0])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fromExchange = (float) ($query->scalar());
- Exclude checks
Spaces must 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 function getActiveBankId()
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
return (new \App\Db\Query())->select(['id'])->from('yetiforce_currencyupdate_banks')->where(['active' => 1])->scalar();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool - true on success or false
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function setActiveBankById($bankId)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string - bank name
- Exclude checks
Line exceeds 120 characters; contains 134 characters Open
return (new \App\Db\Query())->select(['bank_name'])->from('yetiforce_currencyupdate_banks')->where(['active' => 1])->scalar();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->update('yetiforce_currencyupdate_banks', ['active' => 0])->execute();
- Exclude checks
Line exceeds 120 characters; contains 128 characters Open
$result = $db->createCommand()->update('yetiforce_currencyupdate_banks', ['active' => 1], ['id' => $bankId])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($exchange > 0) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return round($amount * $this->getCRMConversionRate($from, $to, $date), 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
* Saves new active bank by 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
return (new \App\Db\Query())->select(['bank_name'])->from('yetiforce_currencyupdate_banks')->where(['active' => 1])->scalar();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['yetiforce_currencyupdate.exchange_date' => $date,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'yetiforce_currencyupdate.bank_id' => $activeBankId,
- Exclude checks
Spaces must 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
$num = (float) ($query->count());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'vtiger_currency_info.currency_code' => $to, ])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->limit(1);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->select(['yetiforce_currencyupdate.exchange'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Class name "Settings_CurrencyUpdate_Module_Model" is not in camel caps format Open
class Settings_CurrencyUpdate_Module_Model extends \App\Base
- Exclude checks