YetiForceCompany/YetiForceCRM

View on GitHub
api/webservice/SMS/SMSAPI/Reception.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

Missing class import via use statement (line '93', column '26').
Open

        $queryGenerator = (new \App\QueryGenerator($this->moduleName));

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 '32', column '14').
Open

            throw new \Api\Core\Exception('No permission - wrong data', 401);

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 '40', column '14').
Open

            throw new \Api\Core\Exception('No permissions for module', 403);

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 '\Api\Core\Module' in method 'checkPermissionToModule'.
Open

        if (!\Api\Core\Module::checkModuleAccess($this->moduleName) || !\App\Privilege::isPermitted($this->moduleName, 'CreateView') || !($provider = \App\Integrations\SMSProvider::getDefaultProvider()) || 'SMSAPI' !== $provider->getName()) {

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 '\Vtiger_Record_Model' in method 'post'.
Open

            && ($recordModel = \Vtiger_Record_Model::getInstanceById($recordId, $this->moduleName))

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 '\Vtiger_Record_Model' in method 'post'.
Open

            $newRecordModel = \Vtiger_Record_Model::getCleanInstance($this->moduleName);

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 '\App\Record' in method 'post'.
Open

        if ($recordId && \App\Record::isExists($recordId, $this->moduleName)

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 assigning values to variables in if clauses and the like (line '97', column '8').
Open

    public function post()
    {
        $msgId = $this->controller->request->getByType('MsgId', \App\Purifier::ALNUM);
        $message = $this->controller->request->getByType('sms_text', \App\Purifier::HTML);
        $smsFrom = $this->controller->request->getByType('sms_from', \App\Purifier::DIGITS);

IfStatementAssignment

Since: 2.7.0

Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

Example

class Foo
{
    public function bar($flag)
    {
        if ($foo = 'bar') { // possible typo
            // ...
        }
        if ($baz = 0) { // always false
            // ...
        }
    }
}

Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

Avoid using static access to class '\App\Integrations\SMSProvider' in method 'checkPermissionToModule'.
Open

        if (!\Api\Core\Module::checkModuleAccess($this->moduleName) || !\App\Privilege::isPermitted($this->moduleName, 'CreateView') || !($provider = \App\Integrations\SMSProvider::getDefaultProvider()) || 'SMSAPI' !== $provider->getName()) {

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 '\App\Privilege' in method 'checkPermissionToModule'.
Open

        if (!\Api\Core\Module::checkModuleAccess($this->moduleName) || !\App\Privilege::isPermitted($this->moduleName, 'CreateView') || !($provider = \App\Integrations\SMSProvider::getDefaultProvider()) || 'SMSAPI' !== $provider->getName()) {

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 assigning values to variables in if clauses and the like (line '39', column '133').
Open

    protected function checkPermissionToModule(): void
    {
        if (!\Api\Core\Module::checkModuleAccess($this->moduleName) || !\App\Privilege::isPermitted($this->moduleName, 'CreateView') || !($provider = \App\Integrations\SMSProvider::getDefaultProvider()) || 'SMSAPI' !== $provider->getName()) {
            throw new \Api\Core\Exception('No permissions for module', 403);
        }

IfStatementAssignment

Since: 2.7.0

Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

Example

class Foo
{
    public function bar($flag)
    {
        if ($foo = 'bar') { // possible typo
            // ...
        }
        if ($baz = 0) { // always false
            // ...
        }
    }
}

Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

Avoid using static access to class '\App\Integrations\SMSProvider' in method 'post'.
Open

        $provider = \App\Integrations\SMSProvider::getProviderByName('SMSAPI');

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

Define a constant instead of duplicating this literal "phone" 3 times.
Open

            && $smsFrom === $provider->setPhone($recordModel->get('phone'))->get('to')

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.

Call to method __construct from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
Open

        $queryGenerator = (new \App\QueryGenerator($this->moduleName));
Severity: Critical
Found in api/webservice/SMS/SMSAPI/Reception.php by phan

Method \Api\SMS\SMSAPI\Reception::post is declared to return array but has no return value
Open

    public function post()

Call to method setFields from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
Open

        $recordId = $queryGenerator->setFields(['id'])->addCondition('msgid', $msgId, 'e')->createQuery()->scalar();
Severity: Critical
Found in api/webservice/SMS/SMSAPI/Reception.php by phan

Possibly zero references to use statement for classlike/namespace OA (\OpenApi\Annotations)
Open

use OpenApi\Annotations as OA;

Spaces must be used for alignment; tabs are not allowed
Open

     *            "url" : "https://www.smsapi.pl/docs"

Spaces must be used for alignment; tabs are not allowed
Open

     *         },

Spaces must be used for alignment; tabs are not allowed
Open

     *                response=200,

Spaces must be used for alignment; tabs are not allowed
Open

     *        @OA\Response(

Spaces must be used for alignment; tabs are not allowed
Open

     *        description="Response",

Spaces must be used for alignment; tabs are not allowed
Open

            && ($recordModel = \Vtiger_Record_Model::getInstanceById($recordId, $this->moduleName))

Spaces must be used for alignment; tabs are not allowed
Open

     *        summary="Receipt of SMS",

Spaces must be used for alignment; tabs are not allowed
Open

     *        ),

Spaces must be used for alignment; tabs are not allowed
Open

     *        @OA\Response(

Spaces must be used for alignment; tabs are not allowed
Open

     *                description="No permissions for module",

Spaces must be used for alignment; tabs are not allowed
Open

     *        type="string",

Spaces must be used for alignment; tabs are not allowed
Open

     */

Spaces must be used for alignment; tabs are not allowed
Open

        $msgId = $this->controller->request->getByType('MsgId', \App\Purifier::ALNUM);

Spaces must be used for alignment; tabs are not allowed
Open

        $recordId = $queryGenerator->setFields(['id'])->addCondition('msgid', $msgId, 'e')->createQuery()->scalar();

Spaces must be used for alignment; tabs are not allowed
Open

            $newRecordModel->set($msgField->getName(), $msgField->getDBValue($message))

Spaces must be used for alignment; tabs are not allowed
Open

                ->set('related_to', $recordModel->get('related_to'))

Spaces must be used for alignment; tabs are not allowed
Open

     *         },

Spaces must be used for alignment; tabs are not allowed
Open

     *        @OA\Response(

Spaces must be used for alignment; tabs are not allowed
Open

     *        schema="SMS_SMSAPI_Post_Reception",

Spaces must be used for alignment; tabs are not allowed
Open

     *            {"ApiKeyAuth" : {}, "token" : {}}

Spaces must be used for alignment; tabs are not allowed
Open

     *        @OA\Response(

Spaces must be used for alignment; tabs are not allowed
Open

     *        ),

Spaces must be used for alignment; tabs are not allowed
Open

     *                response=403,

Spaces must be used for alignment; tabs are not allowed
Open

     *        ),

Spaces must be used for alignment; tabs are not allowed
Open

     *        example="OK"

Spaces must be used for alignment; tabs are not allowed
Open

            $newRecordModel->save();

Spaces must be used for alignment; tabs are not allowed
Open

        echo 'OK';

Spaces must be used for alignment; tabs are not allowed
Open

     *        @OA\Response(

Spaces must be used for alignment; tabs are not allowed
Open

     *                description="`No sent token` OR `Invalid token` OR `wrong data provided in the request`",

Spaces must be used for alignment; tabs are not allowed
Open

     *        example="OK"

Spaces must be used for alignment; tabs are not allowed
Open

     *    ),

Spaces must be used for alignment; tabs are not allowed
Open

     *        path="/webservice/SMS/SMSAPI/Reception",

Spaces must be used for alignment; tabs are not allowed
Open

     *            {"ApiKeyAuth" : {}, "token" : {}}

Spaces must be used for alignment; tabs are not allowed
Open

     *                description="Result",

Spaces must be used for alignment; tabs are not allowed
Open

     *                description="Method Not Allowed",

Spaces must be used for alignment; tabs are not allowed
Open

     *        summary="Receipt of SMS",

Spaces must be used for alignment; tabs are not allowed
Open

     *        ),

Spaces must be used for alignment; tabs are not allowed
Open

    {

Spaces must be used for alignment; tabs are not allowed
Open

        }

Spaces must be used for alignment; tabs are not allowed
Open

    public function post()

Spaces must be used for alignment; tabs are not allowed
Open

                ->set('smsnotifier_status', 'PLL_REPLY')

Spaces must be used for alignment; tabs are not allowed
Open

     *         security={

Spaces must be used for alignment; tabs are not allowed
Open

     *        ),

Spaces must be used for alignment; tabs are not allowed
Open

     *        ),

Spaces must be used for alignment; tabs are not allowed
Open

     *        title="Response",

Spaces must be used for alignment; tabs are not allowed
Open

            && $smsFrom === $provider->setPhone($recordModel->get('phone'))->get('to')

Spaces must be used for alignment; tabs are not allowed
Open

     *                response=401,

Spaces must be used for alignment; tabs are not allowed
Open

        ) {

Spaces must be used for alignment; tabs are not allowed
Open

     *        tags={"SMSAPI"},

Spaces must be used for alignment; tabs are not allowed
Open

     *        externalDocs={

Spaces must be used for alignment; tabs are not allowed
Open

     *                description="Result",

Spaces must be used for alignment; tabs are not allowed
Open

     *        @OA\Response(

Spaces must be used for alignment; tabs are not allowed
Open

     *        @OA\Response(

Spaces must be used for alignment; tabs are not allowed
Open

     *        @OA\Response(

Spaces must be used for alignment; tabs are not allowed
Open

     *        schema="SMS_SMSAPI_Post_Reception",

Spaces must be used for alignment; tabs are not allowed
Open

        $message = $this->controller->request->getByType('sms_text', \App\Purifier::HTML);

Spaces must be used for alignment; tabs are not allowed
Open

        $queryGenerator = (new \App\QueryGenerator($this->moduleName));

Spaces must be used for alignment; tabs are not allowed
Open

        if ($recordId && \App\Record::isExists($recordId, $this->moduleName)

Spaces must be used for alignment; tabs are not allowed
Open

                ->set('parentid', $recordModel->getId())

Spaces must be used for alignment; tabs are not allowed
Open

     *        tags={"SMSAPI"},

Spaces must be used for alignment; tabs are not allowed
Open

     *      },

Spaces must be used for alignment; tabs are not allowed
Open

     *                description="`No sent token` OR `Invalid token` OR `wrong data provided in the request`",

Spaces must be used for alignment; tabs are not allowed
Open

     *                response=405,

Spaces must be used for alignment; tabs are not allowed
Open

     *        ),

Spaces must be used for alignment; tabs are not allowed
Open

     *        title="Response",

Spaces must be used for alignment; tabs are not allowed
Open

     *    ),

Spaces must be used for alignment; tabs are not allowed
Open

            $msgField = $newRecordModel->getField('message');

Spaces must be used for alignment; tabs are not allowed
Open

     *            "url" : "https://www.smsapi.pl/docs"

Spaces must be used for alignment; tabs are not allowed
Open

     *                @OA\JsonContent(ref="#/components/schemas/SMS_SMSAPI_Post_Reception")

Spaces must be used for alignment; tabs are not allowed
Open

     *                description="No permissions for module",

Spaces must be used for alignment; tabs are not allowed
Open

     *                response=405,

Spaces must be used for alignment; tabs are not allowed
Open

     * ),

Spaces must be used for alignment; tabs are not allowed
Open

     * @OA\Schema(

Spaces must be used for alignment; tabs are not allowed
Open

        $smsFrom = $this->controller->request->getByType('sms_from', \App\Purifier::DIGITS);

Spaces must be used for alignment; tabs are not allowed
Open

                ->set('phone', $recordModel->get('phone'));

Spaces must be used for alignment; tabs are not allowed
Open

     *      },

Spaces must be used for alignment; tabs are not allowed
Open

     *                response=401,

Spaces must be used for alignment; tabs are not allowed
Open

     *        ),

Spaces must be used for alignment; tabs are not allowed
Open

     *                response=403,

Spaces must be used for alignment; tabs are not allowed
Open

        $provider = \App\Integrations\SMSProvider::getProviderByName('SMSAPI');

Spaces must be used for alignment; tabs are not allowed
Open

     *            "description" : "SMSApi Documentation",

Spaces must be used for alignment; tabs are not allowed
Open

     *         security={

Spaces must be used for alignment; tabs are not allowed
Open

     *                response=200,

Spaces must be used for alignment; tabs are not allowed
Open

     *                description="Method Not Allowed",

Spaces must be used for alignment; tabs are not allowed
Open

     *        type="string",

Spaces must be used for alignment; tabs are not allowed
Open

    }

Spaces must be used for alignment; tabs are not allowed
Open

     *        externalDocs={

Spaces must be used for alignment; tabs are not allowed
Open

     *            "description" : "SMSApi Documentation",

Spaces must be used for alignment; tabs are not allowed
Open

     *                @OA\JsonContent(ref="#/components/schemas/SMS_SMSAPI_Post_Reception")

Spaces must be used for alignment; tabs are not allowed
Open

     *        description="Response",

Spaces must be used for alignment; tabs are not allowed
Open

            $newRecordModel = \Vtiger_Record_Model::getCleanInstance($this->moduleName);

Spaces must be used to indent lines; tabs are not allowed
Open

    /** {@inheritdoc}  */

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * @OA\Get(

Spaces must be used to indent lines; tabs are not allowed
Open

    /** @var string Module name */

Spaces must be used to indent lines; tabs are not allowed
Open

    protected function checkPermission(): void

Spaces must be used to indent lines; tabs are not allowed
Open

    /** {@inheritdoc}  */

Spaces must be used to indent lines; tabs are not allowed
Open

        parent::checkPermission();

Spaces must be used to indent lines; tabs are not allowed
Open

    private $moduleName = 'SMSNotifier';

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Line exceeds 120 characters; contains 242 characters
Open

        if (!\Api\Core\Module::checkModuleAccess($this->moduleName) || !\App\Privilege::isPermitted($this->moduleName, 'CreateView') || !($provider = \App\Integrations\SMSProvider::getDefaultProvider()) || 'SMSAPI' !== $provider->getName()) {

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return array

Spaces must be used to indent lines; tabs are not allowed
Open

    public $allowedMethod = ['POST'];

Spaces must be used to indent lines; tabs are not allowed
Open

            throw new \Api\Core\Exception('No permission - wrong data', 401);

Spaces must be used to indent lines; tabs are not allowed
Open

     * Add record.

Spaces must be used to indent lines; tabs are not allowed
Open

    protected function checkPermissionToModule(): void

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

            throw new \Api\Core\Exception('No permissions for module', 403);

Spaces must be used to indent lines; tabs are not allowed
Open

     *        path="/webservice/SMS/SMSAPI/Reception",

Spaces must be used to indent lines; tabs are not allowed
Open

        if ($this->controller->request->isEmpty('MsgId', true)) {

Spaces must be used to indent lines; tabs are not allowed
Open

    /** {@inheritdoc}  */

Spaces must be used to indent lines; tabs are not allowed
Open

        if (!\Api\Core\Module::checkModuleAccess($this->moduleName) || !\App\Privilege::isPermitted($this->moduleName, 'CreateView') || !($provider = \App\Integrations\SMSProvider::getDefaultProvider()) || 'SMSAPI' !== $provider->getName()) {

There are no issues that match your filters.

Category
Status