src/ELearn/Form/PartUpdate.php

Summary

Maintainability
A
0 mins
Test Coverage

The method save has a boolean flag argument $commit, which is a certain sign of a Single Responsibility Principle violation.
Open

    function save($commit = true)
Severity: Minor
Found in src/ELearn/Form/PartUpdate.php by phpmd

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 '22', column '37').
Open

        $this->fields['file'] = new Pluf_Form_Field_File(array(
Severity: Minor
Found in src/ELearn/Form/PartUpdate.php by phpmd

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

Avoid using static access to class 'Pluf' in method 'initFields'.
Open

            'max_size' => Pluf::f('upload_max_size', 2097152),
Severity: Minor
Found in src/ELearn/Form/PartUpdate.php by phpmd

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

Add curly braces around the nested statement(s).
Open

        if (empty($name))
Severity: Critical
Found in src/ELearn/Form/PartUpdate.php by sonar-php

While not technically incorrect, the omission of curly braces can be misleading, and may lead to the introduction of errors during maintenance.

Noncompliant Code Example

if (condition)  // Noncompliant
  executeSomething();

Compliant Solution

if (condition) {
  executeSomething();
}

See

  • MISRA C:2004, 14.8 - The statement forming the body of a switch, while, do ... while or for statement shall be a compound statement
  • MISRA C:2004, 14.9 - An if (expression) construct shall be followed by a compound statement. The else keyword shall be followed by either a compound statement, or another if statement
  • MISRA C++:2008, 6-3-1 - The statement forming the body of a switch, while, do ... while or for statement shall be a compound statement
  • MISRA C++:2008, 6-4-1 - An if (condition) construct shall be followed by a compound statement. The else keyword shall be followed by either a compound statement, or another if statement
  • MISRA C:2012, 15.6 - The body of an iteration-statement or a selection-statement shall be a compound-statement
  • CERT, EXP19-C. - Use braces for the body of an if, for, or while statement
  • CERT, EXP52-J. - Use braces for the body of an if, for, or while statement

Reference to undeclared class \Pluf_Form_Model
Open

        $model = parent::save(false);
Severity: Critical
Found in src/ELearn/Form/PartUpdate.php by phan

Reference to undeclared property \ELearn_Form_PartUpdate->model
Open

        $this->model->_a['cols']['lesson']['blank'] = true;
Severity: Minor
Found in src/ELearn/Form/PartUpdate.php by phan

Call to method __construct from undeclared class \Pluf_Form_Field_File
Open

        $this->fields['file'] = new Pluf_Form_Field_File(array(
Severity: Critical
Found in src/ELearn/Form/PartUpdate.php by phan

Reference to undeclared property \ELearn_Form_PartUpdate->model
Open

                'file_name' => $this->model->id,
Severity: Minor
Found in src/ELearn/Form/PartUpdate.php by phan

Reference to undeclared property \ELearn_Form_PartUpdate->cleaned_data
Open

        if (array_key_exists('file', $this->cleaned_data)) {
Severity: Minor
Found in src/ELearn/Form/PartUpdate.php by phan

Reference to undeclared property \ELearn_Form_PartUpdate->fields
Open

        $this->fields['file'] = new Pluf_Form_Field_File(array(
Severity: Minor
Found in src/ELearn/Form/PartUpdate.php by phan

Reference to undeclared class \Pluf_Form_Model
Open

        parent::initFields($extra);
Severity: Critical
Found in src/ELearn/Form/PartUpdate.php by phan

Reference to undeclared property \ELearn_Form_PartUpdate->model
Open

                'upload_path' => $this->model->file_path,
Severity: Minor
Found in src/ELearn/Form/PartUpdate.php by phan

Reference to undeclared property \ELearn_Form_PartUpdate->data
Open

            $myFile = $this->data['file'];
Severity: Minor
Found in src/ELearn/Form/PartUpdate.php by phan

Reference to undeclared property \ELearn_Form_PartUpdate->cleaned_data
Open

        $name = $this->cleaned_data['name'];
Severity: Minor
Found in src/ELearn/Form/PartUpdate.php by phan

Class extends undeclared class \Pluf_Form_Model
Open

class ELearn_Form_PartUpdate extends Pluf_Form_Model
Severity: Critical
Found in src/ELearn/Form/PartUpdate.php by phan

Reference to undeclared property \ELearn_Form_PartUpdate->model
Open

        $this->model = $extra['model'];
Severity: Minor
Found in src/ELearn/Form/PartUpdate.php by phan

Call to method f from undeclared class \Pluf
Open

            'max_size' => Pluf::f('upload_max_size', 2097152),
Severity: Critical
Found in src/ELearn/Form/PartUpdate.php by phan

Reference to undeclared property \ELearn_Form_PartUpdate->model
Open

        if (strcmp($name, $this->model->name) === 0) {
Severity: Minor
Found in src/ELearn/Form/PartUpdate.php by phan

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class ELearn_Form_PartUpdate extends Pluf_Form_Model

The class ELearn_Form_PartUpdate is not named in CamelCase.
Open

class ELearn_Form_PartUpdate extends Pluf_Form_Model
{

    public function initFields($extra = array())
    {
Severity: Minor
Found in src/ELearn/Form/PartUpdate.php by phpmd

CamelCaseClassName

Since: 0.2

It is considered best practice to use the CamelCase notation to name classes.

Example

class class_name {
}

Source

Visibility must be declared on method "save"
Open

    function save($commit = true)

Method name "ELearn_Form_PartUpdate::clean_name" is not in camel caps format
Open

    public function clean_name()

Inline control structures are not allowed
Open

        if (empty($name))

Line exceeds 120 characters; contains 123 characters
Open

 * با استفاده از این فرم می‌توان اطلاعات یک محتوا را به روزرسانی کرد.

Whitespace found at end of line
Open

 *        

Class name "ELearn_Form_PartUpdate" is not in camel caps format
Open

class ELearn_Form_PartUpdate extends Pluf_Form_Model

The method clean_name is not named in camelCase.
Open

    public function clean_name()
    {
        $name = $this->cleaned_data['name'];
        if (empty($name))
            return null;
Severity: Minor
Found in src/ELearn/Form/PartUpdate.php by phpmd

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

There are no issues that match your filters.

Category
Status