Method __construct
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct()
{
$this->exec = \function_exists('exec');
$this->climate = new \League\CLImate\CLImate();
if (!$this->exec) {
Function showHelp
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
private function showHelp(): void
{
if ($this->climate->arguments->defined('module')) {
$module = $this->climate->arguments->get('module');
$className = "\\App\\Cli\\{$module}";
- 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 showHelp
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function showHelp(): void
{
if ($this->climate->arguments->defined('module')) {
$module = $this->climate->arguments->get('module');
$className = "\\App\\Cli\\{$module}";
Function __construct
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function __construct()
{
$this->exec = \function_exists('exec');
$this->climate = new \League\CLImate\CLImate();
if (!$this->exec) {
- 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 __construct() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10. Open
public function __construct()
{
$this->exec = \function_exists('exec');
$this->climate = new \League\CLImate\CLImate();
if (!$this->exec) {
- 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 16 to the 15 allowed. Open
private function showHelp(): void
- 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
Missing class import via use statement (line '31', column '24'). Open
$this->climate = new \League\CLImate\CLImate();
- 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 __construct has a boolean flag argument $full, which is a certain sign of a Single Responsibility Principle violation. Open
public function exec($command, $full = 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 '138', column '16'). Open
foreach (new \DirectoryIterator(ROOT_DIRECTORY . '/app/Cli') 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 '33', column '32'). Open
$this->climate->setUtil(new \League\CLImate\Util\UtilFactory(new class() extends \League\CLImate\Util\System\System {
- 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 actionsList uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
\call_user_func([$instance, $action]);
}
- 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 '__construct'. Open
$this->climate->white('Version: ' . Version::get() . ' | CRM URL: ' . \Config\Main::$site_URL);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\User' in method '__construct'. Open
\App\User::setCurrentUserId(\Users::getActiveAdminId());
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Users' in method '__construct'. Open
\App\User::setCurrentUserId(\Users::getActiveAdminId());
- 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 __construct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->modulesList();
}
- 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 showHelp uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->climate->white('Action list for module ' . $this->climate->arguments->get('module'));
$this->climate->columns(array_merge([' > Action name <' => ' > Description <'], $instance->methods));
$this->climate->lightGreen()->border('─', 200);
foreach (array_keys($instance->methods) as $method) {
- 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\Language' in method '__construct'. Open
\App\Language::setTemporaryLanguage('en-US');
- 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 showHelp uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$modules = $this->getModulesList();
$modules = array_keys($modules);
$this->climate->white('Modules list:')->columns($modules);
$this->climate->lightGreen()->border('─', 200);
- 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
Remove this unused private "getModulesList" method. Open
private function getModulesList(): array
- Read upRead up
- Exclude checks
private
methods that are never executed are dead code: unnecessary, inoperative code that should be removed. Cleaning out dead code
decreases the size of the maintained codebase, making it easier to understand the program and preventing bugs from being introduced.
Noncompliant Code Example
public class Foo { private function Foo() {} // Compliant, private empty constructor intentionally used to prevent any direct instantiation of a class. public static function doSomething() { $foo = new Foo(); ... } private function unusedPrivateFunction() { // Noncompliant } }
Compliant Solution
public class Foo { private function Foo(){} // Compliant, private empty constructor intentionally used to prevent any direct instantiation of a class. public static function doSomething() { $foo = new Foo(); } }
See
- CERT, MSC07-CPP. - Detect and remove dead code
Define a constant instead of duplicating this literal "error" 6 times. Open
$this->climate->to('error')->lightRed('Error: YetiForce CLI works only on the OS user who owns the CRM files');
- 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.
Remove this unused private "showHelp" method. Open
private function showHelp(): void
- Read upRead up
- Exclude checks
private
methods that are never executed are dead code: unnecessary, inoperative code that should be removed. Cleaning out dead code
decreases the size of the maintained codebase, making it easier to understand the program and preventing bugs from being introduced.
Noncompliant Code Example
public class Foo { private function Foo() {} // Compliant, private empty constructor intentionally used to prevent any direct instantiation of a class. public static function doSomething() { $foo = new Foo(); ... } private function unusedPrivateFunction() { // Noncompliant } }
Compliant Solution
public class Foo { private function Foo(){} // Compliant, private empty constructor intentionally used to prevent any direct instantiation of a class. public static function doSomething() { $foo = new Foo(); } }
See
- CERT, MSC07-CPP. - Detect and remove dead code
Define a constant instead of duplicating this literal "description" 3 times. Open
'description' => 'Module 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 "module" 12 times. Open
'module' => [
- 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" 3 times. Open
'prefix' => 'm',
- 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 "action" 12 times. Open
'action' => [
- 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 '$command'. Open
public function exec($command, $full = 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
Avoid unused parameters such as '$full'. Open
public function exec($command, $full = 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 method white
from undeclared class \League\CLImate\CLImate
Open
$this->climate->white('Version: ' . Version::get() . ' | CRM URL: ' . \Config\Main::$site_URL);
- Exclude checks
Reference to instance property arguments
from undeclared class \League\CLImate\CLImate
Open
} elseif ($this->climate->arguments->defined('module') && $this->climate->arguments->defined('action')) {
- Exclude checks
Call to method radio
from undeclared class \League\CLImate\CLImate
Open
$input = $this->climate->radio('Action:', array_merge($instance->methods, ['Exit' => 'Exit']));
- Exclude checks
Call to method white
from undeclared class \League\CLImate\CLImate
Open
$this->climate->white("php cli.php -m $module");
- Exclude checks
Call to method __construct
from undeclared class \League\CLImate\Util\UtilFactory
Open
$this->climate->setUtil(new \League\CLImate\Util\UtilFactory(new class() extends \League\CLImate\Util\System\System {
- Exclude checks
Call to method to
from undeclared class \League\CLImate\CLImate
Open
$this->climate->to('error')->lightRed('Error: YetiForce CLI works only on the OS user who owns the CRM files');
- Exclude checks
Reference to instance property arguments
from undeclared class \League\CLImate\CLImate
Open
$this->actionsList($this->climate->arguments->get('module'));
- Exclude checks
Reference to instance property arguments
from undeclared class \League\CLImate\CLImate
Open
$this->climate->to('error')->lightRed("Error: Action '{$this->climate->arguments->get('action')}' does not exist in '{$this->climate->arguments->get('module')}'");
- Exclude checks
Call to method usage
from undeclared class \League\CLImate\CLImate
Open
$this->climate->usage();
- Exclude checks
Reference to instance property arguments
from undeclared class \League\CLImate\CLImate
Open
if ($this->climate->arguments->defined('action') && !empty($this->climate->arguments->get('action'))) {
- Exclude checks
Call to method white
from undeclared class \League\CLImate\CLImate
Open
$this->climate->white('Modules list:')->columns($modules);
- Exclude checks
Call to method __construct
from undeclared class \League\CLImate\CLImate
Open
$this->climate = new \League\CLImate\CLImate();
- Exclude checks
Reference to instance property arguments
from undeclared class \League\CLImate\CLImate
Open
if ($this->climate->arguments->defined('help')) {
- Exclude checks
Reference to instance property arguments
from undeclared class \League\CLImate\CLImate
Open
$this->climate->to('error')->lightRed("Error: Module '{$this->climate->arguments->get('module')}' does not exist");
- Exclude checks
Call to method white
from undeclared class \League\CLImate\CLImate
Open
$this->climate->white("php cli.php -m $module -a $method");
- Exclude checks
Call to method lightGreen
from undeclared class \League\CLImate\CLImate
Open
$this->climate->lightGreen()->border('─', 200);
- Exclude checks
Call to method clear
from undeclared class \League\CLImate\CLImate
Open
$this->climate->clear();
- Exclude checks
Call to method lightGreen
from undeclared class \League\CLImate\CLImate
Open
$this->climate->lightGreen()->border('─', 200);
- Exclude checks
Call to method setUtil
from undeclared class \League\CLImate\CLImate
Open
$this->climate->setUtil(new \League\CLImate\Util\UtilFactory(new class() extends \League\CLImate\Util\System\System {
- Exclude checks
Call to method lightGreen
from undeclared class \League\CLImate\CLImate
Open
$this->climate->lightGreen()->border('─', 200);
- Exclude checks
Call to method usage
from undeclared class \League\CLImate\CLImate
Open
$this->climate->usage();
- Exclude checks
Reference to instance property arguments
from undeclared class \League\CLImate\CLImate
Open
if ($this->climate->arguments->defined('module')) {
- Exclude checks
Reference to instance property arguments
from undeclared class \League\CLImate\CLImate
Open
\call_user_func([$instance, $this->climate->arguments->get('action')]);
- Exclude checks
Reference to static property site_URL
from undeclared class \Config\Main
Open
$this->climate->white('Version: ' . Version::get() . ' | CRM URL: ' . \Config\Main::$site_URL);
- Exclude checks
Call to method backgroundBlue
from undeclared class \League\CLImate\CLImate
Open
$this->climate->backgroundBlue()->out($instance->methods[$this->climate->arguments->get('action')]);
- Exclude checks
Call to method to
from undeclared class \League\CLImate\CLImate
Open
$this->climate->to('error')->lightRed('Error: YetiForce CLI only works from the operating system console (CLI)');
- Exclude checks
Call to method setCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
\App\User::setCurrentUserId(\Users::getActiveAdminId());
- Exclude checks
Reference to instance property arguments
from undeclared class \League\CLImate\CLImate
Open
$this->climate->backgroundBlue()->out($instance->methods[$this->climate->arguments->get('action')]);
- Exclude checks
Call to method clear
from undeclared class \League\CLImate\CLImate
Open
$this->climate->clear();
- Exclude checks
Reference to instance property arguments
from undeclared class \League\CLImate\CLImate
Open
$this->climate->arguments->add([
- Exclude checks
Reference to instance property arguments
from undeclared class \League\CLImate\CLImate
Open
$this->climate->arguments->parse();
- Exclude checks
Call to method to
from undeclared class \League\CLImate\CLImate
Open
$this->climate->to('error')->lightRed("Error: Action '{$this->climate->arguments->get('action')}' does not exist in '{$this->climate->arguments->get('module')}'");
- Exclude checks
Reference to instance property arguments
from undeclared class \League\CLImate\CLImate
Open
\call_user_func([$instance, $this->climate->arguments->get('action')]);
- Exclude checks
Call to method to
from undeclared class \League\CLImate\CLImate
Open
$this->climate->to('error')->lightRed("Error: Action '{$this->climate->arguments->get('action')}' does not exist in '{$this->climate->arguments->get('module')}'");
- Exclude checks
Call to method white
from undeclared class \League\CLImate\CLImate
Open
$this->climate->white('Action list for module ' . $this->climate->arguments->get('module'));
- Exclude checks
Reference to instance property arguments
from undeclared class \League\CLImate\CLImate
Open
if (!method_exists($instance, $this->climate->arguments->get('action'))) {
- Exclude checks
Reference to instance property arguments
from undeclared class \League\CLImate\CLImate
Open
$this->climate->white('Action list for module ' . $this->climate->arguments->get('module'));
- Exclude checks
Reference to instance property arguments
from undeclared class \League\CLImate\CLImate
Open
} elseif ($this->climate->arguments->defined('module') && !$this->climate->arguments->defined('action') && !empty($this->climate->arguments->get('module'))) {
- Exclude checks
Reference to instance property arguments
from undeclared class \League\CLImate\CLImate
Open
if (!method_exists($instance, $this->climate->arguments->get('action'))) {
- Exclude checks
Call to method lightGreen
from undeclared class \League\CLImate\CLImate
Open
$this->climate->lightGreen()->border('─', 200);
- Exclude checks
Property \App\Cli->climate
has undeclared type \League\CLImate\CLImate
Open
public $climate;
- Exclude checks
Class extends undeclared class \League\CLImate\Util\System\System
(Did you mean class \App\Cli\System) Open
$this->climate->setUtil(new \League\CLImate\Util\UtilFactory(new class() extends \League\CLImate\Util\System\System {
- Exclude checks
Call to method usage
from undeclared class \League\CLImate\CLImate
Open
$this->climate->usage();
- Exclude checks
Call to method border
from undeclared class \League\CLImate\CLImate
Open
$this->climate->border('─', 200);
- Exclude checks
Call to method to
from undeclared class \League\CLImate\CLImate
Open
$this->climate->to('error')->lightRed("Error: Module '$module' does not exist");
- Exclude checks
Call to method columns
from undeclared class \League\CLImate\CLImate
Open
$this->climate->columns(array_merge([' > Action name <' => ' > Description <'], $instance->methods));
- Exclude checks
Call to method lightGreen
from undeclared class \League\CLImate\CLImate
Open
$this->climate->lightGreen()->border('─', 200);
- Exclude checks
Reference to instance property arguments
from undeclared class \League\CLImate\CLImate
Open
$className = "\\App\\Cli\\{$this->climate->arguments->get('module')}";
- Exclude checks
Call to method to
from undeclared class \League\CLImate\CLImate
Open
$this->climate->to('error')->lightRed("Error: Module '{$this->climate->arguments->get('module')}' does not exist");
- Exclude checks
Call to method lightGreen
from undeclared class \League\CLImate\CLImate
Open
$this->climate->lightGreen()->border('─', 200);
- Exclude checks
Call to method radio
from undeclared class \League\CLImate\CLImate
Open
$input = $this->climate->radio('Module:', $modules);
- Exclude checks
Reference to instance property arguments
from undeclared class \League\CLImate\CLImate
Open
$module = $this->climate->arguments->get('module');
- Exclude checks
Reference to instance property arguments
from undeclared class \League\CLImate\CLImate
Open
$this->climate->to('error')->lightRed("Error: Action '{$this->climate->arguments->get('action')}' does not exist in '{$this->climate->arguments->get('module')}'");
- Exclude checks
Call to method clear
from undeclared class \League\CLImate\CLImate
Open
$this->climate->clear();
- Exclude checks
Call to method tab
from undeclared class \League\CLImate\CLImate
Open
$this->climate->tab(2)->lightGreen('Y e t i F o r c e C L I');
- Exclude checks
Call to method lightGreen
from undeclared class \League\CLImate\CLImate
Open
$this->climate->lightGreen()->border('─', 200);
- 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
$this->climate->usage();
- Exclude checks
Spaces must 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 (!$this->exec) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 40;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->clear();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->lightGreen()->border('─', 200);
- Exclude checks
Spaces must 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
* Show modules list.
- Exclude checks
Spaces must 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->exec = \function_exists('exec');
- Exclude checks
Spaces must 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' => 'h',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->to('error')->lightRed("Error: Action '{$this->climate->arguments->get('action')}' does not exist in '{$this->climate->arguments->get('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
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('Exit' === $module || empty($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
*/
- Exclude checks
Spaces must 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->climate->tab(2)->lightGreen('Y e t i F o r c e C L I');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'help' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->showHelp();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->border('─', 200);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var bool Php support exec */
- Exclude checks
Spaces must 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->climate = new \League\CLImate\CLImate();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function __construct()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$this->exec) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->setUtil(new \League\CLImate\Util\UtilFactory(new class() extends \League\CLImate\Util\System\System {
- Exclude checks
Spaces must 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
'description' => 'Module action name',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\PHP_SAPI !== 'cli') {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->arguments->parse();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance = new $className($this);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->backgroundBlue()->out($instance->methods[$this->climate->arguments->get('action')]);
- Exclude checks
Spaces must 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
'prefix' => 'm',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'description' => 'Module 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
public function modulesList(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->showHelp();
- Exclude checks
Spaces must 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
* Construct.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function width()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->arguments->add([
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'action' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ($this->climate->arguments->defined('module') && $this->climate->arguments->defined('action')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->actionsList($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
return '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->to('error')->lightRed('Error: YetiForce CLI only works from the operating system console (CLI)');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\User::setCurrentUserId(\Users::getActiveAdminId());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Language::setTemporaryLanguage('en-US');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'prefix' => 'a',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->climate->arguments->defined('help')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\call_user_func([$instance, $this->climate->arguments->get('action')]);
- 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
$this->modulesList();
- 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
return 120;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$className = "\\App\\Cli\\{$this->climate->arguments->get('module')}";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$module = $input->prompt();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $climate;
- Exclude checks
Spaces must 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
Line exceeds 120 characters; contains 179 characters Open
$this->climate->to('error')->lightRed("Error: Action '{$this->climate->arguments->get('action')}' does not exist in '{$this->climate->arguments->get('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
$this->climate->usage();
- Exclude checks
Line exceeds 120 characters; contains 129 characters Open
$this->climate->setUtil(new \League\CLImate\Util\UtilFactory(new class() extends \League\CLImate\Util\System\System {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 124 characters Open
$this->climate->to('error')->lightRed('Error: YetiForce CLI works only on the OS user who owns the CRM files');
- 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
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$modules = $this->getModulesList();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var \League\CLImate\CLImate CLImate 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
protected function systemHasAnsiSupport()
- Exclude checks
Spaces must 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->climate->to('error')->lightRed('Error: YetiForce CLI works only on the OS user who owns the CRM files');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$input = $this->climate->radio('Module:', $modules);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string[]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $exec = true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function exec($command, $full = false)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\function_exists('getmyuid') && getmyuid() !== fileowner(__FILE__)) {
- Exclude checks
Line exceeds 120 characters; contains 125 characters Open
$this->climate->to('error')->lightRed('Error: YetiForce CLI only works from the operating system console (CLI)');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->lightGreen()->border('─', 200);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->white('Version: ' . Version::get() . ' | CRM URL: ' . \Config\Main::$site_URL);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'description' => 'Help',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->actionsList($this->climate->arguments->get('module'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!method_exists($instance, $this->climate->arguments->get('action'))) {
- Exclude checks
Spaces must 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
$action = $input->prompt();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$className = "\\App\\Cli\\{$module}";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!class_exists($className)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->lightGreen()->border('─', 200);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach (array_keys($instance->methods) as $method) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!class_exists($className)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->to('error')->lightRed("Error: Module '{$this->climate->arguments->get('module')}' does not exist");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance->helpMode = true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function height()
- Exclude checks
Spaces must 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->climate->lightGreen()->border('─', 200);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ($this->climate->arguments->defined('module') && !$this->climate->arguments->defined('action') && !empty($this->climate->arguments->get('module'))) {
- Exclude checks
Line exceeds 120 characters; contains 166 characters Open
} elseif ($this->climate->arguments->defined('module') && !$this->climate->arguments->defined('action') && !empty($this->climate->arguments->get('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
return;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->clear();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get modules list.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$modules = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->to('error')->lightRed("Error: Module '$module' does not exist");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$module = $this->climate->arguments->get('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
'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
$modules['Exit'] = 'Exit';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private function showHelp(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->climate->arguments->defined('action') && !empty($this->climate->arguments->get('action'))) {
- 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
if ($fileInfo->isFile() && 'Base' !== $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
$instance = new $className($this);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$this->exec) {
- 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->climate->clear();
- Exclude checks
Spaces must 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_user_func([$instance, $action]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!method_exists($instance, $this->climate->arguments->get('action'))) {
- Exclude checks
Line exceeds 120 characters; contains 131 characters Open
$this->climate->to('error')->lightRed("Error: Module '{$this->climate->arguments->get('module')}' does not exist");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance = new $className($this);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($modules as $module) {
- Exclude checks
Line exceeds 120 characters; contains 183 characters Open
$this->climate->to('error')->lightRed("Error: Action '{$this->climate->arguments->get('action')}' does not exist in '{$this->climate->arguments->get('module')}'");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->white("php cli.php -m $module");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->lightGreen()->border('─', 200);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$modules = $this->getModulesList();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach (new \DirectoryIterator(ROOT_DIRECTORY . '/app/Cli') as $fileInfo) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $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
$this->climate->lightGreen()->border('─', 200);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must 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
* Show help.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->climate->arguments->defined('module')) {
- 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
$modules = array_keys($modules);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$className = "\\App\\Cli\\{$module}";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$input = $this->climate->radio('Action:', array_merge($instance->methods, ['Exit' => 'Exit']));
- Exclude checks
Spaces must 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
* Show actions list.
- 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
$this->showHelp();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('Exit' === $action) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private function getModulesList(): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance = new $className($this);
- Exclude checks
Spaces must 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 void
- Exclude checks
Spaces must 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->climate->white("php cli.php -m $module -a $method");
- Exclude checks
Spaces must 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 $modules;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function actionsList(string $module): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$className = "\\App\\Cli\\{$module}";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->modulesList();
- 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
$this->climate->white('Action list for module ' . $this->climate->arguments->get('module'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->white('Modules list:')->columns($modules);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$module = $fileInfo->getBasename('.php');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->usage();
- Exclude checks
Spaces must 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->climate->to('error')->lightRed("Error: Action '{$this->climate->arguments->get('action')}' does not exist in '{$this->climate->arguments->get('module')}'");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\call_user_func([$instance, $this->climate->arguments->get('action')]);
- 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
$this->climate->columns(array_merge([' > Action name <' => ' > Description <'], $instance->methods));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$modules[$module] = $instance->moduleName;
- 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
$this->climate->lightGreen()->border('─', 200);
- Exclude checks