src/Notifier/Engine.php

Summary

Maintainability
A
1 hr
Test Coverage

Method getGeneralParam has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getGeneralParam()
    {
        $params = array();
        $params[] = array(
            'name' => 'title',
Severity: Minor
Found in src/Notifier/Engine.php - About 1 hr to fix

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

                throw new Notifier_Exception_EngineLoad('NotifierEngine class must be placed in engine package.');
    Severity: Minor
    Found in src/Notifier/Engine.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 "description" 8 times.
    Open

                'description' => $this->getDescription(),
    Severity: Critical
    Found in src/Notifier/Engine.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 "defaultValue" 3 times.
    Open

                'defaultValue' => 'no title',
    Severity: Critical
    Found in src/Notifier/Engine.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 "visible" 4 times.
    Open

                'visible' => true,
    Severity: Critical
    Found in src/Notifier/Engine.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 "symbol" 6 times.
    Open

                'symbol' => $this->getSymbol()
    Severity: Critical
    Found in src/Notifier/Engine.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 "String" 3 times.
    Open

                'type' => 'String',
    Severity: Critical
    Found in src/Notifier/Engine.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 "priority" 4 times.
    Open

                'priority' => 5,
    Severity: Critical
    Found in src/Notifier/Engine.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 "validators" 3 times.
    Open

                'validators' => [
    Severity: Critical
    Found in src/Notifier/Engine.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 "title" 9 times.
    Open

                'title' => $this->getTitle(),
    Severity: Critical
    Found in src/Notifier/Engine.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 "children" 3 times.
    Open

                'children' => []
    Severity: Critical
    Found in src/Notifier/Engine.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 "editable" 4 times.
    Open

                'editable' => true,
    Severity: Critical
    Found in src/Notifier/Engine.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.

    Avoid unused parameters such as '$data'.
    Open

        public function send($data){
    Severity: Minor
    Found in src/Notifier/Engine.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

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

    class Notifier_Engine implements JsonSerializable
    Severity: Minor
    Found in src/Notifier/Engine.php by phpcodesniffer

    The class Notifier_Engine is not named in CamelCase.
    Open

    class Notifier_Engine implements JsonSerializable
    {
        const ENGINE_PREFIX = 'notifier_engine_';
        
        /**
    Severity: Minor
    Found in src/Notifier/Engine.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

    Line exceeds 120 characters; contains 121 characters
    Open

         * This functions should be overrided by implementors which have some other parameters other than general parameters.
    Severity: Minor
    Found in src/Notifier/Engine.php by phpcodesniffer

    Whitespace found at end of line
    Open

         * 
    Severity: Minor
    Found in src/Notifier/Engine.php by phpcodesniffer

    Whitespace found at end of line
    Open

         * 
    Severity: Minor
    Found in src/Notifier/Engine.php by phpcodesniffer

    Whitespace found at end of line
    Open

         * 
    Severity: Minor
    Found in src/Notifier/Engine.php by phpcodesniffer

    Expected 1 newline at end of file; 0 found
    Open

    }
    Severity: Minor
    Found in src/Notifier/Engine.php by phpcodesniffer

    Whitespace found at end of line
    Open

         * 
    Severity: Minor
    Found in src/Notifier/Engine.php by phpcodesniffer

    Whitespace found at end of line
    Open

     *        
    Severity: Minor
    Found in src/Notifier/Engine.php by phpcodesniffer

    Whitespace found at end of line
    Open

         * 
    Severity: Minor
    Found in src/Notifier/Engine.php by phpcodesniffer

    Whitespace found at end of line
    Open

         * 
    Severity: Minor
    Found in src/Notifier/Engine.php by phpcodesniffer

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

    class Notifier_Engine implements JsonSerializable
    Severity: Minor
    Found in src/Notifier/Engine.php by phpcodesniffer

    Opening brace should be on a new line
    Open

        public function send($data){
    Severity: Minor
    Found in src/Notifier/Engine.php by phpcodesniffer

    There are no issues that match your filters.

    Category
    Status