Showing 89 of 92 total issues
Method getSchemaPointers
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getSchemaPointers($path, $isURIFragmentId = false)
{
$items = explode('->', $path);
unset($items[0]);
$result = array();
Function isValid
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public static function isValid(array $data)
{
$index = array();
foreach ($data as $value) {
if (is_array($value) || $value instanceof \stdClass) {
- 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 getFailedSubSchema
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function getFailedSubSchema(Schema $schema)
{
$schemaPointer = $this->getSchemaPointer();
if ($schema instanceof ObjectItemContract) {
$refs = $schema->getFromRefs();
- 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 preProcessReferences
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function preProcessReferences($data, Context $options, $nestingLevel = 0)
{
if ($nestingLevel > 200) {
throw new Exception('Too deep nesting level', Exception::DEEP_NESTING);
}
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))
Function getFromRefPath
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function getFromRefPath()
{
if ($this->__refPath === null) {
$this->__refPath = '';
if ($this->__fromRef) {
- 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 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 ||
Method resolveURI
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function resolveURI($parent, $current)
{
if ($current === '') {
return $parent;
}
Function dateTimeError
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function dateTimeError($data)
{
if (!preg_match('/^' . self::$dateRegexPart . 'T' . self::$timeRegexPart . '$/i', $data)) {
return 'Invalid date-time format: ' . $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
Function unicodeNextChar
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private static function unicodeNextChar($string, &$pointer)
{
if (!isset($string[$pointer])) return false;
$char = ord($string[$pointer]);
if ($char < 128) {
- 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 (isset($test->schemas)) {
foreach ($test->schemas as $i => $schema) {
$testCases[$name . '_' . $i] = array(
'schema' => $schema,
'data' => $case->data,
Avoid deeply nested control flow statements. Open
if (isset($test->schemas)) {
foreach ($test->schemas as $i => $schema) {
$testCases[$name . '_' . $i] = array(
'schema' => $schema,
'data' => $case->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
Method process
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function process(Context $options, $encoding, $mediaType, $data, $import = true)