gdbots/pbj-php

View on GitHub
src/Marshaler/DynamoDb/ItemMarshaler.php

Summary

Maintainability
D
2 days
Test Coverage

Function doUnmarshal has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

    private function doUnmarshal(array $data): Message
    {
        Assertion::keyIsset(
            $data['M'],
            Schema::PBJ_FIELD_NAME,
Severity: Minor
Found in src/Marshaler/DynamoDb/ItemMarshaler.php - About 6 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 ItemMarshaler.php has 325 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
declare(strict_types=1);

namespace Gdbots\Pbj\Marshaler\DynamoDb;

Severity: Minor
Found in src/Marshaler/DynamoDb/ItemMarshaler.php - About 3 hrs to fix

    Method doUnmarshal has 74 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function doUnmarshal(array $data): Message
        {
            Assertion::keyIsset(
                $data['M'],
                Schema::PBJ_FIELD_NAME,
    Severity: Major
    Found in src/Marshaler/DynamoDb/ItemMarshaler.php - About 2 hrs to fix

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

          private function encodeValue(mixed $value, Field $field): array
          {
              $type = $field->getType();
      
              if ($type->encodesToScalar()) {
      Severity: Minor
      Found in src/Marshaler/DynamoDb/ItemMarshaler.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 marshal has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          public function marshal(Message $message): array
          {
              $schema = $message::schema();
              $message->validate();
              $payload = [];
      Severity: Minor
      Found in src/Marshaler/DynamoDb/ItemMarshaler.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 marshal has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function marshal(Message $message): array
          {
              $schema = $message::schema();
              $message->validate();
              $payload = [];
      Severity: Minor
      Found in src/Marshaler/DynamoDb/ItemMarshaler.php - About 1 hr to fix

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

            private function encodeASetValue(array $value, Field $field): array
            {
                $type = $field->getType();
        
                if ($type->isString()) {
        Severity: Minor
        Found in src/Marshaler/DynamoDb/ItemMarshaler.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

        Avoid too many return statements within this method.
        Open

                            return [self::TYPE_BINARY => $value];
        Severity: Major
        Found in src/Marshaler/DynamoDb/ItemMarshaler.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                              return ['NULL' => true];
          Severity: Major
          Found in src/Marshaler/DynamoDb/ItemMarshaler.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return $type->encode($value, $field, $this);
            Severity: Major
            Found in src/Marshaler/DynamoDb/ItemMarshaler.php - About 30 mins to fix

              There are no issues that match your filters.

              Category
              Status