Showing 68 of 77 total issues
Method doDeserialize
has 56 lines of code (exceeds 25 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();
Method doUnmarshal
has 56 lines of code (exceeds 25 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();
MappingBuilder
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
class MappingBuilder
{
/**
* Generally we use "__" to indicate a derived field but kibana won't recognize it.
* So for now, we'll use "d__" to indicate a derived field for ES.
Schema
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
final class Schema implements \JsonSerializable
{
const PBJ_FIELD_NAME = '_schema';
private string $className;
Function guard
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function guard(mixed $value, Field $field): void
{
$fieldName = $field->getName();
Assertion::string($value, null, $fieldName);
- 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
Consider simplifying this complex logical expression. Open
} else if (($c >= 8219 && $c <= 8223) || $c == 8242 || $c == 8243 || $c == 8216 || $c == 8217 || $c == 168 || $c == 180 || $c == 729 || $c == 733) {
//all the strange curly single and double quotes
// Ignore them
} else if ($c == 188) {
$slug .= '-one-quarter-';
Function applyDefault
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private function applyDefault($default = null): void
{
$this->default = $default;
if ($this->type->isScalar()) {
- 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 buildSchema
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function buildSchema(Schema $schema): array
{
$properties = [];
if ($this->getPathDepth() > static::MAX_PATH_DEPTH) {
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()) {
- 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 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 = [];
- 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 getNestedMessages
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private function getNestedMessages(): array
{
$messages = [];
foreach (static::schema()->getFields() as $field) {
if ($field->getType()->isMessage()) {
- 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 marshal
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function marshal(Message $message): array
{
$schema = $message::schema();
$message->validate();
$payload = [];
Method create
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function create(string $str, bool $camelize = true): ?string
{
// remove special chars (accents, etc.)
$str = trim(self::normalize($str));
$str = ltrim($str, '#_ ');
Method applyDefault
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function applyDefault($default = null): void
{
$this->default = $default;
if ($this->type->isScalar()) {
Function getDefault
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function getDefault(?Message $message = null): mixed
{
if (null === $this->default) {
if ($this->useTypeDefault) {
return $this->isASingleValue() ? $this->type->getDefault() : [];
- 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 varToString
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function varToString($var): string
{
if (is_object($var)) {
return sprintf('Object(%s)', get_class($var));
}
- 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 create
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function create(string $str, bool $camelize = true): ?string
{
// remove special chars (accents, etc.)
$str = trim(self::normalize($str));
$str = ltrim($str, '#_ ');
- 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 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()) {
- 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
Consider simplifying this complex logical expression. Open
if (($c >= 224 && $c <= 229) || ($c >= 192 && $c <= 198) || ($c >= 281 && $c <= 286)) {
$slug .= 'a';
} else if (($c >= 232 && $c <= 235) || ($c >= 200 && $c <= 203)) {
$slug .= 'e';
} else if (($c >= 236 && $c <= 239) || ($c >= 204 && $c <= 207)) {
Method __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
private function __construct(string $vendor, string $package, string $category, string $message, string $version)