mikecbrant/php-rest-client

View on GitHub
src/RestClientLib/RestClient.php

Summary

Maintainability
C
1 day
Test Coverage
A
100%

RestClient has 32 functions (exceeds 20 allowed). Consider refactoring.
Open

class RestClient
{
    /**
      * Flag to determine if basic authentication is to be used.
     * 
Severity: Minor
Found in src/RestClientLib/RestClient.php - About 4 hrs to fix

    The class RestClient has an overall complexity of 63 which is very high. The configured complexity threshold is 50.
    Open

    class RestClient
    {
        /**
          * Flag to determine if basic authentication is to be used.
         * 
    Severity: Minor
    Found in src/RestClientLib/RestClient.php by phpmd

    File RestClient.php has 289 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace MikeBrant\RestClientLib;
    
    /**
    Severity: Minor
    Found in src/RestClientLib/RestClient.php - About 2 hrs to fix

      Function setRemoteHost has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          public function setRemoteHost($host)
          {
              if(empty($host)) {
                  throw new \InvalidArgumentException('Host name not provided.');
              } else if(!is_string($host)) {
      Severity: Minor
      Found in src/RestClientLib/RestClient.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

      Method curlInit has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function curlInit()
          {
              // initialize curl
              $curl = curl_init();
              if($curl === false) {
      Severity: Minor
      Found in src/RestClientLib/RestClient.php - About 1 hr to fix

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

            protected function curlInit()
            {
                // initialize curl
                $curl = curl_init();
                if($curl === false) {
        Severity: Minor
        Found in src/RestClientLib/RestClient.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

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

                    throw new \InvalidArgumentException('Host name not provided.');
        Severity: Minor
        Found in src/RestClientLib/RestClient.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 '649', column '23').
        Open

                    throw new \InvalidArgumentException('An empty value was passed for data parameter');
        Severity: Minor
        Found in src/RestClientLib/RestClient.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 '355', column '23').
        Open

                    throw new \InvalidArgumentException('A non-negative integer value must be passed when trying to set timeout');
        Severity: Minor
        Found in src/RestClientLib/RestClient.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 '299', column '23').
        Open

                    throw new \InvalidArgumentException('Non-boolean value passed as parameter.');
        Severity: Minor
        Found in src/RestClientLib/RestClient.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 '216', column '23').
        Open

                    throw new \InvalidArgumentException('Non-string host name provided.');
        Severity: Minor
        Found in src/RestClientLib/RestClient.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 '319', column '23').
        Open

                    throw new \InvalidArgumentException('Password not provided when trying to set basic authentication credentials.');
        Severity: Minor
        Found in src/RestClientLib/RestClient.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 '316', column '23').
        Open

                    throw new \InvalidArgumentException('User name not provided when trying to set basic authentication credentials.');
        Severity: Minor
        Found in src/RestClientLib/RestClient.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 '574', column '23').
        Open

                    throw new \Exception(
        Severity: Minor
        Found in src/RestClientLib/RestClient.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 '635', column '23').
        Open

                    throw new \InvalidArgumentException('A non-string value was passed for action parameter');
        Severity: Minor
        Found in src/RestClientLib/RestClient.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 '282', column '23').
        Open

                    throw new \InvalidArgumentException('Non-boolean value passed as parameter.');
        Severity: Minor
        Found in src/RestClientLib/RestClient.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 '338', column '23').
        Open

                    throw new \InvalidArgumentException('Empty array passed when triyng to set headers');
        Severity: Minor
        Found in src/RestClientLib/RestClient.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 '567', column '23').
        Open

                    throw new \Exception('curl call failed with message: "' . $curlError. '"');
        Severity: Minor
        Found in src/RestClientLib/RestClient.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 '389', column '23').
        Open

                    throw new \InvalidArgumentException('A non-negative integer value must be passed when trying to set max redirects.');
        Severity: Minor
        Found in src/RestClientLib/RestClient.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 '372', column '23').
        Open

                    throw new \InvalidArgumentException('Non-boolean value passed as parameter.');
        Severity: Minor
        Found in src/RestClientLib/RestClient.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 '259', column '23').
        Open

                    throw new \InvalidArgumentException('URI base not provided.');
        Severity: Minor
        Found in src/RestClientLib/RestClient.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 '261', column '23').
        Open

                    throw new \InvalidArgumentException('Non-string URI base provided.');
        Severity: Minor
        Found in src/RestClientLib/RestClient.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 '489', column '23').
        Open

                    throw new \Exception('curl failed to initialize.');
        Severity: Minor
        Found in src/RestClientLib/RestClient.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

        There are no issues that match your filters.

        Category
        Status