MPOS/php-mpos

View on GitHub
include/classes/tools.class.php

Summary

Maintainability
F
4 days
Test Coverage

Function getApiType has a Cognitive Complexity of 103 (exceeds 5 allowed). Consider refactoring.
Open

  private function getApiType($url) {
    if (preg_match('/coinchoose.com/', $url)) {
      return 'coinchoose';
    } else if (preg_match('/btc-e.nz/', $url)) {
      return 'btce';
Severity: Minor
Found in include/classes/tools.class.php - About 2 days 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 getPrice has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

  public function getPrice() {
    $aData = $this->getApi($this->config['price']['url'], $this->config['price']['target']);
    $strBase = $this->config['currency'];
    $strQuote = $this->config['price']['currency'];
    // Check the API type for configured URL
Severity: Minor
Found in include/classes/tools.class.php - About 3 hrs 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 getPrice has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public function getPrice() {
    $aData = $this->getApi($this->config['price']['url'], $this->config['price']['target']);
    $strBase = $this->config['currency'];
    $strQuote = $this->config['price']['currency'];
    // Check the API type for configured URL
Severity: Major
Found in include/classes/tools.class.php - About 2 hrs to fix

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

      private function getApiType($url) {
        if (preg_match('/coinchoose.com/', $url)) {
          return 'coinchoose';
        } else if (preg_match('/btc-e.nz/', $url)) {
          return 'btce';
    Severity: Minor
    Found in include/classes/tools.class.php - About 1 hr to fix

      Avoid too many return statements within this method.
      Open

            return 'bittrex';
      Severity: Major
      Found in include/classes/tools.class.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

              return 'cryptobridge';
        Severity: Major
        Found in include/classes/tools.class.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                return 'tradeogre';
          Severity: Major
          Found in include/classes/tools.class.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                return false;
            Severity: Major
            Found in include/classes/tools.class.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                        return @$aData['price'];
              Severity: Major
              Found in include/classes/tools.class.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                      return 'yobit';
                Severity: Major
                Found in include/classes/tools.class.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                            return @$aData['ticker']['lastprice'];
                  Severity: Major
                  Found in include/classes/tools.class.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                          return false;
                    Severity: Major
                    Found in include/classes/tools.class.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                            return 'c-cex';
                      Severity: Major
                      Found in include/classes/tools.class.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                    return @$aData['0']['last_price'];
                        Severity: Major
                        Found in include/classes/tools.class.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                return 'mintpal';
                          Severity: Major
                          Found in include/classes/tools.class.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                  return 'southxchange';
                            Severity: Major
                            Found in include/classes/tools.class.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                    return 'mercatox';
                              Severity: Major
                              Found in include/classes/tools.class.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                          return @$aData['pairs']["{$strBase}_{$strQuote}"]['last'];
                                Severity: Major
                                Found in include/classes/tools.class.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                            return @$aData[strtolower($strBase) . "_" . strtolower($strQuote)]['last'];
                                  Severity: Major
                                  Found in include/classes/tools.class.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                              return @$aData['Last'];
                                    Severity: Major
                                    Found in include/classes/tools.class.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                return @$aData['price'];
                                      Severity: Major
                                      Found in include/classes/tools.class.php - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                    return @$aData["{$strBase}/{$strQuote}"]['last_trade'];
                                        Severity: Major
                                        Found in include/classes/tools.class.php - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                      return @$aData['result']['Last'];
                                          Severity: Major
                                          Found in include/classes/tools.class.php - About 30 mins to fix

                                            Avoid too many return statements within this method.
                                            Open

                                                          return $aItem['last'];
                                            Severity: Major
                                            Found in include/classes/tools.class.php - About 30 mins to fix

                                              Avoid too many return statements within this method.
                                              Open

                                                  return false;
                                              Severity: Major
                                              Found in include/classes/tools.class.php - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

                                                      return 'binance';
                                                Severity: Major
                                                Found in include/classes/tools.class.php - About 30 mins to fix

                                                  There are no issues that match your filters.

                                                  Category
                                                  Status