src/Notifier/Engine/SmsIr.php

Summary

Maintainability
A
1 hr
Test Coverage

Method sendSms has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function sendSms($data)
    {
        // Mobile number
        $receiver = array_key_exists('receiver', $data) ? $data['receiver'] : null;
        if (! $receiver) {
Severity: Minor
Found in src/Notifier/Engine/SmsIr.php - About 1 hr to fix

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

                throw new Notifier_Exception_NotificationSend($response->getBody()->getContents());
    Severity: Minor
    Found in src/Notifier/Engine/SmsIr.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 '73', column '23').
    Open

            $client = new GuzzleHttp\Client();
    Severity: Minor
    Found in src/Notifier/Engine/SmsIr.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 '121', column '23').
    Open

            $client = new GuzzleHttp\Client();
    Severity: Minor
    Found in src/Notifier/Engine/SmsIr.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 '93', column '23').
    Open

                throw new Notifier_Exception_NotificationSend('Phone is not determined to send notification SMS.');
    Severity: Minor
    Found in src/Notifier/Engine/SmsIr.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 '127', column '23').
    Open

                throw new \Pluf\Exception($response->getBody()->getContents());
    Severity: Minor
    Found in src/Notifier/Engine/SmsIr.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 'Tenant_Service' in method 'getToken'.
    Open

            $secKey = Tenant_Service::setting(self::ENGINE_PARAMETER_SECRET_KEY, '');
    Severity: Minor
    Found in src/Notifier/Engine/SmsIr.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 sendSms uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                $param['MobileNumber'] = $receiver;
                $param['Code'] = $code;
            }
    Severity: Minor
    Found in src/Notifier/Engine/SmsIr.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 'Tenant_Service' in method 'sendSms'.
    Open

            $templateId = (int) Tenant_Service::setting(self::ENGINE_PARAMETER_TEMPLATE_ID, 0);
    Severity: Minor
    Found in src/Notifier/Engine/SmsIr.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 'Tenant_Service' in method 'getToken'.
    Open

            $apiKey = Tenant_Service::setting(self::ENGINE_PARAMETER_API_KEY, '');
    Severity: Minor
    Found in src/Notifier/Engine/SmsIr.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

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

    class Notifier_Engine_SmsIr extends Notifier_Engine

    The class Notifier_Engine_SmsIr is not named in CamelCase.
    Open

    class Notifier_Engine_SmsIr extends Notifier_Engine
    {
        const ENGINE_PARAMETER_API_KEY = 'notifier.engine.SmsIr.ApiKey';
        const ENGINE_PARAMETER_SECRET_KEY = 'notifier.engine.SmsIr.SecretKey';
        const ENGINE_PARAMETER_TEMPLATE_ID = 'notifier.engine.SmsIr.TemplateId';
    Severity: Minor
    Found in src/Notifier/Engine/SmsIr.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

    Whitespace found at end of line
    Open

     *        

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

    class Notifier_Engine_SmsIr extends Notifier_Engine

    There are no issues that match your filters.

    Category
    Status