nabbar/SwaggerValidator-PHP

View on GitHub
src/Common/CollectionType.php

Summary

Maintainability
A
35 mins
Test Coverage

Function registerCallable has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function registerCallable(\SwaggerValidator\Common\Context $context, $type, $callable)
    {
        if (!$this->__isset($type)) {
            $context->throwException('Cannot find type : "' . $type . '" (Normalized : "' . $this->normalizeType($type) . '" ', __FILE__, __LINE__);
        }
Severity: Minor
Found in src/Common/CollectionType.php - About 35 mins 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

Missing class import via use statement (line '231', column '26').
Open

            $class = new \ReflectionClass($callable);
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

The method __storeData uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        else {
            parent::__storeData($key, $value);
        }
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

The method registerCallable uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            else {
                $context->throwException('Callable is an abstract class : ' . $callable, __FILE__, __LINE__);
            }
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Avoid unused parameters such as '$data'.
Open

    public function unserialize($data)
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Constant Exception should be defined in uppercase
Open

    const Exception = '\\SwaggerValidator\\Exception';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant Contact should be defined in uppercase
Open

    const Contact             = '\\SwaggerValidator\\Object\\Contact';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant Definitions should be defined in uppercase
Open

    const Definitions         = '\\SwaggerValidator\\Object\\Definitions';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant ExternalDocs should be defined in uppercase
Open

    const ExternalDocs        = '\\SwaggerValidator\\Object\\ExternalDocs';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant IOHelper should be defined in uppercase
Open

    const IOHelper  = '\\SwaggerValidator\\CustomIOHelper';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant HeaderItem should be defined in uppercase
Open

    const HeaderItem          = '\\SwaggerValidator\\Object\\HeaderItem';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant Headers should be defined in uppercase
Open

    const Headers             = '\\SwaggerValidator\\Object\\Headers';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant Paths should be defined in uppercase
Open

    const Paths               = '\\SwaggerValidator\\Object\\Paths';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant TypeArrayItems should be defined in uppercase
Open

    const TypeArrayItems       = '\\SwaggerValidator\\DataType\\TypeArrayItems';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant Swagger should be defined in uppercase
Open

    const Swagger             = '\\SwaggerValidator\\Object\\Swagger';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant BasicAuthenticationSecurity should be defined in uppercase
Open

    const BasicAuthenticationSecurity  = '\\SwaggerValidator\\Security\\BasicAuthenticationSecurity';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant Responses should be defined in uppercase
Open

    const Responses           = '\\SwaggerValidator\\Object\\Responses';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant TypeNumber should be defined in uppercase
Open

    const TypeNumber           = '\\SwaggerValidator\\DataType\\TypeNumber';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant Info should be defined in uppercase
Open

    const Info                = '\\SwaggerValidator\\Object\\Info';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant SecurityDefinitions should be defined in uppercase
Open

    const SecurityDefinitions = '\\SwaggerValidator\\Object\\SecurityDefinitions';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant OAuth2PasswordSecurity should be defined in uppercase
Open

    const OAuth2PasswordSecurity       = '\\SwaggerValidator\\Security\\OAuth2PasswordSecurity';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant SecurityRequirement should be defined in uppercase
Open

    const SecurityRequirement = '\\SwaggerValidator\\Object\\SecurityRequirement';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant TypeFile should be defined in uppercase
Open

    const TypeFile             = '\\SwaggerValidator\\DataType\\TypeFile';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant TypeObjectProperties should be defined in uppercase
Open

    const TypeObjectProperties = '\\SwaggerValidator\\DataType\\TypeObject';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant OAuth2ApplicationSecurity should be defined in uppercase
Open

    const OAuth2ApplicationSecurity    = '\\SwaggerValidator\\Security\\OAuth2ApplicationSecurity';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant OAuth2PasswordSecurityScopes should be defined in uppercase
Open

    const OAuth2PasswordSecurityScopes = '\\SwaggerValidator\\Security\\OAuth2PasswordSecurityScopes';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant Reference should be defined in uppercase
Open

    const Reference           = '\\SwaggerValidator\\Object\\Reference';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant ResponseItem should be defined in uppercase
Open

    const ResponseItem        = '\\SwaggerValidator\\Object\\ResponseItem';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant TypeArray should be defined in uppercase
Open

    const TypeArray            = '\\SwaggerValidator\\DataType\\TypeArray';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant Operation should be defined in uppercase
Open

    const Operation           = '\\SwaggerValidator\\Object\\Operation';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant Security should be defined in uppercase
Open

    const Security            = '\\SwaggerValidator\\Object\\Security';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant Parameters should be defined in uppercase
Open

    const Parameters          = '\\SwaggerValidator\\Object\\Parameters';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant TypeInteger should be defined in uppercase
Open

    const TypeInteger          = '\\SwaggerValidator\\DataType\\TypeInteger';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant License should be defined in uppercase
Open

    const License             = '\\SwaggerValidator\\Object\\License';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant ParameterBody should be defined in uppercase
Open

    const ParameterBody       = '\\SwaggerValidator\\Object\\ParameterBody';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant PathItem should be defined in uppercase
Open

    const PathItem            = '\\SwaggerValidator\\Object\\PathItem';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant ApiKeySecurity should be defined in uppercase
Open

    const ApiKeySecurity               = '\\SwaggerValidator\\Security\\ApiKeySecurity';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant TypeCombined should be defined in uppercase
Open

    const TypeCombined         = '\\SwaggerValidator\\DataType\\TypeCombined';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant SecurityItem should be defined in uppercase
Open

    const SecurityItem        = '\\SwaggerValidator\\Object\\SecurityItem';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant TypeBoolean should be defined in uppercase
Open

    const TypeBoolean          = '\\SwaggerValidator\\DataType\\TypeBoolean';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant TypeObject should be defined in uppercase
Open

    const TypeObject           = '\\SwaggerValidator\\DataType\\TypeObject';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant TypeString should be defined in uppercase
Open

    const TypeString           = '\\SwaggerValidator\\DataType\\TypeString';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant OAuth2AccessCodeSecurity should be defined in uppercase
Open

    const OAuth2AccessCodeSecurity     = '\\SwaggerValidator\\Security\\OAuth2AccessCodeSecurity';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

Constant OAuth2ImplicitSecurity should be defined in uppercase
Open

    const OAuth2ImplicitSecurity       = '\\SwaggerValidator\\Security\\OAuth2ImplicitSecurity';
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

ConstantNamingConventions

Since: 0.2

Class/Interface constant names should always be defined in uppercase.

Example

class Foo {
    const MY_NUM = 0; // ok
    const myTest = ""; // fail
}

Source https://phpmd.org/rules/naming.html#constantnamingconventions

The method __storeData is not named in camelCase.
Open

    protected function __storeData($key, $value = null)
    {
        if (property_exists($this, $key)) {
            $this->$key = $value;
        }
Severity: Minor
Found in src/Common/CollectionType.php by phpmd

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

There are no issues that match your filters.

Category
Status