alexander-emelyanov/opteck-api-client

View on GitHub

Showing 20 of 20 total issues

File ApiClient.php has 303 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Opteck;

use GuzzleHttp;
Severity: Minor
Found in src/ApiClient.php - About 3 hrs to fix

    The class TradeAction has 16 fields. Consider redesigning TradeAction to keep the number of fields under 15.
    Open

    class TradeAction extends Entity
    {
        const STATUS_IN_PROGRESS = 1;
    
        const STATUS_CALCULATING = 2;
    Severity: Minor
    Found in src/Entities/TradeAction.php by phpmd

    TooManyFields

    Since: 0.1

    Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.

    Example

    class Person {
       protected $one;
       private $two;
       private $three;
       [... many more fields ...]
    }

    Source https://phpmd.org/rules/codesize.html#toomanyfields

    Avoid variables with short names like $id. Configured minimum length is 3.
    Open

        protected $id;
    Severity: Minor
    Found in src/Entities/OptionType.php by phpmd

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#shortvariable

    Avoid variables with short names like $id. Configured minimum length is 3.
    Open

        protected $id;
    Severity: Minor
    Found in src/Entities/Definition.php by phpmd

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#shortvariable

    Avoid variables with short names like $id. Configured minimum length is 3.
    Open

        protected $id;
    Severity: Minor
    Found in src/Entities/TradeAction.php by phpmd

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#shortvariable

    Avoid variables with short names like $id. Configured minimum length is 3.
    Open

        protected $id;
    Severity: Minor
    Found in src/Entities/Asset.php by phpmd

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#shortvariable

    Avoid variables with short names like $id. Configured minimum length is 3.
    Open

        protected $id;
    Severity: Minor
    Found in src/Entities/Market.php by phpmd

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#shortvariable

    Avoid variables with short names like $ip. Configured minimum length is 3.
    Open

        protected $ip;
    Severity: Minor
    Found in src/Requests/CreateLead.php by phpmd

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#shortvariable

    The class ApiClient has a coupling between objects value of 33. Consider to reduce the number of dependencies under 13.
    Open

    class ApiClient implements LoggerAwareInterface
    {
        /**
         * @var \GuzzleHttp\ClientInterface A Guzzle HTTP client.
         */
    Severity: Minor
    Found in src/ApiClient.php by phpmd

    CouplingBetweenObjects

    Since: 1.1.0

    A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

    Example

    class Foo {
        /**
         * @var \foo\bar\X
         */
        private $x = null;
    
        /**
         * @var \foo\bar\Y
         */
        private $y = null;
    
        /**
         * @var \foo\bar\Z
         */
        private $z = null;
    
        public function setFoo(\Foo $foo) {}
        public function setBar(\Bar $bar) {}
        public function setBaz(\Baz $baz) {}
    
        /**
         * @return \SplObjectStorage
         * @throws \OutOfRangeException
         * @throws \InvalidArgumentException
         * @throws \ErrorException
         */
        public function process(\Iterator $it) {}
    
        // ...
    }

    Source https://phpmd.org/rules/design.html#couplingbetweenobjects

    Method openPosition has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public function openPosition($email, $password, $symbol, $direction, $amount)
    Severity: Minor
    Found in src/ApiClient.php - About 35 mins to fix

      Missing class import via use statement (line '13', column '27').
      Open

                      throw new \Exception("Unknown parameter name [$key]");
      Severity: Minor
      Found in src/Request.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 '25', column '23').
      Open

                  throw new \UnexpectedValueException('Invalid JSON message. Message: '.$json);
      Severity: Minor
      Found in src/Payload.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 '487', column '23').
      Open

                  throw new \Exception($e->getResponse()->getReasonPhrase(), $e->getResponse()->getStatusCode());
      Severity: Minor
      Found in src/ApiClient.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

      The 'getIsActive()' method which returns a boolean should be named 'is...()' or 'has...()'
      Open

          public function getIsActive()
          {
              return boolval(intval($this->isActive));
          }
      Severity: Minor
      Found in src/Entities/Definition.php by phpmd

      BooleanGetMethodName

      Since: 0.2

      Looks for methods named 'getX()' with 'boolean' as the return type. The convention is to name these methods 'isX()' or 'hasX()'.

      Example

      class Foo {
          /**
           * @return boolean
           */
          public function getFoo() {} // bad
          /**
           * @return bool
           */
          public function isFoo(); // ok
          /**
           * @return boolean
           */
          public function getFoo($bar); // ok, unless checkParameterizedMethods=true
      }

      Source https://phpmd.org/rules/naming.html#booleangetmethodname

      Avoid using static access to class '\GuzzleHttp\HandlerStack' in method 'getHttpClient'.
      Open

              $stack = GuzzleHttp\HandlerStack::create();
      Severity: Minor
      Found in src/ApiClient.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

      The 'getIsValid()' method which returns a boolean should be named 'is...()' or 'has...()'
      Open

          public function getIsValid()
          {
              return boolval($this->isValid);
          }
      Severity: Minor
      Found in src/Entities/Deposit.php by phpmd

      BooleanGetMethodName

      Since: 0.2

      Looks for methods named 'getX()' with 'boolean' as the return type. The convention is to name these methods 'isX()' or 'hasX()'.

      Example

      class Foo {
          /**
           * @return boolean
           */
          public function getFoo() {} // bad
          /**
           * @return bool
           */
          public function isFoo(); // ok
          /**
           * @return boolean
           */
          public function getFoo($bar); // ok, unless checkParameterizedMethods=true
      }

      Source https://phpmd.org/rules/naming.html#booleangetmethodname

      The method __construct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

                  } else {
                      throw new \Exception("Unknown parameter name [$key]");
                  }
      Severity: Minor
      Found in src/Request.php by phpmd

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

      Source https://phpmd.org/rules/cleancode.html#elseexpression

      The 'getIsFirstTimeDeposit()' method which returns a boolean should be named 'is...()' or 'has...()'
      Open

          public function getIsFirstTimeDeposit()
          {
              return boolval($this->isFirstTimeDeposit);
          }
      Severity: Minor
      Found in src/Entities/Deposit.php by phpmd

      BooleanGetMethodName

      Since: 0.2

      Looks for methods named 'getX()' with 'boolean' as the return type. The convention is to name these methods 'isX()' or 'hasX()'.

      Example

      class Foo {
          /**
           * @return boolean
           */
          public function getFoo() {} // bad
          /**
           * @return bool
           */
          public function isFoo(); // ok
          /**
           * @return boolean
           */
          public function getFoo($bar); // ok, unless checkParameterizedMethods=true
      }

      Source https://phpmd.org/rules/naming.html#booleangetmethodname

      The 'getIsActive()' method which returns a boolean should be named 'is...()' or 'has...()'
      Open

          public function getIsActive()
          {
              return $this->isActive;
          }
      Severity: Minor
      Found in src/Requests/GetDefinitions.php by phpmd

      BooleanGetMethodName

      Since: 0.2

      Looks for methods named 'getX()' with 'boolean' as the return type. The convention is to name these methods 'isX()' or 'hasX()'.

      Example

      class Foo {
          /**
           * @return boolean
           */
          public function getFoo() {} // bad
          /**
           * @return bool
           */
          public function isFoo(); // ok
          /**
           * @return boolean
           */
          public function getFoo($bar); // ok, unless checkParameterizedMethods=true
      }

      Source https://phpmd.org/rules/naming.html#booleangetmethodname

      Avoid using static access to class '\GuzzleHttp\Middleware' in method 'getHttpClient'.
      Open

                  $stack->push(GuzzleHttp\Middleware::log(
                      $this->logger,
                      new GuzzleHttp\MessageFormatter(GuzzleHttp\MessageFormatter::DEBUG)
                  ));
      Severity: Minor
      Found in src/ApiClient.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

      Severity
      Category
      Status
      Source
      Language