prismicio/php-kit

View on GitHub

Showing 36 of 36 total issues

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

    private static function insertSpans($text, array $spans, $linkResolver = null, $htmlSerializer = null)
    {
        if (empty($spans)) {
            return htmlentities($text, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, 'UTF-8');
        }
Severity: Minor
Found in src/Prismic/Dom/RichText.php - About 5 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 asHtml has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

    public static function asHtml($richText, $linkResolver = null, $htmlSerializer = null)
    {
        $groups = [];

        foreach ($richText as $block) {
Severity: Minor
Found in src/Prismic/Dom/RichText.php - About 4 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 serialize has 95 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private static function serialize($element, $content, $linkResolver, $htmlSerializer) : string
    {
        if ($htmlSerializer) {
            $custom = $htmlSerializer($element, $content);
            if ($custom) {
Severity: Major
Found in src/Prismic/Dom/RichText.php - About 3 hrs to fix

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

    class Api
    {
    
        /**
         * Kit version number
    Severity: Minor
    Found in src/Prismic/Api.php - About 3 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

        File Api.php has 291 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 3 hrs to fix

          Function submit has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              public function submit() : array
              {
                  $numargs = func_num_args();
                  if ($numargs == 1 && is_array(func_get_arg(0))) {
                      $forms = func_get_arg(0);
          Severity: Minor
          Found in src/Prismic/Api.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 insertSpans has 64 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private static function insertSpans($text, array $spans, $linkResolver = null, $htmlSerializer = null)
              {
                  if (empty($spans)) {
                      return htmlentities($text, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, 'UTF-8');
                  }
          Severity: Major
          Found in src/Prismic/Dom/RichText.php - About 2 hrs to fix

            Function serialize has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
            Open

                private static function serialize($element, $content, $linkResolver, $htmlSerializer) : string
                {
                    if ($htmlSerializer) {
                        $custom = $htmlSerializer($element, $content);
                        if ($custom) {
            Severity: Minor
            Found in src/Prismic/Dom/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

            File RichText.php has 255 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            
            namespace Prismic\Dom;
            
            use Prismic\Dom\BlockGroup;
            Severity: Minor
            Found in src/Prismic/Dom/RichText.php - About 2 hrs to fix

              Method asHtml has 53 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function asHtml($richText, $linkResolver = null, $htmlSerializer = null)
                  {
                      $groups = [];
              
                      foreach ($richText as $block) {
              Severity: Major
              Found in src/Prismic/Dom/RichText.php - About 2 hrs to fix

                Consider simplifying this complex logical expression.
                Open

                        if ($block->type === 'heading1' ||
                            $block->type === 'heading2' ||
                            $block->type === 'heading3' ||
                            $block->type === 'heading4' ||
                            $block->type === 'heading5' ||
                Severity: Critical
                Found in src/Prismic/Dom/RichText.php - About 2 hrs to fix

                  Method submit has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function submit() : array
                      {
                          $numargs = func_num_args();
                          if ($numargs == 1 && is_array(func_get_arg(0))) {
                              $forms = func_get_arg(0);
                  Severity: Minor
                  Found in src/Prismic/Api.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

                      Method submitRaw has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function submitRaw() : stdClass
                          {
                              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 __construct has 9 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                                array $refs,
                                array $bookmarks,
                                array $types,
                                array $languages,
                                array $tags,
                        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

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

                                  ?string $name,
                                  string  $method,
                                  ?string $rel,
                                  string  $enctype,
                                  string  $action,
                          Severity: Minor
                          Found in src/Prismic/Form.php - About 45 mins to fix

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

                                    private function recentDocs(int $count = 10) : array
                                    {
                                        /** @var SearchForm $form */
                                        $form = $this->api->forms()->everything;
                                        $form = $form->ref($this->api->ref());
                            Severity: Minor
                            Found in samples/document-explorer.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 __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                    string $id,
                                    string $ref,
                                    string $label,
                                    bool   $isMasterRef,
                                    ?int   $maybeScheduledAt = null
                            Severity: Minor
                            Found in src/Prismic/Ref.php - About 35 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language