netglue/prismic-php-kit

View on GitHub

Showing 41 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

        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

                    Function v1Factory has a Cognitive Complexity of 12 (exceeds 5 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

                    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 submit has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function submit() : Response
                        {
                            if ($this->form->getMethod() !== 'GET' ||
                                $this->form->getEnctype() !== 'application/x-www-form-urlencoded' ||
                                ! $this->form->getAction()
                    Severity: Minor
                    Found in src/Prismic/SearchForm.php - About 1 hr to fix

                      Method fromJsonObject has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public static function fromJsonObject(stdClass $data, Api $api) : DocumentInterface
                          {
                              $inst        = new static;
                              $inst->api   = $api;
                              $inst->id    = $inst->assertRequiredProperty($data, 'id', false);
                      Severity: Minor
                      Found in src/Prismic/Document.php - About 1 hr to fix

                        Method fromJson has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public static function fromJson($value, LinkResolver $linkResolver) : self
                            {
                                // Type and Label are the same for V1 & V2
                                $type    = isset($value->slice_type)
                                         ? (string) $value->slice_type
                        Severity: Minor
                        Found in src/Prismic/Document/Fragment/Slice.php - About 1 hr to fix

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

                                  array $refs,
                                  array $bookmarks,
                                  array $types,
                                  array $tags,
                                  array $forms,
                          Severity: Major
                          Found in src/Prismic/ApiData.php - About 1 hr to fix

                            Function set has a Cognitive Complexity of 9 (exceeds 5 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 55 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

                            Severity
                            Category
                            Status
                            Source
                            Language