Skip to content

[maintainability] QuantumManager::circuit()/batch() re-implement driverAlias()'s default-resolution logic instead of calling it #61

Description

@corgab

Summary

QuantumManager::driverAlias(string|UnitEnum|null $driver) already centralizes "resolve $driver to a string, falling back to getDefaultDriver() when null, and unwrapping enums" (src/QuantumManager.php:52-61), and is used by driver() for exactly this purpose. circuit(?string $driver = null) and batch(array $circuits, ?string $driver = null) each independently re-implement the null-fallback half of that same logic inline as $driver ?? $this->getDefaultDriver(), rather than delegating to driverAlias().

Where

  • src/QuantumManager.php:52-61 (driverAlias() — the existing centralized logic)
  • src/QuantumManager.php:69-75 (circuit() — line 74: $driver ?? $this->getDefaultDriver())
  • src/QuantumManager.php:80-89 (batch() — line 87: $driver ?? $this->getDefaultDriver())

Note: because circuit()/batch() type their own $driver parameter as ?string (not string|UnitEnum|null like driver()'s), the enum-unwrapping half of driverAlias() is not reachable through these two methods today — only the null-coalescing half is actually duplicated.

Refactor proposal

Have circuit() and batch() call $this->driverAlias($driver) instead of repeating $driver ?? $this->getDefaultDriver() inline, so there is exactly one place that knows how an absent driver name resolves to the default.

Severity: low

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions