bnomei/autoloader-for-kirby

View on GitHub
classes/Autoloader.php

Summary

Maintainability
F
3 days
Test Coverage
A
95%

Showing 7 of 7 total issues

Function registry has a Cognitive Complexity of 72 (exceeds 5 allowed). Consider refactoring.
Open

private function registry(string $type): array
{
// only register once
if (array_key_exists($type, $this->registry)) {
return $this->registry[$type];
Severity: Minor
Found in classes/Autoloader.php - About 1 day to fix

File Autoloader.php has 395 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
 
declare(strict_types=1);
 
namespace Bnomei;
Severity: Minor
Found in classes/Autoloader.php - About 5 hrs to fix

    Method registry has 128 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    private function registry(string $type): array
    {
    // only register once
    if (array_key_exists($type, $this->registry)) {
    return $this->registry[$type];
    Severity: Major
    Found in classes/Autoloader.php - About 5 hrs to fix

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

      public function __construct(array $options = [])
      {
      $this->options = self::array_merge_recursive_distinct([
      // we can not read the kirby options since we are loading
      // while kirby is booting, but once spyc is removed we can
      Severity: Major
      Found in classes/Autoloader.php - About 4 hrs to fix

        Autoloader has 24 functions (exceeds 20 allowed). Consider refactoring.
        Open

        final class Autoloader
        {
        // exclude files like filename.config.(php|yml)
        public const PHP = '/^[\w\d\-\_]+\.php$/';
         
         
        Severity: Minor
        Found in classes/Autoloader.php - About 2 hrs to fix

          Consider simplifying this complex logical expression.
          Open

          if ($options['key'] === 'classname') {
          $this->registry[$type][$key] = $class;
          } elseif ($options['key'] === 'route') {
          // Author: @tobimori
          $pattern = strtolower($file->getRelativePathname());
          Severity: Critical
          Found in classes/Autoloader.php - About 1 hr to fix

            Avoid too many return statements within this method.
            Open

            return $this->registry[$type];
            Severity: Major
            Found in classes/Autoloader.php - About 30 mins to fix

              There are no issues that match your filters.

              Category
              Status