php-yaoi/php-yaoi

View on GitHub
src/Service.php

Summary

Maintainability
C
1 day
Test Coverage

Function findOrCreateInstance has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    private static function findOrCreateInstance($serviceClassName, $identifier, $idIsSettings = false) {
        //var_dump('=-=-=-=-=-=-=-=-=-=-=-=-=-=',$serviceClassName, $identifier, $idIsSettings);

        if ($identifier instanceof Closure) {
            $identifier = self::resolveClosure($identifier);
Severity: Minor
Found in src/Service.php - About 4 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 findOrCreateInstance has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private static function findOrCreateInstance($serviceClassName, $identifier, $idIsSettings = false) {
        //var_dump('=-=-=-=-=-=-=-=-=-=-=-=-=-=',$serviceClassName, $identifier, $idIsSettings);

        if ($identifier instanceof Closure) {
            $identifier = self::resolveClosure($identifier);
Severity: Major
Found in src/Service.php - About 2 hrs to fix

    Function getDriver has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getDriver()
        {
            if (null === $this->driver) {
                if ($this->settings && $this->settings->driverClassName) {
                    $driverClass = $this->settings->driverClassName;
    Severity: Minor
    Found in src/Service.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

    Function __construct has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public function __construct($settings = null)
        {
            $settingsClass = static::getSettingsClassName();
            if (null === $settingsClass) {
                $settingsClass = Settings::className();
    Severity: Minor
    Found in src/Service.php - About 55 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

    Avoid too many return statements within this method.
    Open

                    return $resource;
    Severity: Major
    Found in src/Service.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                  return new $serviceClassName($identifier);
      Severity: Major
      Found in src/Service.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                            return $resource;
        Severity: Major
        Found in src/Service.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                      return $identifier;
          Severity: Major
          Found in src/Service.php - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status