Skip to content
This repository has been archived by the owner on May 12, 2022. It is now read-only.

Commit

Permalink
Refactor functions.php
Browse files Browse the repository at this point in the history
  • Loading branch information
nickolasburr committed Mar 10, 2019
1 parent fad6346 commit 6933e06
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions functions.php
Expand Up @@ -33,25 +33,11 @@ function include_imports($package, $class) {
throw new \Exception('No import path was specified.');
}

/** @var string $short */
$short = Config::getShortNameFromFqcn($import['as'] ?? $use);

/** @var string $alias */
$alias = $import['as'] ?? null;

/**
* If an alias was explicitly set,
* use it instead of short name.
*/
if ($alias !== null) {
/**
* An alias only has context inside the scope
* of the file where it was included. As such,
* it should only contain a short name without
* the preceding namespace.
*/
$alias = $namespace . '\\' . Config::getShortNameFromFqcn($alias);
} else {
/** @var string $alias The alias (target) for the source class. */
$alias = $namespace . '\\' . Config::getShortNameFromFqcn($use);
}
$alias = $namespace . '\\' . $short;

if (!class_exists($alias)) {
class_alias($use, $alias);
Expand Down

0 comments on commit 6933e06

Please sign in to comment.