Showing 70 of 70 total issues

Function parseValue has a Cognitive Complexity of 83 (exceeds 5 allowed). Consider refactoring.
Open

    protected static function parseValue($json, &$pos, $assoc = false, $variables = [], $options = 0)
    {
        $length = strlen($json);
        $result = '';

Severity: Minor
Found in src/LJSON.php - About 1 day to fix

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 parseValue has 211 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected static function parseValue($json, &$pos, $assoc = false, $variables = [], $options = 0)
    {
        $length = strlen($json);
        $result = '';

Severity: Major
Found in src/LJSON.php - About 1 day to fix

File LJSON.php has 372 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
namespace LJSON;

/**
 * Class LJSON
Severity: Minor
Found in src/LJSON.php - About 4 hrs to fix

The class Parameter has 13 public methods. Consider refactoring Parameter to keep number of public methods under 10.
Open

class Parameter implements \ArrayAccess, \IteratorAggregate, \Countable
{
    /**
     * @var string
     */
Severity: Minor
Found in src/Parameter.php by phpmd

TooManyPublicMethods

Since: 0.1

A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

By default it ignores methods starting with 'get' or 'set'.

Example

Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

The class LJSON has an overall complexity of 134 which is very high. The configured complexity threshold is 50.
Open

class LJSON
{
    const RETURN_UNDEFINED_AS_SPECIAL_CLASS = 1073741824; // 2^30
    /**
     * @var bool
Severity: Minor
Found in src/LJSON.php by phpmd

Function stringify has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public static function stringify($value, $parameterCount = 0)
    {
        if (is_null($value) || is_bool($value)
            || is_int($value) || is_float($value) || is_double($value) || is_numeric($value)
            || is_string($value)
Severity: Minor
Found in src/LJSON.php - About 3 hrs to fix

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 stringify has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function stringify($value, $parameterCount = 0)
    {
        if (is_null($value) || is_bool($value)
            || is_int($value) || is_float($value) || is_double($value) || is_numeric($value)
            || is_string($value)
Severity: Major
Found in src/LJSON.php - About 2 hrs to fix

Consider simplifying this complex logical expression.
Open

        if (is_null($value) || is_bool($value)
            || is_int($value) || is_float($value) || is_double($value) || is_numeric($value)
            || is_string($value)
        ) {
            return json_encode($value);
Severity: Major
Found in src/LJSON.php - About 1 hr to fix

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    public function __call($name, $arguments)
    {
        $file = __FILE__;
        $line = __LINE__;
        $trace = (new \Exception)->getTrace();
Severity: Major
Found in src/Parameter.php and 2 other locations - About 1 hr to fix
src/Parameter.php on lines 99..109
src/Parameter.php on lines 148..158

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 100.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    public function offsetSet($offset, $value)
    {
        $file = __FILE__;
        $line = __LINE__;
        $trace = (new \Exception)->getTrace();
Severity: Major
Found in src/Parameter.php and 2 other locations - About 1 hr to fix
src/Parameter.php on lines 48..58
src/Parameter.php on lines 148..158

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 100.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    public function __set($name, $value)
    {
        $file = __FILE__;
        $line = __LINE__;
        $trace = (new \Exception)->getTrace();
Severity: Major
Found in src/Parameter.php and 2 other locations - About 1 hr to fix
src/Parameter.php on lines 48..58
src/Parameter.php on lines 99..109

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 100.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 6 locations. Consider refactoring.
Open

    public function offsetUnset($offset)
    {
        $file = __FILE__;
        $line = __LINE__;
        $trace = (new \Exception)->getTrace();
Severity: Major
Found in src/Parameter.php and 5 other locations - About 45 mins to fix
src/Parameter.php on lines 65..75
src/Parameter.php on lines 82..92
src/Parameter.php on lines 131..141
src/Parameter.php on lines 164..174
src/Parameter.php on lines 180..190

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 96.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 6 locations. Consider refactoring.
Open

    public function offsetGet($offset)
    {
        $file = __FILE__;
        $line = __LINE__;
        $trace = (new \Exception)->getTrace();
Severity: Major
Found in src/Parameter.php and 5 other locations - About 45 mins to fix
src/Parameter.php on lines 65..75
src/Parameter.php on lines 115..125
src/Parameter.php on lines 131..141
src/Parameter.php on lines 164..174
src/Parameter.php on lines 180..190

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 96.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 6 locations. Consider refactoring.
Open

    public function __unset($name)
    {
        $file = __FILE__;
        $line = __LINE__;
        $trace = (new \Exception)->getTrace();
Severity: Major
Found in src/Parameter.php and 5 other locations - About 45 mins to fix
src/Parameter.php on lines 65..75
src/Parameter.php on lines 82..92
src/Parameter.php on lines 115..125
src/Parameter.php on lines 131..141
src/Parameter.php on lines 164..174

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 96.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 6 locations. Consider refactoring.
Open

    public function __get($name)
    {
        $file = __FILE__;
        $line = __LINE__;
        $trace = (new \Exception)->getTrace();
Severity: Major
Found in src/Parameter.php and 5 other locations - About 45 mins to fix
src/Parameter.php on lines 65..75
src/Parameter.php on lines 82..92
src/Parameter.php on lines 115..125
src/Parameter.php on lines 164..174
src/Parameter.php on lines 180..190

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 96.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 6 locations. Consider refactoring.
Open

    public function __isset($name)
    {
        $file = __FILE__;
        $line = __LINE__;
        $trace = (new \Exception)->getTrace();
Severity: Major
Found in src/Parameter.php and 5 other locations - About 45 mins to fix
src/Parameter.php on lines 65..75
src/Parameter.php on lines 82..92
src/Parameter.php on lines 115..125
src/Parameter.php on lines 131..141
src/Parameter.php on lines 180..190

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 96.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 6 locations. Consider refactoring.
Open

    public function offsetExists($offset)
    {
        $file = __FILE__;
        $line = __LINE__;
        $trace = (new \Exception)->getTrace();
Severity: Major
Found in src/Parameter.php and 5 other locations - About 45 mins to fix
src/Parameter.php on lines 82..92
src/Parameter.php on lines 115..125
src/Parameter.php on lines 131..141
src/Parameter.php on lines 164..174
src/Parameter.php on lines 180..190

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 96.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Avoid deeply nested control flow statements.
Open

                        if (strlen($use) > 0) {
                            $use = 'use(' . $use . ')';
                        }
Severity: Major
Found in src/LJSON.php - About 45 mins to fix

Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function __construct($message, $file, $line, $code = 0, $previous = null)
Severity: Minor
Found in src/StringifyException.php - About 35 mins to fix

Method parseValue has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    protected static function parseValue($json, &$pos, $assoc = false, $variables = [], $options = 0)
Severity: Minor
Found in src/LJSON.php - About 35 mins to fix
Severity
Category
Status
Source
Language