YetiForceCompany/YetiForceCRM

View on GitHub
app/RequestHttp.php

Summary

Maintainability
A
2 hrs
Test Coverage
F
44%

Method getOptions has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function getOptions(): array
    {
        $caPathOrFile = \Composer\CaBundle\CaBundle::getSystemCaRootBundlePath();
        $options = [
            'headers' => [
Severity: Minor
Found in app/RequestHttp.php - About 1 hr to fix

    Function getOptions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function getOptions(): array
        {
            $caPathOrFile = \Composer\CaBundle\CaBundle::getSystemCaRootBundlePath();
            $options = [
                'headers' => [
    Severity: Minor
    Found in app/RequestHttp.php - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function getSoapOptions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function getSoapOptions(): array
        {
            $options = [
                'trace' => 1,
                'exceptions' => 1,
    Severity: Minor
    Found in app/RequestHttp.php - About 35 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Missing class import via use statement (line '35', column '14').
    Open

            return new \GuzzleHttp\Client(\App\Utils::merge(self::getOptions(), $config));
    Severity: Minor
    Found in app/RequestHttp.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\Utils' in method 'getClient'.
    Open

            return new \GuzzleHttp\Client(\App\Utils::merge(self::getOptions(), $config));
    Severity: Minor
    Found in app/RequestHttp.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 '\Composer\CaBundle\CaBundle' in method 'getOptions'.
    Open

            $caPathOrFile = \Composer\CaBundle\CaBundle::getSystemCaRootBundlePath();
    Severity: Minor
    Found in app/RequestHttp.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\Version' in method 'getOptions'.
    Open

                    'User-Agent' => 'YetiForceCRM/' . Version::get(),
    Severity: Minor
    Found in app/RequestHttp.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\Version' in method 'getSoapOptions'.
    Open

                'user_agent' => 'YetiForceCRM/' . Version::get(),
    Severity: Minor
    Found in app/RequestHttp.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

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

            return new \GuzzleHttp\Client(\App\Utils::merge(self::getOptions(), $config));
    Severity: Critical
    Found in app/RequestHttp.php by phan

    Return type of getClient() is undeclared type \GuzzleHttp\Client
    Open

        public static function getClient(array $config = []): \GuzzleHttp\Client
    Severity: Minor
    Found in app/RequestHttp.php by phan

    Call to method getSystemCaRootBundlePath from undeclared class \Composer\CaBundle\CaBundle
    Open

            $caPathOrFile = \Composer\CaBundle\CaBundle::getSystemCaRootBundlePath();
    Severity: Critical
    Found in app/RequestHttp.php by phan

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

        {
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

        {
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                ],
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

            }
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

         */
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

         *
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                if (!empty(\Config\Security::$proxyLogin)) {
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                    $proxy .= '@';
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

        }
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

            return $options;
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

        /** @var int The number of seconds to wait while trying to connect to a server. Use 0 to wait indefinitely (the default behavior). */
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

         *
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

            return new \GuzzleHttp\Client(\App\Utils::merge(self::getOptions(), $config));
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

            return $options;
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                $proxy = '';
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                        $proxy .= ':' . \Config\Security::$proxyPassword;
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

         * @return array
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

         */
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

            }
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

         */
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                'verify' => \is_file($caPathOrFile) ? $caPathOrFile : false,
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

            ];
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

        /**
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

         * @return \GuzzleHttp\Client
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

            if (!empty(\Config\Security::$proxyConnection)) {
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

         * Get default configuration for SoapClient.
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                $options['proxy'] = $proxy;
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                'user_agent' => 'YetiForceCRM/' . Version::get(),
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                'trace' => 1,
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                if (!empty(\Config\Security::$proxyPort)) {
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

        /** @var int Total timeout of the request in seconds. Use 0 to wait indefinitely (the default behavior). */
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

        /**
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

        public static function getOptions(): array
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

            $options = [
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                'connect_timeout' => self::$connectTimeout,
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

        public static function getSoapOptions(): array
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

         * @param array $config
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

        public static function getClient(array $config = []): \GuzzleHttp\Client
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                if (!empty(\Config\Security::$proxyProtocol)) {
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                }
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

            $caPathOrFile = \Composer\CaBundle\CaBundle::getSystemCaRootBundlePath();
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                'headers' => [
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                }
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

         *
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

        {
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                'exceptions' => 1,
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

            if (!empty(\Config\Security::$proxyConnection)) {
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                $options['proxy_host'] = \Config\Security::$proxyHost;
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                    $options['proxy_port'] = \Config\Security::$proxyPort;
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

    Line exceeds 120 characters; contains 137 characters
    Open

        /** @var int The number of seconds to wait while trying to connect to a server. Use 0 to wait indefinitely (the default behavior). */
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

        /**
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

         *
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

         * Get default configuration for GuzzleHttp Client.
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

        }
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

        public static $connectTimeout = 2;
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                    $proxy .= ':' . \Config\Security::$proxyPort;
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                    $options['proxy_login'] = \Config\Security::$proxyLogin;
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

         * Get GuzzleHttp client instance.
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                    }
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                }
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

            $options = [
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

            ];
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                if (!empty(\Config\Security::$proxyPassword)) {
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

        public static $timeout = 10;
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                    'User-Agent' => 'YetiForceCRM/' . Version::get(),
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

         * @return array
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                    $proxy .= \Config\Security::$proxyLogin;
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                    if (!empty(\Config\Security::$proxyPassword)) {
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                    $proxy .= \Config\Security::$proxyProtocol . '://';
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                $proxy .= \Config\Security::$proxyHost;
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                'connection_timeout' => self::$timeout,
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                if (!empty(\Config\Security::$proxyPort)) {
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                }
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                }
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

        }
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                'timeout' => self::$timeout,
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                }
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                if (!empty(\Config\Security::$proxyLogin)) {
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

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

                    $options['proxy_password'] = \Config\Security::$proxyPassword;
    Severity: Minor
    Found in app/RequestHttp.php by phpcodesniffer

    There are no issues that match your filters.

    Category
    Status