mrcnpdlk/teryt-api

View on GitHub

Showing 20 of 52 total issues

File NativeApi.php has 674 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);
/**
 * TERYT-API
Severity: Major
Found in src/NativeApi.php - About 1 day to fix

    NativeApi has 56 functions (exceeds 20 allowed). Consider refactoring.
    Open

    final class NativeApi
    {
        /**
         * @var string Wyszukiwanie wśród wszystkich rodzajów jednostek
         */
    Severity: Major
    Found in src/NativeApi.php - About 1 day to fix

      The class NativeApi has 55 non-getter- and setter-methods. Consider refactoring NativeApi to keep number of methods under 25.
      Open

      final class NativeApi
      {
          /**
           * @var string Wyszukiwanie wśród wszystkich rodzajów jednostek
           */
      Severity: Minor
      Found in src/NativeApi.php by phpmd

      TooManyMethods

      Since: 0.1

      A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

      By default it ignores methods starting with 'get' or 'set'.

      The default was changed from 10 to 25 in PHPMD 2.3.

      Example

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

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

      final class NativeApi
      {
          /**
           * @var string Wyszukiwanie wśród wszystkich rodzajów jednostek
           */
      Severity: Minor
      Found in src/NativeApi.php by phpmd

      Function find has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          public function find(string $id)
          {
              switch (strlen($id)) {
                  case 6:
                      $provinceId = substr($id, 0, 2);
      Severity: Minor
      Found in src/Model/Commune.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 find has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function find(string $id)
          {
              switch (strlen($id)) {
                  case 6:
                      $provinceId = substr($id, 0, 2);
      Severity: Minor
      Found in src/Model/Commune.php - About 1 hr to fix

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

            public function searchDistricts(string $phrase = null)
            {
                try {
                    $answer = [];
                    if ($phrase) {
        Severity: Minor
        Found in src/Model/Province.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

        The class NativeApi has 55 public methods and attributes. Consider reducing the number of public items to less than 45.
        Open

        final class NativeApi
        {
            /**
             * @var string Wyszukiwanie wśród wszystkich rodzajów jednostek
             */
        Severity: Minor
        Found in src/NativeApi.php by phpmd

        ExcessivePublicCount

        Since: 0.1

        A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it.

        Example

        public class Foo {
            public $value;
            public $something;
            public $var;
            // [... more more public attributes ...]
        
            public function doWork() {}
            public function doMoreWork() {}
            public function doWorkAgain() {}
            // [... more more public methods ...]
        }

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

        Function getKeyValues has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function getKeyValues(array $tItems, string $sKey, bool $asUnique = true): array
            {
                $answer = [];
                foreach ($tItems as $item) {
                    if (!is_object($item) && !is_array($item)) {
        Severity: Minor
        Found in src/Helper.php - About 45 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

        Method WeryfikujNazwaAdresUlic has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                string $provinceName,
                string $districtName,
                string $communeName,
                string $cityName,
                string $cityTypeName = null,
        Severity: Minor
        Found in src/NativeApi.php - About 45 mins to fix

          Method WeryfikujNazwaAdresUlicAdresowy has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  string $provinceName,
                  string $districtName,
                  string $communeName,
                  string $cityName,
                  string $cityTypeName = null,
          Severity: Minor
          Found in src/NativeApi.php - About 45 mins to fix

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

                    string $name = null,
                    string $identityName = 'ul.',
                    string $streetId = null,
                    array $tSimc = [],
                    array $tTerc = []
            Severity: Minor
            Found in src/NativeApi.php - About 35 mins to fix

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

                      string $provinceName,
                      string $districtName,
                      string $communeName,
                      string $cityName,
                      string $cityTypeName = null
              Severity: Minor
              Found in src/NativeApi.php - About 35 mins to fix

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

                        string $provinceName,
                        string $districtName,
                        string $communeName,
                        string $cityName,
                        string $cityTypeName = null
                Severity: Minor
                Found in src/NativeApi.php - About 35 mins to fix

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

                      public function __doRequest($request, $location, $action, $version, $oneWay = 0)
                  Severity: Minor
                  Found in src/TerytSoapClient.php - About 35 mins to fix

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

                            string $provinceName,
                            string $districtName,
                            string $communeName,
                            string $cityName,
                            string $cityId = null
                    Severity: Minor
                    Found in src/NativeApi.php - About 35 mins to fix

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

                              string $name = null,
                              string $cityId = null,
                              array $tSimc = [],
                              array $tTerc = [],
                              string $cityTypeName = NativeApi::SEARCH_CITY_TYPE_ALL
                      Severity: Minor
                      Found in src/NativeApi.php - About 35 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                    return new Exception('Unknown Exception', 1, $e);
                        Severity: Major
                        Found in src/Helper.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                          return $e;
                          Severity: Major
                          Found in src/Helper.php - About 30 mins to fix

                            The class NativeApi has 1406 lines of code. Current threshold is 1000. Avoid really long classes.
                            Open

                            final class NativeApi
                            {
                                /**
                                 * @var string Wyszukiwanie wśród wszystkich rodzajów jednostek
                                 */
                            Severity: Minor
                            Found in src/NativeApi.php by phpmd
                            Severity
                            Category
                            Status
                            Source
                            Language