Method register
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function register(string $prefix, string $name = '', ?bool $isDefault = false, bool $isActive = true, int $progress = 0)
{
$dbCommand = \App\Db::getInstance()->createCommand();
$prefix = trim($prefix);
if ($langInfo = \App\Language::getLangInfo($prefix)) {
Function exportLanguage
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function exportLanguage($languageCode, $todir = '', $zipfilename = '', $directDownload = false)
{
$this->__initExport($languageCode);
// Call language export function
$this->generateLangMainfest($languageCode);
- 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 register
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function register(string $prefix, string $name = '', ?bool $isDefault = false, bool $isActive = true, int $progress = 0)
Missing class import via use statement (line '168', column '17'). Open
$query = (new \App\Db\Query())->from(self::TABLENAME)->select(['prefix', '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
The method register has a boolean flag argument $isActive, which is a certain sign of a Single Responsibility Principle violation. Open
public static function register(string $prefix, string $name = '', ?bool $isDefault = false, bool $isActive = true, int $progress = 0)
- 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 exportLanguage has a boolean flag argument $directDownload, which is a certain sign of a Single Responsibility Principle violation. Open
public function exportLanguage($languageCode, $todir = '', $zipfilename = '', $directDownload = 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 register has a boolean flag argument $isDefault, which is a certain sign of a Single Responsibility Principle violation. Open
public static function register(string $prefix, string $name = '', ?bool $isDefault = false, bool $isActive = true, int $progress = 0)
- 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 getAll has a boolean flag argument $includeInActive, which is a certain sign of a Single Responsibility Principle violation. Open
public static function getAll($includeInActive = false)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Avoid using static access to class '\App\Log' in method 'register'. Open
\App\Log::trace("Registering Language $name [$prefix] ... DONE", __METHOD__);
- 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\Zip' in method 'exportLanguage'. Open
$zip = \App\Zip::createFile($zipfilename);
- 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 assigning values to variables in if clauses and the like (line '115', column '7'). Open
public static function register(string $prefix, string $name = '', ?bool $isDefault = false, bool $isActive = true, int $progress = 0)
{
$dbCommand = \App\Db::getInstance()->createCommand();
$prefix = trim($prefix);
if ($langInfo = \App\Language::getLangInfo($prefix)) {
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid using static access to class '\App\Cache' in method 'register'. Open
\App\Cache::clear();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Language' in method 'generateLangMainfest'. Open
$langInfo = \App\Language::getLangInfo($prefix);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Purifier' in method 'generateLangMainfest'. Open
$this->outputNode(\App\Purifier::decodeHtml($langInfo['name']), 'name');
- 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 'deregister'. Open
\App\Log::trace("Deregistering Language $prefix ... DONE", __METHOD__);
- 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 'vtlib\Utils' in method '__initExport'. Open
Utils::checkFileAccessForInclusion("languages/$languageCode/_Base.json");
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Language' in method 'register'. Open
if ($langInfo = \App\Language::getLangInfo($prefix)) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Config' in method 'generateLangMainfest'. Open
$this->outputNode(\App\Config::main('default_charset'), 'encoding');
- 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 exportLanguage uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$zip->close();
if ($todir) {
copy($zipfilename, $todir);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method register uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$dbCommand->insert(
static::TABLENAME,
[
'name' => $name,
- 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\Version' in method 'generateLangMainfest'. Open
$this->outputNode(\App\Version::get(), 'vtiger_version');
- 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 "isdefault" 3 times. Open
'isdefault' => (int) (null === $isDefault ? $langInfo['isdefault'] : $isDefault),
- 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 "prefix" 6 times. Open
$this->outputNode($prefix, 'prefix');
- 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 "active" 3 times. Open
'active' => (int) $isActive,
- 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 '$moduleInstance'. Open
public function __initExport($languageCode, $moduleInstance = null)
- 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
@throws type of register
has undeclared type \yii\db\Exception
(Did you mean class \Exception) Open
public static function register(string $prefix, string $name = '', ?bool $isDefault = false, bool $isActive = true, int $progress = 0)
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
\App\Db::getInstance()->createCommand()->delete(self::TABLENAME, ['prefix' => $prefix])->execute();
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace("Registering Language $name [$prefix] ... DONE", __METHOD__);
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$dbCommand = \App\Db::getInstance()->createCommand();
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace("Deregistering Language $prefix ... DONE", __METHOD__);
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$query = (new \App\Db\Query())->from(self::TABLENAME)->select(['prefix', 'name']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed|null $moduleInstance
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->__finishExport();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// Add manifest file
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// Copy module directory
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->outputNode('language', 'type');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Export Language Handler.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'isdefault' => (int) (null === $isDefault ? $langInfo['isdefault'] : $isDefault),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['prefix' => $prefix]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'progress' => $progress,
- Exclude checks
Spaces must 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;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Db::getInstance()->createCommand()->delete(self::TABLENAME, ['prefix' => $prefix])->execute();
- 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
$languages[$row['prefix']] = $row['name'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $languages;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// Call language export function
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$zip->addDirectory($path);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->outputNode(\App\Version::get(), 'vtiger_version');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws \yii\db\Exception
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'prefix' => $prefix,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// Security check to ensure file is withing the web folder.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// Export as Zip
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->outputNode($prefix, 'prefix');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::trace("Registering Language $name [$prefix] ... DONE", __METHOD__);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $prefix Language prefix like (de-De) etc
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$includeInActive) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader = $query->createCommand()->query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('' === $zipfilename) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$path = $dir . \DIRECTORY_SEPARATOR . $languageCode;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (file_exists($path)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
copy($zipfilename, $todir);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->openNode('module');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->outputNode('YetiForce S.A.', 'author');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->closeNode('dependencies');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand = \App\Db::getInstance()->createCommand();
- Exclude checks
Spaces must 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 __initExport($languageCode, $moduleInstance = null)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->__write("<?xml version='1.0'?>\n");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $languageCode Module Instance of module
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach (['languages', 'custom' . \DIRECTORY_SEPARATOR . 'languages'] as $dir) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$zip->close();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->__cleanupExport();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->outputNode('language', 'type');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->outputNode(\App\Config::main('default_charset'), 'encoding');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $progress
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// We will not allow deregistering core language
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getAll($includeInActive = 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
* @param string $todir Path Output directory path
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private function generateLangMainfest($prefix)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// Export dependency information
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'lastupdated' => date('Y-m-d H:i:s'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Export Module as a zip file.
- Exclude checks
Spaces must 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 ($directDownload) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->outputNode(\App\Purifier::decodeHtml($langInfo['name']), 'name');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->outputNode('YetiForce Public License 6.5 (yetiforce.com)', 'license');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand->update(
- 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function exportLanguage($languageCode, $todir = '', $zipfilename = '', $directDownload = false)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $prefix
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $prefix
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::TABLENAME,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'name' => $name,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $languageCode
- Exclude checks
Spaces must 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
$zipfilename = "$this->_export_tmpdir/$zipfilename";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $isActive
- Exclude checks
Line exceeds 120 characters; contains 138 characters Open
public static function register(string $prefix, string $name = '', ?bool $isDefault = false, bool $isActive = true, int $progress = 0)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'isdefault' => (int) $isDefault,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Initialize Export.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$zipfilename = "$languageCode-" . date('YmdHis') . '.zip';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$zip->download($languageCode);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Register language pack information.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function register(string $prefix, string $name = '', ?bool $isDefault = false, bool $isActive = true, int $progress = 0)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'progress' => $progress,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$prefix = trim($prefix);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::trace("Deregistering Language $prefix ... DONE", __METHOD__);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $includeInActive true to include in-active languages also, false (default)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Utils::checkFileAccessForInclusion("languages/$languageCode/_Base.json");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $directDownload True for sending the output as download
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->__initExport($languageCode);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$zip = \App\Zip::createFile($zipfilename);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$langInfo = \App\Language::getLangInfo($prefix);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'active' => (int) $isActive,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
[
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($todir) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->openNode('dependencies');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool|null $isDefault
- Exclude checks
Spaces must 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 ($langInfo = \App\Language::getLangInfo($prefix)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::TABLENAME,
- Exclude checks
Spaces must 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 deregister($prefix)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->where(['active' => 1]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
const TABLENAME = 'vtiger_language';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->_export_modulexml_file = fopen($this->__getManifestFilePath(), 'w');
- Exclude checks
Spaces must 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
'lastupdated' => date('Y-m-d H:i:s'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand->insert(
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'active' => (int) $isActive,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::clear();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get all the language information.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->generateLangMainfest($languageCode);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$zip->addFile($this->__getManifestFilePath(), 'manifest.xml');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->closeNode('module');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$prefix = trim($prefix);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'name' => $name,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* De-Register language pack information.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query = (new \App\Db\Query())->from(self::TABLENAME)->select(['prefix', 'name']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$languages = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $zipfilename
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- 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
if (strtolower($prefix) === strtolower(\App\Language::DEFAULT_LANG)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
asort($languages);
- Exclude checks
The method __initExport is not named in camelCase. Open
public function __initExport($languageCode, $moduleInstance = null)
{
// Security check to ensure file is withing the web folder.
Utils::checkFileAccessForInclusion("languages/$languageCode/_Base.json");
$this->_export_modulexml_file = fopen($this->__getManifestFilePath(), 'w');
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}