Showing 32 of 32 total issues
Function add
has a Cognitive Complexity of 69 (exceeds 5 allowed). Consider refactoring. Open
public static function add(&$holder, $pathItems, $value, $flags = self::RECURSIVE_KEY_CREATION)
{
$ref = &$holder;
while (null !== $key = array_shift($pathItems)) {
if ($ref instanceof \stdClass || is_object($ref)) {
- 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 process
has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring. Open
private function process($original, $new)
{
$merge = !($this->options & self::SKIP_JSON_MERGE_PATCH);
if ($this->options & self::TOLERATE_ASSOCIATIVE_ARRAYS) {
- 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 rearrangeArray
has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring. Open
private function rearrangeArray(array $original, array $new)
{
$first = reset($original);
if (!$first instanceof \stdClass) {
return $this->rearrangeEqualItems($original, $new);
- 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 remove
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
public static function remove(&$holder, $pathItems, $flags = 0)
{
$ref = &$holder;
while (null !== $key = array_shift($pathItems)) {
$parent = &$ref;
- 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 import
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
public static function import(array $data)
{
$result = new JsonPatch();
foreach ($data as $operation) {
/** @var OpPath|OpPathValue|OpPathFrom|array $operation */
- 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 113 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function process($original, $new)
{
$merge = !($this->options & self::SKIP_JSON_MERGE_PATCH);
if ($this->options & self::TOLERATE_ASSOCIATIVE_ARRAYS) {
File JsonDiff.php
has 349 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Swaggest\JsonDiff;
use Swaggest\JsonDiff\JsonPatch\Add;
Function xorHash
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
public function xorHash($data, $path = '')
{
$xorHash = '';
if (!$data instanceof \stdClass && !is_array($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 rearrangeArray
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function rearrangeArray(array $original, array $new)
{
$first = reset($original);
if (!$first instanceof \stdClass) {
return $this->rearrangeEqualItems($original, $new);
Function get
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public static function get($holder, $pathItems)
{
$ref = $holder;
while (null !== $key = array_shift($pathItems)) {
if ($ref 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 apply
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public function apply(&$original, $stopOnError = true)
{
$errors = array();
foreach ($this->operations as $opIndex => $operation) {
try {
- 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 apply
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function apply(&$original, $stopOnError = true)
{
$errors = array();
foreach ($this->operations as $opIndex => $operation) {
try {
Method init
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
static function init()
{
self::$simpleOriginal = (object)(array("root" => (object)array("a" => 1, "b" => 2)));
self::$simpleNew = (object)(array("root" => (object)array("b" => 3, "c" => 4)));
self::$original = json_decode(<<<'JSON'
Method import
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function import(array $data)
{
$result = new JsonPatch();
foreach ($data as $operation) {
/** @var OpPath|OpPathValue|OpPathFrom|array $operation */
Method add
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function add(&$holder, $pathItems, $value, $flags = self::RECURSIVE_KEY_CREATION)
{
$ref = &$holder;
while (null !== $key = array_shift($pathItems)) {
if ($ref instanceof \stdClass || is_object($ref)) {
Function apply
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public static function apply(&$original, $patch)
{
if (null === $patch) {
$original = null;
} elseif (is_object($patch)) {
- 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 xorHash
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function xorHash($data, $path = '')
{
$xorHash = '';
if (!$data instanceof \stdClass && !is_array($data)) {
Method remove
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function remove(&$holder, $pathItems, $flags = 0)
{
$ref = &$holder;
while (null !== $key = array_shift($pathItems)) {
$parent = &$ref;
Method process
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function process($data)
{
$check = true;
if ($this->pathFilterRegex && !preg_match($this->pathFilterRegex, $this->path)) {
$check = false;
Method rearrangeEqualItems
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function rearrangeEqualItems(array $original, array $new)
{
if ($this->jsonHash === null) {
$this->jsonHash = new JsonHash($this->options);
}