YetiForceCompany/YetiForceCRM

View on GitHub
app/Integrations/Pbx/VtigerAsteriskConnector.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

Missing class import via use statement (line '44', column '21').
Open

            $response = (new \GuzzleHttp\Client(\App\RequestHttp::getOptions()))->request('POST', $serviceURL);

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 '\App\Log' in method 'performCall'.
Open

            \App\Log::warning('Error: ' . $serviceURL . ' | ' . $exc->getMessage(), __CLASS__);

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\Log' in method 'performCall'.
Open

            \App\Log::beginProfile("POST|VtigerAsteriskConnector::performCall|{$serviceURL}", __NAMESPACE__);

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\Log' in method 'performCall'.
Open

            \App\Log::endProfile("POST|VtigerAsteriskConnector::performCall|{$serviceURL}", __NAMESPACE__);

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\RequestHttp' in method 'performCall'.
Open

            $response = (new \GuzzleHttp\Client(\App\RequestHttp::getOptions()))->request('POST', $serviceURL);

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\Log' in method 'performCall'.
Open

                \App\Log::warning('Error: ' . $serviceURL . ' | ' . $response->getStatusCode() . ' ' . $response->getReasonPhrase(), __CLASS__);

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

    public $configFields = ['url' => ['label' => 'LBL_URL'], 'secretkey' => ['label' => 'LBL_SECRET_KEY'], 'outboundContext' => ['label' => 'LBL_OUTBOUND_CONTEXT']];

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 endProfile from undeclared class \App\Log
Open

            \App\Log::endProfile("POST|VtigerAsteriskConnector::performCall|{$serviceURL}", __NAMESPACE__);

Call to method request from undeclared class \GuzzleHttp\Client
Open

            $response = (new \GuzzleHttp\Client(\App\RequestHttp::getOptions()))->request('POST', $serviceURL);

Call to method warning from undeclared class \App\Log
Open

                \App\Log::warning('Error: ' . $serviceURL . ' | ' . $response->getStatusCode() . ' ' . $response->getReasonPhrase(), __CLASS__);

Assigning array{url:array{label:'LBL_URL'},secretkey:array{label:'LBL_SECRET_KEY'},outboundContext:array{label:'LBL_OUTBOUND_CONTEXT'}} to property but \App\Integrations\Pbx\VtigerAsteriskConnector->configFields is string[]
Open

    public $configFields = ['url' => ['label' => 'LBL_URL'], 'secretkey' => ['label' => 'LBL_SECRET_KEY'], 'outboundContext' => ['label' => 'LBL_OUTBOUND_CONTEXT']];

Call to method beginProfile from undeclared class \App\Log
Open

            \App\Log::beginProfile("POST|VtigerAsteriskConnector::performCall|{$serviceURL}", __NAMESPACE__);

Call to method warning from undeclared class \App\Log
Open

            \App\Log::warning('Error: ' . $serviceURL . ' | ' . $exc->getMessage(), __CLASS__);

Call to method __construct from undeclared class \GuzzleHttp\Client
Open

            $response = (new \GuzzleHttp\Client(\App\RequestHttp::getOptions()))->request('POST', $serviceURL);

Line exceeds 120 characters; contains 165 characters
Open

    public $configFields = ['url' => ['label' => 'LBL_URL'], 'secretkey' => ['label' => 'LBL_SECRET_KEY'], 'outboundContext' => ['label' => 'LBL_OUTBOUND_CONTEXT']];

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

            \App\Log::warning('Error: ' . $serviceURL . ' | ' . $exc->getMessage(), __CLASS__);

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

    /**

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

            $response = (new \GuzzleHttp\Client(\App\RequestHttp::getOptions()))->request('POST', $serviceURL);

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

            return false;

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

     * @var string[]

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

     */

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

     * Values to configure.

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

        $serviceURL .= '/makecall?event=OutgoingCall&';

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

        try {

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

        }

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

     * @var string Class name

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

        $serviceURL .= 'secret=' . urlencode($pbx->getConfig('secretkey')) . '&';

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

    public function performCall(\App\Integrations\Pbx $pbx)

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

        $serviceURL .= 'to=' . urlencode($pbx->get('targetPhone')) . '&';

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

            if (200 !== $response->getStatusCode()) {

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

    public $name = 'VtigerAsteriskConnector';

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

    /**

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

     * Perform phone call.

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

                \App\Log::warning('Error: ' . $serviceURL . ' | ' . $response->getStatusCode() . ' ' . $response->getReasonPhrase(), __CLASS__);

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

    {

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

            \App\Log::beginProfile("POST|VtigerAsteriskConnector::performCall|{$serviceURL}", __NAMESPACE__);

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

            \App\Log::endProfile("POST|VtigerAsteriskConnector::performCall|{$serviceURL}", __NAMESPACE__);

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

     */

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

     * @param \App\Integrations\Pbx $pbx

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

        $serviceURL .= 'from=' . urlencode($pbx->get('sourcePhone')) . '&';

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

        $serviceURL .= 'context=' . urlencode($pbx->get('outboundContext'));

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

        $serviceURL = $pbx->getConfig('url');

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

                return false;

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

    public $configFields = ['url' => ['label' => 'LBL_URL'], 'secretkey' => ['label' => 'LBL_SECRET_KEY'], 'outboundContext' => ['label' => 'LBL_OUTBOUND_CONTEXT']];

Line exceeds 120 characters; contains 144 characters
Open

                \App\Log::warning('Error: ' . $serviceURL . ' | ' . $response->getStatusCode() . ' ' . $response->getReasonPhrase(), __CLASS__);

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

        } catch (\Throwable $exc) {

There are no issues that match your filters.

Category
Status