Showing 68 of 77 total issues
Function create
has a Cognitive Complexity of 272 (exceeds 5 allowed). Consider refactoring. Open
public static function create(string $string, bool $allowSlashes = false): string
{
$slug = '';
$string = html_entity_decode($string, ENT_QUOTES);
- Read upRead up
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 AbstractMessage.php
has 447 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare(strict_types=1);
namespace Gdbots\Pbj;
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,
- Read upRead up
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
AbstractMessage
has 45 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class AbstractMessage implements Message, \JsonSerializable
{
/** @var Schema[] */
private static array $schemas = [];
private static ?PhpArraySerializer $serializer = null;
File Field.php
has 364 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare(strict_types=1);
namespace Gdbots\Pbj;
Function xmlEscape
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
public static function xmlEscape(string $str): string
{
// array used to figure what number to decrement from character order value
// according to number of characters used to map unicode to ascii by utf-8
$decrement = [];
- Read upRead up
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
Field
has 34 functions (exceeds 20 allowed). Consider refactoring. Open
final class Field implements \JsonSerializable
{
/**
* Regular expression pattern for matching a valid field name. The pattern allows
* for camelCase fields name but snake_case is recommend.
Function doUnmarshal
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
private function doUnmarshal(array $data): Message
{
$schemaId = SchemaId::fromString((string)$data[Schema::PBJ_FIELD_NAME]);
$className = MessageResolver::resolveId($schemaId);
$message = new $className();
- Read upRead up
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 doDeserialize
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
private function doDeserialize(array $data): Message
{
$schemaId = SchemaId::fromString((string)$data[Schema::PBJ_FIELD_NAME]);
$className = MessageResolver::resolveId($schemaId);
$message = new $className();
- Read upRead up
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;
File URLUtil.php
has 311 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare(strict_types=1);
namespace Gdbots\Pbj\Util;
File MappingBuilder.php
has 301 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare(strict_types=1);
namespace Gdbots\Pbj\Marshaler\Elastica;
Method create
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function create(string $string, bool $allowSlashes = false): string
{
$slug = '';
$string = html_entity_decode($string, ENT_QUOTES);
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,
Method guard
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function guard(mixed $value, Field $field): void
{
$fieldName = $field->getName();
Assertion::string($value, null, $fieldName);
Method xmlEscape
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function xmlEscape(string $str): string
{
// array used to figure what number to decrement from character order value
// according to number of characters used to map unicode to ascii by utf-8
$decrement = [];
Function buildSchema
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
protected function buildSchema(Schema $schema): array
{
$properties = [];
if ($this->getPathDepth() > static::MAX_PATH_DEPTH) {
- Read upRead up
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
FieldBuilder
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
final class FieldBuilder
{
private string $name;
private Type $type;
private ?FieldRule $rule = null;
Function validate
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
final public function validate(bool $strict = false, bool $recursive = false): static
{
if (!$strict && $this->isFrozen()) {
return $this;
}
- Read upRead up
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 18 arguments (exceeds 4 allowed). Consider refactoring. Open
string $name,
Type $type,
FieldRule $rule,
bool $required = false,
?int $minLength = null,