modules/SMSNotifier/models/Record.php
Avoid using static access to class '\App\Integrations\SMSProvider' in method 'send'. Open
Open
if ($this->isEditable() && ($provider = \App\Integrations\SMSProvider::getDefaultProvider())) {
- 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 '23', column '31'). Open
Open
public function send(): bool
{
$result = false;
if ($this->isEditable() && ($provider = \App\Integrations\SMSProvider::getDefaultProvider())) {
$result = $provider->sendByRecord($this);
- 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
Each class must be in a namespace of at least one level (a top-level vendor name) Open
Open
class SMSNotifier_Record_Model extends Vtiger_Record_Model
- Exclude checks
The class SMSNotifier_Record_Model is not named in CamelCase. Open
Open
class SMSNotifier_Record_Model extends Vtiger_Record_Model
{
/**
* Send sms.
*
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
Spaces must be used to indent lines; tabs are not allowed Open
Open
$this->save();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return $result;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$result = $provider->sendByRecord($this);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Send sms.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public function send(): bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if ($this->isEditable() && ($provider = \App\Integrations\SMSProvider::getDefaultProvider())) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$this->set('smsnotifier_status', $result ? 'PLL_SENT' : 'PLL_FAILED');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$result = false;
- Exclude checks
Class name "SMSNotifier_Record_Model" is not in camel caps format Open
Open
class SMSNotifier_Record_Model extends Vtiger_Record_Model
- Exclude checks