tflori/dependency-injector

View on GitHub

Showing 4 of 4 total issues

Function resolve has a Cognitive Complexity of 18 (exceeds 9 allowed). Consider refactoring.
Open

    protected function resolve($name): FactoryInterface
    {
        if (!isset($this->factories[$name])) {
            foreach ($this->namespaces as $namespace) {
                $class = sprintf($namespace, ucfirst($name));
Severity: Minor
Found in src/Container.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

Method add has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function add(string $name, $getter): FactoryInterface
    {
        $factory = null;
        if ($getter instanceof FactoryInterface) {
            $factory = $getter;
Severity: Minor
Found in src/Container.php - About 1 hr to fix

    Function add has a Cognitive Complexity of 12 (exceeds 9 allowed). Consider refactoring.
    Open

        public function add(string $name, $getter): FactoryInterface
        {
            $factory = null;
            if ($getter instanceof FactoryInterface) {
                $factory = $getter;
    Severity: Minor
    Found in src/Container.php - About 45 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 set has a Cognitive Complexity of 10 (exceeds 9 allowed). Consider refactoring.
    Open

        public static function set($name, $getter = null, bool $share = true, bool $instance = false)
        {
            if (is_array($name)) {
                $dependencies = $name;
                $factories = [];
    Severity: Minor
    Found in src/DI.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

    Severity
    Category
    Status
    Source
    Language