netglue/prismic-php-kit

View on GitHub

Showing 316 of 316 total issues

Api has 37 functions (exceeds 20 allowed). Consider refactoring.
Open

class Api
{

    /**
     * Kit version number
Severity: Minor
Found in src/Prismic/Api.php - About 4 hrs to fix

    File Api.php has 347 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    declare(strict_types=1);
    
    namespace Prismic;
    
    
    Severity: Minor
    Found in src/Prismic/Api.php - About 4 hrs to fix

      Predicates has 28 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Predicates
      {
      
          /**
           * @param string $fragment
      Severity: Minor
      Found in src/Prismic/Predicates.php - About 3 hrs to fix

        The class SearchForm has 13 public methods. Consider refactoring SearchForm to keep number of public methods under 10.
        Open

        class SearchForm
        {
        
            /**
             * @var Api
        Severity: Minor
        Found in src/Prismic/SearchForm.php by phpmd

        TooManyPublicMethods

        Since: 0.1

        A class with too many public 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'.

        Example

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

        The class Api has 12 public methods. Consider refactoring Api to keep number of public methods under 10.
        Open

        class Api
        {
        
            /**
             * Kit version number
        Severity: Minor
        Found in src/Prismic/Api.php by phpmd

        TooManyPublicMethods

        Since: 0.1

        A class with too many public 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'.

        Example

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

        The class Predicates has 27 public methods. Consider refactoring Predicates to keep number of public methods under 10.
        Open

        class Predicates
        {
        
            /**
             * @param string $fragment
        Severity: Minor
        Found in src/Prismic/Predicates.php by phpmd

        TooManyPublicMethods

        Since: 0.1

        A class with too many public 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'.

        Example

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

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

        class FragmentCollection implements CompositeFragmentInterface
        {
        
            /** @var FragmentInterface[] */
            protected $fragments = [];

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

        class Api
        {
        
            /**
             * Kit version number
        Severity: Minor
        Found in src/Prismic/Api.php by phpmd

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

        class Predicates
        {
        
            /**
             * @param string $fragment
        Severity: Minor
        Found in src/Prismic/Predicates.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

        Function v2Factory has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
        Open

            private function v2Factory(string $key, $value, LinkResolver $linkResolver) : void
            {
                if ($this->isEmptyFragment($value)) {
                    return;
                }
        Severity: Minor
        Found in src/Prismic/Document/Fragment/FragmentCollection.php - About 2 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 v2Factory has 63 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function v2Factory(string $key, $value, LinkResolver $linkResolver) : void
            {
                if ($this->isEmptyFragment($value)) {
                    return;
                }
        Severity: Major
        Found in src/Prismic/Document/Fragment/FragmentCollection.php - About 2 hrs to fix

          Method factory has 59 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function factory($value, LinkResolver $linkResolver) : FragmentInterface
              {
                  $richText = new static;
                  // In API V2, Rich text is an array of 'Block Level' objects,
                  // in V1, the array is in the property 'value'
          Severity: Major
          Found in src/Prismic/Document/Fragment/RichText.php - About 2 hrs to fix

            Function abstractFactory has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function abstractFactory($value, LinkResolver $linkResolver) :? LinkInterface
                {
                    // Inspect payload to determine link type
                    $linkType = isset($value->link_type) ? $value->link_type : null;
                    $linkType = isset($value->value) && isset($value->type) ? $value->type : $linkType;
            Severity: Minor
            Found in src/Prismic/Document/Fragment/Link/AbstractLink.php - About 2 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

            Function factory has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function factory($value, LinkResolver $linkResolver) : FragmentInterface
                {
                    $richText = new static;
                    // In API V2, Rich text is an array of 'Block Level' objects,
                    // in V1, the array is in the property 'value'
            Severity: Minor
            Found in src/Prismic/Document/Fragment/RichText.php - About 2 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 abstractFactory has 51 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function abstractFactory($value, LinkResolver $linkResolver) :? LinkInterface
                {
                    // Inspect payload to determine link type
                    $linkType = isset($value->link_type) ? $value->link_type : null;
                    $linkType = isset($value->value) && isset($value->type) ? $value->type : $linkType;
            Severity: Major
            Found in src/Prismic/Document/Fragment/Link/AbstractLink.php - About 2 hrs to fix

              Function insertSpans has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function insertSpans(string $text, array $spans, LinkResolver $linkResolver) : string
                  {
                      if (empty($spans)) {
                          return nl2br($this->escapeHtml($text));
                      }
              Severity: Minor
              Found in src/Prismic/Document/Fragment/HtmlHelperTrait.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 htmlAttributes has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function htmlAttributes(array $attributes) : string
                  {
                      $html = '';
                      foreach ($attributes as $key => $val) {
                          $key = $this->escapeHtml($key);
              Severity: Minor
              Found in src/Prismic/Document/Fragment/HtmlHelperTrait.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 v1Factory has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function v1Factory(string $key, $value, LinkResolver $linkResolver) : void
                  {
                      $fragment = null;
                      switch ($value->type) {
                          case 'Image':
              Severity: Minor
              Found in src/Prismic/Document/Fragment/FragmentCollection.php - About 1 hr to fix

                Method insertSpans has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function insertSpans(string $text, array $spans, LinkResolver $linkResolver) : string
                    {
                        if (empty($spans)) {
                            return nl2br($this->escapeHtml($text));
                        }
                Severity: Minor
                Found in src/Prismic/Document/Fragment/HtmlHelperTrait.php - About 1 hr to fix

                  Method set has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function set(string $key, $value) : self
                      {
                          if (empty($key)) {
                              throw new Exception\InvalidArgumentException('Form parameter key must be a non-empty string');
                          }
                  Severity: Minor
                  Found in src/Prismic/SearchForm.php - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language