core/modules/user/model/UserModel.php

Summary

Maintainability
A
0 mins
Test Coverage

The class UserModel has 13 public methods. Consider refactoring UserModel to keep number of public methods under 10.
Open

class UserModel extends Ajde_User
{
    public $usernameField = 'username';
    public $passwordField = 'password';

Severity: Minor
Found in core/modules/user/model/UserModel.php by phpmd

TooManyPublicMethods

Since: 0.1

A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

By default it ignores methods starting with 'get' or 'set'.

Example

Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

Missing class import via use statement (line '146', column '23').
Open

        $mailer = new Ajde_Mailer();
Severity: Minor
Found in core/modules/user/model/UserModel.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 'Ajde_Event' in method 'registerEvents'.
Open

            Ajde_Event::register($this, 'afterCrudLoaded', 'parseForCrud');
Severity: Minor
Found in core/modules/user/model/UserModel.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

Avoid using static access to class 'Ajde_Fs_File' in method 'saveFileFromWeb'.
Open

            $extension = Ajde_Fs_File::getExtensionFromMime($mimeType);
Severity: Minor
Found in core/modules/user/model/UserModel.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

Avoid using static access to class 'Ajde_Component_Image' in method 'displayAvatar'.
Open

            return Ajde_Component_Image::getImageTag(AVATAR_DIR.$this->getAvatar(), $width, $width, true, $class);
Severity: Minor
Found in core/modules/user/model/UserModel.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

Avoid using static access to class 'Ajde_Http_Curl' in method 'saveFileFromWeb'.
Open

            $image = Ajde_Http_Curl::get($this->get($fieldName));
Severity: Minor
Found in core/modules/user/model/UserModel.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

Avoid using static access to class 'Ajde_Resource_Image_Gravatar' in method 'displayGravatar'.
Open

        return Ajde_Resource_Image_Gravatar::get($this->getEmail(), $width, 'identicon', 'g', true,
            ['class' => $class]);
Severity: Minor
Found in core/modules/user/model/UserModel.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

The method displayAvatar uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            return $this->displayGravatar($width, $class);
        }
Severity: Minor
Found in core/modules/user/model/UserModel.php by phpmd

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 'Ajde_Event' in method 'registerEvents'.
Open

            Ajde_Event::register($this, 'beforeCrudSave', 'prepareCrudSave');
Severity: Minor
Found in core/modules/user/model/UserModel.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

Avoid using static access to class 'Ajde_Fs_File' in method 'saveFileFromWeb'.
Open

            $mimeType = Ajde_Fs_File::getMimeType($tmp_path);
Severity: Minor
Found in core/modules/user/model/UserModel.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

Avoid using static access to class 'Ajde_Event' in method 'registerEvents'.
Open

        if (!Ajde_Event::has($this, 'afterCrudLoaded', 'parseForCrud')) {
Severity: Minor
Found in core/modules/user/model/UserModel.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

Avoid unused parameters such as '$crud'.
Open

    public function parseForCrud(Ajde_Crud $crud)
Severity: Minor
Found in core/modules/user/model/UserModel.php by phpmd

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 '$controller'.
Open

    public function prepareCrudSave(Ajde_Controller $controller, Ajde_Crud $crud)
Severity: Minor
Found in core/modules/user/model/UserModel.php by phpmd

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 '$crud'.
Open

    public function prepareCrudSave(Ajde_Controller $controller, Ajde_Crud $crud)
Severity: Minor
Found in core/modules/user/model/UserModel.php by phpmd

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 variables with short names like $fh. Configured minimum length is 3.
Open

            $fh = fopen($tmp_path, 'wb');
Severity: Minor
Found in core/modules/user/model/UserModel.php by phpmd

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

The variable $tmp_path is not named in camelCase.
Open

    private function saveFileFromWeb($fieldName)
    {
        if ($this->has($fieldName) &&
            (substr(strtolower($this->get($fieldName)), 0, 7) === 'http://' ||
                substr(strtolower($this->get($fieldName)), 0, 8) === 'https://')
Severity: Minor
Found in core/modules/user/model/UserModel.php by phpmd

CamelCaseVariableName

Since: 0.2

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

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $tmp_path is not named in camelCase.
Open

    private function saveFileFromWeb($fieldName)
    {
        if ($this->has($fieldName) &&
            (substr(strtolower($this->get($fieldName)), 0, 7) === 'http://' ||
                substr(strtolower($this->get($fieldName)), 0, 8) === 'https://')
Severity: Minor
Found in core/modules/user/model/UserModel.php by phpmd

CamelCaseVariableName

Since: 0.2

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

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $tmp_path is not named in camelCase.
Open

    private function saveFileFromWeb($fieldName)
    {
        if ($this->has($fieldName) &&
            (substr(strtolower($this->get($fieldName)), 0, 7) === 'http://' ||
                substr(strtolower($this->get($fieldName)), 0, 8) === 'https://')
Severity: Minor
Found in core/modules/user/model/UserModel.php by phpmd

CamelCaseVariableName

Since: 0.2

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

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $tmp_path is not named in camelCase.
Open

    private function saveFileFromWeb($fieldName)
    {
        if ($this->has($fieldName) &&
            (substr(strtolower($this->get($fieldName)), 0, 7) === 'http://' ||
                substr(strtolower($this->get($fieldName)), 0, 8) === 'https://')
Severity: Minor
Found in core/modules/user/model/UserModel.php by phpmd

CamelCaseVariableName

Since: 0.2

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

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

There are no issues that match your filters.

Category
Status