mheinzerling/php-meta

View on GitHub
src/writer/TypeConverter.php

Summary

Maintainability
A
2 hrs
Test Coverage

Function toValue has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public static function toValue(PHPType $type, $value): string
    {
        if ($type instanceof PrimitivePHPType) {
            if ($value === null) return 'null';
            if ($type->isInt()) return (string)$value;
Severity: Minor
Found in src/writer/TypeConverter.php - About 1 hr 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

Avoid too many return statements within this method.
Open

            if ($value === null) return 'null';
Severity: Major
Found in src/writer/TypeConverter.php - About 30 mins to fix

    Function toPHP has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function toPHP(PHPType $type, ClassWriter $classWriter): string
        {
            $result = '';
            if ($type->isOptional()) $result .= "?";
            if ($type instanceof PrimitivePHPType) {
    Severity: Minor
    Found in src/writer/TypeConverter.php - About 25 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

    Function toPHPDoc has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function toPHPDoc(PHPType $type, ClassWriter $classWriter): string
        {
            $result = "";
            if ($type instanceof PrimitivePHPType) {
                $result .= $type->getToken();//TODO array of Object
    Severity: Minor
    Found in src/writer/TypeConverter.php - About 25 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 '17', column '19').
    Open

            throw new \Exception("Unhandled type " . get_class($type));
    Severity: Minor
    Found in src/writer/TypeConverter.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

    Missing class import via use statement (line '58', column '23').
    Open

                throw new \Exception("Unsupported for objects " . $type->getClass()->fullyQualified());
    Severity: Minor
    Found in src/writer/TypeConverter.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

    Missing class import via use statement (line '60', column '19').
    Open

            throw new \Exception("Unhandled type " . get_class($type));
    Severity: Minor
    Found in src/writer/TypeConverter.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

    Missing class import via use statement (line '28', column '23').
    Open

                throw new \Exception("Unhandled type " . get_class($type));
    Severity: Minor
    Found in src/writer/TypeConverter.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

    Missing class import via use statement (line '43', column '23').
    Open

                throw new \Exception("Unhandled type " . get_class($type));
    Severity: Minor
    Found in src/writer/TypeConverter.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

    TODO found
    Open

                $result .= $type->getToken();//TODO array of Object
    Severity: Minor
    Found in src/writer/TypeConverter.php by fixme

    There are no issues that match your filters.

    Category
    Status