maestroprog/di-container

View on GitHub
src/Container.php

Summary

Maintainability
C
1 day
Test Coverage

Showing 6 of 6 total issues

Function get has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

public function get($id)
{
$id = ucfirst($id);
if (array_key_exists($id, $this->instances)) {
// fast getter
Severity: Minor
Found in src/Container.php - About 4 hrs to fix

Method get has 66 lines of code (exceeds 25 allowed). Consider refactoring.
Open

public function get($id)
{
$id = ucfirst($id);
if (array_key_exists($id, $this->instances)) {
// fast getter
Severity: Major
Found in src/Container.php - About 2 hrs to fix

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

    protected function addService(int $containerId, string $serviceId, Argument $argument): void
    {
    if (substr($serviceId, -8) === 'Original') {
    throw new \InvalidArgumentException(sprintf(
    'Service id cannot ends with "Original" keyword in "%s".',
    Severity: Minor
    Found in src/Container.php - About 1 hr to fix

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

    protected function addService(int $containerId, string $serviceId, Argument $argument): void
    {
    if (substr($serviceId, -8) === 'Original') {
    throw new \InvalidArgumentException(sprintf(
    'Service id cannot ends with "Original" keyword in "%s".',
    Severity: Minor
    Found in src/Container.php - About 1 hr to fix

      Function append has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      protected function append(Argument $argument, string $serviceId, int $containerId): void
      {
      $returnType = $argument->getReturnType();
       
      $overridden = false;
      Severity: Minor
      Found in src/Container.php - About 45 mins to fix

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

      public function register($container): void
      {
      static $id = 0;
       
      $this->containers[++$id] = $container;
      Severity: Minor
      Found in src/Container.php - About 25 mins to fix

      There are no issues that match your filters.

      Category
      Status