YetiForceCompany/YetiForceCRM

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

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

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

            $response = (new \GuzzleHttp\Client(\App\RequestHttp::getOptions()))->request('GET', $url);
Severity: Minor
Found in app/Integrations/Pbx/Mixpbx.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 '\App\Log' in method 'performCall'.
Open

            \App\Log::warning('Error: ' . $url . ' | ' . $exc->getMessage(), __CLASS__);
Severity: Minor
Found in app/Integrations/Pbx/Mixpbx.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 '\App\Log' in method 'performCall'.
Open

            \App\Log::beginProfile("GET|Mixpbx::performCall|{$url}", __NAMESPACE__);
Severity: Minor
Found in app/Integrations/Pbx/Mixpbx.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 '\App\Log' in method 'performCall'.
Open

            \App\Log::endProfile("GET|Mixpbx::performCall|{$url}", __NAMESPACE__);
Severity: Minor
Found in app/Integrations/Pbx/Mixpbx.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 '\App\Log' in method 'performCall'.
Open

                \App\Log::warning('Error: ' . $url . ' | ' . $response->getStatusCode() . ' ' . $response->getReasonPhrase(), __CLASS__);
Severity: Minor
Found in app/Integrations/Pbx/Mixpbx.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 '\App\RequestHttp' in method 'performCall'.
Open

            $response = (new \GuzzleHttp\Client(\App\RequestHttp::getOptions()))->request('GET', $url);
Severity: Minor
Found in app/Integrations/Pbx/Mixpbx.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 '\App\Log' in method 'performCall'.
Open

                \App\Log::warning($contents, 'PBX[Mixpbx]');
Severity: Minor
Found in app/Integrations/Pbx/Mixpbx.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

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

    public $configFields = ['url' => ['label' => 'LBL_URL'], 'username' => ['label' => 'LBL_USERNAME'], 'password' => ['label' => 'LBL_PASSWORD']];
Severity: Critical
Found in app/Integrations/Pbx/Mixpbx.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.

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

            \App\Log::beginProfile("GET|Mixpbx::performCall|{$url}", __NAMESPACE__);
Severity: Critical
Found in app/Integrations/Pbx/Mixpbx.php by phan

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

                \App\Log::warning($contents, 'PBX[Mixpbx]');
Severity: Critical
Found in app/Integrations/Pbx/Mixpbx.php by phan

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

            \App\Log::warning('Error: ' . $url . ' | ' . $exc->getMessage(), __CLASS__);
Severity: Critical
Found in app/Integrations/Pbx/Mixpbx.php by phan

Assigning array{url:array{label:'LBL_URL'},username:array{label:'LBL_USERNAME'},password:array{label:'LBL_PASSWORD'}} to property but \App\Integrations\Pbx\Mixpbx->configFields is string[]
Open

    public $configFields = ['url' => ['label' => 'LBL_URL'], 'username' => ['label' => 'LBL_USERNAME'], 'password' => ['label' => 'LBL_PASSWORD']];
Severity: Minor
Found in app/Integrations/Pbx/Mixpbx.php by phan

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

            $response = (new \GuzzleHttp\Client(\App\RequestHttp::getOptions()))->request('GET', $url);
Severity: Critical
Found in app/Integrations/Pbx/Mixpbx.php by phan

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

                \App\Log::warning('Error: ' . $url . ' | ' . $response->getStatusCode() . ' ' . $response->getReasonPhrase(), __CLASS__);
Severity: Critical
Found in app/Integrations/Pbx/Mixpbx.php by phan

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

            $response = (new \GuzzleHttp\Client(\App\RequestHttp::getOptions()))->request('GET', $url);
Severity: Critical
Found in app/Integrations/Pbx/Mixpbx.php by phan

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

            \App\Log::endProfile("GET|Mixpbx::performCall|{$url}", __NAMESPACE__);
Severity: Critical
Found in app/Integrations/Pbx/Mixpbx.php by phan

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 $configFields = ['url' => ['label' => 'LBL_URL'], 'username' => ['label' => 'LBL_USERNAME'], 'password' => ['label' => 'LBL_PASSWORD']];

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

        $url .= '&extension=' . urlencode($pbx->get('sourcePhone'));

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

        $url .= '&password=' . urlencode($pbx->getConfig('password'));

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

        $url .= '?username=' . urlencode($pbx->getConfig('username'));

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

                \App\Log::warning($contents, 'PBX[Mixpbx]');

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

        } catch (\Throwable $exc) {

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 false;

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

        $url .= '&number=' . urlencode($pbx->get('targetPhone'));

Line exceeds 120 characters; contains 147 characters
Open

    public $configFields = ['url' => ['label' => 'LBL_URL'], 'username' => ['label' => 'LBL_USERNAME'], 'password' => ['label' => 'LBL_PASSWORD']];

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

                \App\Log::warning('Error: ' . $url . ' | ' . $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::warning('Error: ' . $url . ' | ' . $exc->getMessage(), __CLASS__);

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

    public $name = 'MixPBX';

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

    /**

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

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

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

            $contents = $response->getBody()->getContents();

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('GET', $url);

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

            \App\Log::endProfile("GET|Mixpbx::performCall|{$url}", __NAMESPACE__);

Line exceeds 120 characters; contains 137 characters
Open

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

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

            if ('OK' !== trim($contents)) {

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

            \App\Log::beginProfile("GET|Mixpbx::performCall|{$url}", __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

            return false;

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[]

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

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

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

     *

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

        try {

There are no issues that match your filters.

Category
Status