projek-xyz/slim-framework

View on GitHub
src/DefaultServicesProvider.php

Summary

Maintainability
C
1 day
Test Coverage

Method register has 102 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function register(PimpleContainer $container)
    {
        /** @var Collection $settings */
        $settings = $container->get('settings');

Severity: Major
Found in src/DefaultServicesProvider.php - About 4 hrs to fix

    Avoid too many return statements within this method.
    Open

                return function ($data, array $rules) use ($container) {
                    if ($data instanceof ServerRequestInterface) {
                        $data = $data->getParsedBody();
                    }
    
    
    Severity: Major
    Found in src/DefaultServicesProvider.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                  return new SlimDatabase($db['dsn'], $db['user'], $db['pass'], [
                      \PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_CLASS
                  ]);
      Severity: Major
      Found in src/DefaultServicesProvider.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

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

          Avoid too many return statements within this method.
          Open

                      return new Database\Migrator($container->get('db'), $directory);
          Severity: Major
          Found in src/DefaultServicesProvider.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                        return function ($class) use ($container) {
                            if (!class_exists($class)) {
                                throw new \LogicException("Data model class {$class} not exists ");
                            }
            
            
            Severity: Major
            Found in src/DefaultServicesProvider.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                          return new Uploader($settings['upload']);
              Severity: Major
              Found in src/DefaultServicesProvider.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return array_merge($commands, $settings->get('commands', []));
                Severity: Major
                Found in src/DefaultServicesProvider.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

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

                    Avoid too many return statements within this method.
                    Open

                                return new Logger($settings['basename'], $settings['logger'] ?: []);
                    Severity: Major
                    Found in src/DefaultServicesProvider.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return new Mailer(
                                      $container->get(Mailer\MailDriverInterface::class)
                                  );
                      Severity: Major
                      Found in src/DefaultServicesProvider.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                    return new FileSystem($settings->get('filesystem', []));
                        Severity: Major
                        Found in src/DefaultServicesProvider.php - About 30 mins to fix

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

                              public function register(PimpleContainer $container)
                              {
                                  /** @var Collection $settings */
                                  $settings = $container->get('settings');
                          
                          
                          Severity: Minor
                          Found in src/DefaultServicesProvider.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

                          There are no issues that match your filters.

                          Category
                          Status