Function processObject
has a Cognitive Complexity of 271 (exceeds 5 allowed). Consider refactoring. Open
private function processObject($data, Context $options, $path, $result = null)
{
$import = $options->import;
$hasMapping = $this->properties !== null && isset($this->properties->__dataToProperty[$options->mapping]);
- 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 Schema.php
has 1068 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Swaggest\JsonSchema;
Method processObject
has 293 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function processObject($data, Context $options, $path, $result = null)
{
$import = $options->import;
$hasMapping = $this->properties !== null && isset($this->properties->__dataToProperty[$options->mapping]);
Function process
has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring. Open
public function process($data, Context $options, $path = '#', $result = null)
{
$origData = $data;
$import = $options->import;
- 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
Schema
has 42 functions (exceeds 20 allowed). Consider refactoring. Open
class Schema extends JsonSchema implements MetaHolder, SchemaContract, HasDefault
{
const ENUM_NAMES_PROPERTY = 'x-enum-names';
const CONST_PROPERTY = 'const';
const DEFAULT_PROPERTY = 'default';
Function processArray
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
private function processArray($data, Context $options, $path, $result)
{
$count = count($data);
if (!$options->skipValidation) {
if ($this->minItems !== null && $count < $this->minItems) {
- 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 processNumeric
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
private function processNumeric($data, $path)
{
if ($this->multipleOf !== null) {
$div = $data / $this->multipleOf;
if ($div != (int)$div && ($div = $data * (1 / $this->multipleOf)) && ($div != (int)$div)) {
- 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 process
has 107 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function process($data, Context $options, $path = '#', $result = null)
{
$origData = $data;
$import = $options->import;
Method processArray
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function processArray($data, Context $options, $path, $result)
{
$count = count($data);
if (!$options->skipValidation) {
if ($this->minItems !== null && $count < $this->minItems) {
Function processEnum
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
private function processEnum($data, $path = '#')
{
$enumOk = false;
foreach ($this->enum as $item) {
if ($item === $data ||
- 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 processNumeric
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function processNumeric($data, $path)
{
if ($this->multipleOf !== null) {
$div = $data / $this->multipleOf;
if ($div != (int)$div && ($div = $data * (1 / $this->multipleOf)) && ($div != (int)$div)) {
Function processString
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
private function processString($data, $path)
{
if ($this->minLength !== null) {
if (mb_strlen($data, 'UTF-8') < $this->minLength) {
$this->fail((new StringException('String is too short', StringException::TOO_SHORT))
- 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 processOneOf
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private function processOneOf($data, Context $options, $path)
{
$successes = 0;
$failures = '';
$subErrors = [];
- 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 processOneOf
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function processOneOf($data, Context $options, $path)
{
$successes = 0;
$failures = '';
$subErrors = [];
Function processConst
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private function processConst($data, $path)
{
if ($this->const !== $data &&
!( // Int and float equality.
(is_int($this->const) || is_float($this->const)) &&
- 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 processString
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function processString($data, $path)
{
if ($this->minLength !== null) {
if (mb_strlen($data, 'UTF-8') < $this->minLength) {
$this->fail((new StringException('String is too short', StringException::TOO_SHORT))
Method processAnyOf
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function processAnyOf($data, Context $options, $path)
{
$successes = 0;
$failures = '';
$subErrors = [];
Method processEnum
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function processEnum($data, $path = '#')
{
$enumOk = false;
foreach ($this->enum as $item) {
if ($item === $data ||
Function import
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public static function import($data, Context $options = null)
{
if (null === $options) {
$options = new Context();
}
- 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 in
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function in($data, Context $options = null)
{
if (null !== $this->__booleanSchema) {
if ($this->__booleanSchema) {
return $data;
- 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
Avoid deeply nested control flow statements. Open
if ($result->__validateOnSet) {
$result->__validateOnSet = false;
/** @noinspection PhpUnusedLocalVariableInspection */
/* todo check performance impact
$validateOnSetHandler = new ScopeExit(function () use ($result) {
Function processAnyOf
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function processAnyOf($data, Context $options, $path)
{
$successes = 0;
$failures = '';
$subErrors = [];
- 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 ($this->const !== $data &&
!( // Int and float equality.
(is_int($this->const) || is_float($this->const)) &&
(is_int($data) || is_float($data)) &&
$this->const == $data
Consider simplifying this complex logical expression. Open
if ($item === $data ||
( // Int and float equality check.
(is_int($item) || is_float($item)) &&
(is_int($data) || is_float($data)) &&
$item == $data
Function makeObjectItem
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function makeObjectItem(Context $options = null)
{
if (null === $this->objectItemClass) {
return new ObjectItem();
} else {
- 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 processIf
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function processIf($data, Context $options, $path)
{
$valid = true;
try {
self::unboolSchema($this->if)->process($data, $options, $path . '->if');
- 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"