src/Shop/OrderMetafield.php

Summary

Maintainability
A
1 hr
Test Coverage

Method init has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function init()
    {
        $this->_a['table'] = 'shop_order_metafields';
        $this->_a['verbose'] = 'Shop_OrderMetafield';
        $this->_a['cols'] = array(
Severity: Minor
Found in src/Shop/OrderMetafield.php - About 1 hr to fix

    Missing class import via use statement (line '76', column '22').
    Open

            $where = new Pluf_SQL('`key`=%s AND `order_id`=%s', array(
    Severity: Minor
    Found in src/Shop/OrderMetafield.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

    Missing class import via use statement (line '75', column '22').
    Open

            $model = new Shop_OrderMetafield();
    Severity: Minor
    Found in src/Shop/OrderMetafield.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

    Define a constant instead of duplicating this literal "editable" 5 times.
    Open

                    'editable' => false
    Severity: Critical
    Found in src/Shop/OrderMetafield.php by sonar-php

    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 "Varchar" 3 times.
    Open

                    'type' => 'Varchar',
    Severity: Critical
    Found in src/Shop/OrderMetafield.php by sonar-php

    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 "is_null" 5 times.
    Open

                    'is_null' => false,
    Severity: Critical
    Found in src/Shop/OrderMetafield.php by sonar-php

    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.

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

    class Shop_OrderMetafield extends Pluf_Model
    Severity: Minor
    Found in src/Shop/OrderMetafield.php by phpcodesniffer

    The class Shop_OrderMetafield is not named in CamelCase.
    Open

    class Shop_OrderMetafield extends Pluf_Model
    {
    
        /**
         *
    Severity: Minor
    Found in src/Shop/OrderMetafield.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 "init"
    Open

        function init()
    Severity: Minor
    Found in src/Shop/OrderMetafield.php by phpcodesniffer

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

    class Shop_OrderMetafield extends Pluf_Model
    Severity: Minor
    Found in src/Shop/OrderMetafield.php by phpcodesniffer

    There are no issues that match your filters.

    Category
    Status