midasplatform/Midas

View on GitHub
core/controllers/components/InternationalizationComponent.php

Summary

Maintainability
A
2 hrs
Test Coverage

Function translate has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public static function translate($text)
    {
        if ((int) Zend_Registry::get('configGlobal')->get('internationalization', 0) === 1) {
            /** @var SettingModel $settingModel */
            $settingModel = MidasLoader::loadModel('Setting');
Severity: Minor
Found in core/controllers/components/InternationalizationComponent.php - About 2 hrs to fix

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

Avoid using static access to class 'MidasLoader' in method 'translate'.
Open

            $settingModel = MidasLoader::loadModel('Setting');

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 'Zend_Registry' in method 'translate'.
Open

                $translate = Zend_Registry::get('translator');

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 'Zend_Registry' in method 'translate'.
Open

                    $translators = Zend_Registry::get('translatorsModules');

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

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

class InternationalizationComponent extends AppComponent

The property $_instance is not named in camelCase.
Open

class InternationalizationComponent extends AppComponent
{
    /** @var null|InternationalizationComponent */
    private static $_instance = null;

CamelCasePropertyName

Since: 0.2

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

Example

class ClassName {
    protected $property_name;
}

Source

Property name "$_instance" should not be prefixed with an underscore to indicate visibility
Open

    private static $_instance = null;

The variable $new_text is not named in camelCase.
Open

    public static function translate($text)
    {
        if ((int) Zend_Registry::get('configGlobal')->get('internationalization', 0) === 1) {
            /** @var SettingModel $settingModel */
            $settingModel = MidasLoader::loadModel('Setting');

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 $new_text is not named in camelCase.
Open

    public static function translate($text)
    {
        if ((int) Zend_Registry::get('configGlobal')->get('internationalization', 0) === 1) {
            /** @var SettingModel $settingModel */
            $settingModel = MidasLoader::loadModel('Setting');

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 $new_text is not named in camelCase.
Open

    public static function translate($text)
    {
        if ((int) Zend_Registry::get('configGlobal')->get('internationalization', 0) === 1) {
            /** @var SettingModel $settingModel */
            $settingModel = MidasLoader::loadModel('Setting');

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 $new_text is not named in camelCase.
Open

    public static function translate($text)
    {
        if ((int) Zend_Registry::get('configGlobal')->get('internationalization', 0) === 1) {
            /** @var SettingModel $settingModel */
            $settingModel = MidasLoader::loadModel('Setting');

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 $new_text is not named in camelCase.
Open

    public static function translate($text)
    {
        if ((int) Zend_Registry::get('configGlobal')->get('internationalization', 0) === 1) {
            /** @var SettingModel $settingModel */
            $settingModel = MidasLoader::loadModel('Setting');

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