bookboon/api-php

View on GitHub

Showing 32 of 32 total issues

Book has 38 functions (exceeds 20 allowed). Consider refactoring.
Open

abstract class Book extends Entity
{
    const _OWN_TYPE = '';

    const TYPE_AUDIO = 'audio';
Severity: Minor
Found in src/Entity/Book.php - About 5 hrs to fix

    File Book.php has 300 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace Bookboon\Api\Entity;
    
    use Bookboon\Api\Bookboon;
    Severity: Minor
    Found in src/Entity/Book.php - About 3 hrs to fix

      Method executeQuery has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function executeQuery(
              string $uri,
              string $type = ClientInterface::HTTP_GET,
              array $variables = [],
              string $contentType = ClientInterface::CONTENT_TYPE_JSON
      Severity: Major
      Found in src/Client/OauthClient.php - About 2 hrs to fix

        Method executeQuery has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function executeQuery(
                $uri,
                $type = self::HTTP_GET,
                $variables = [],
                $contentType = self::CONTENT_TYPE_FORM
        Severity: Major
        Found in src/Client/BasicAuthClient.php - About 2 hrs to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              public static function get(Bookboon $bookboon, string $examId) : BookboonResponse
              {
                  if (Entity::isValidUUID($examId) === false) {
                      throw new BadUUIDException();
                  }
          Severity: Major
          Found in src/Entity/Exam.php and 1 other location - About 2 hrs to fix
          src/Entity/Author.php on lines 20..44

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 121.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              public static function get(Bookboon $bookboon, string $authorId) : BookboonResponse
              {
                  if (Entity::isValidUUID($authorId) === false) {
                      throw new BadUUIDException();
                  }
          Severity: Major
          Found in src/Entity/Author.php and 1 other location - About 2 hrs to fix
          src/Entity/Exam.php on lines 22..46

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 121.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

              public static function getByBookId(Bookboon $bookboon, string $bookId) : BookboonResponse
              {
                  if (Entity::isValidUUID($bookId) === false) {
                      throw new BadUUIDException();
                  }
          Severity: Major
          Found in src/Entity/Review.php and 2 other locations - About 1 hr to fix
          src/Entity/Chapter.php on lines 20..39
          src/Entity/TimeTag.php on lines 20..39

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 118.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

              public static function getByBookId(Bookboon $bookboon, string $bookId) : BookboonResponse
              {
                  if (Entity::isValidUUID($bookId) === false) {
                      throw new BadUUIDException();
                  }
          Severity: Major
          Found in src/Entity/TimeTag.php and 2 other locations - About 1 hr to fix
          src/Entity/Chapter.php on lines 20..39
          src/Entity/Review.php on lines 22..41

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 118.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

              public static function getByBookId(Bookboon $bookboon, string $bookId) : BookboonResponse
              {
                  if (Entity::isValidUUID($bookId) === false) {
                      throw new BadUUIDException();
                  }
          Severity: Major
          Found in src/Entity/Chapter.php and 2 other locations - About 1 hr to fix
          src/Entity/Review.php on lines 22..41
          src/Entity/TimeTag.php on lines 20..39

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 118.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Function getRemoteAddress has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              private function getRemoteAddress() : ?string
              {
                  $hostname = null;
          
                  if (isset($_SERVER['REMOTE_ADDR'])) {
          Severity: Minor
          Found in src/Client/Headers.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 __construct has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function __construct(
                  string $apiId,
                  string $apiSecret,
                  Headers $headers,
                  array $scopes,
          Severity: Minor
          Found in src/Client/OauthClient.php - About 1 hr to fix

            Method __construct has 11 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    string $apiId,
                    string $apiSecret,
                    Headers $headers,
                    array $scopes,
                    CacheInterface $cache = null,
            Severity: Major
            Found in src/Client/OauthClient.php - About 1 hr to fix

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

                  protected function executeQuery(
                      string $uri,
                      string $type = ClientInterface::HTTP_GET,
                      array $variables = [],
                      string $contentType = ClientInterface::CONTENT_TYPE_JSON
              Severity: Minor
              Found in src/Client/OauthClient.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 executeQuery has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function executeQuery(
                      $uri,
                      $type = self::HTTP_GET,
                      $variables = [],
                      $contentType = self::CONTENT_TYPE_FORM
              Severity: Minor
              Found in src/Client/BasicAuthClient.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 create has 8 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      string $appId,
                      string $appSecret,
                      array $scopes,
                      array $headers = [],
                      ?string $appUserId = null,
              Severity: Major
              Found in src/Bookboon.php - About 1 hr to fix

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

                        $apiId,
                        $apiSecret,
                        Headers $headers,
                        CacheInterface $cache = null,
                        $apiUri = null,
                Severity: Minor
                Found in src/Client/BasicAuthClient.php - About 45 mins to fix

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

                      public function makeRequest(
                          string $relativeUrl,
                          array $variables = [],
                          string $httpMethod = ClientInterface::HTTP_GET,
                          bool $shouldCache = true,
                  Severity: Minor
                  Found in src/Client/RequestTrait.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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                      public static function get(Bookboon $bookboon, array $bookTypes = ['professional']) : BookboonResponse
                      {
                          $bResponse = $bookboon->rawRequest(
                              '/v1/languages',
                              [],
                  Severity: Minor
                  Found in src/Entity/Language.php and 1 other location - About 40 mins to fix
                  src/Entity/Journey.php on lines 59..74

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 94.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                      public static function getAll(Bookboon $bookboon, array $bookTypes = ['professional']) : BookboonResponse
                      {
                          $bResponse = $bookboon->rawRequest(
                              '/v1/journeys',
                              [],
                  Severity: Minor
                  Found in src/Entity/Journey.php and 1 other location - About 40 mins to fix
                  src/Entity/Language.php on lines 21..36

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 94.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

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

                          Bookboon $bookboon,
                          array $bookIds = [],
                          int $limit = 5,
                          array $bookTypes = ['professional'],
                          array $params = []
                  Severity: Minor
                  Found in src/Entity/Book.php - About 35 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language