Skip to content

Commit

Permalink
Simplify getting target namespace by including appending \
Browse files Browse the repository at this point in the history
  • Loading branch information
coenjacobs committed Sep 9, 2024
1 parent 15a5bcb commit 2cbde92
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
9 changes: 8 additions & 1 deletion src/Config/Mozart.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use stdClass;
use CoenJacobs\Mozart\Config\OverrideAutoload;
use CoenJacobs\Mozart\Config\Package;
use Exception;

class Mozart
{
Expand Down Expand Up @@ -92,7 +93,13 @@ public function getDeleteVendorDirectories(): bool

public function getDependencyNamespace(): string
{
return $this->dep_namespace;
$namespace = preg_replace("/\\\{2,}$/", "\\", $this->dep_namespace."\\");

if (empty($namespace)) {
throw new Exception('Could not get target dependency namespace');
}

return $namespace;
}

public function getClassmapPrefix(): string
Expand Down
4 changes: 1 addition & 3 deletions src/Config/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ public function __construct($path, $overrideAutoload = null)
$this->path = $path;

if (isset($overrideAutoload)) {
$autoload = new Autoload();
$autoload->setupAutoloaders($overrideAutoload);
$this->set('autoload', $autoload);
$this->setAutoload($overrideAutoload);
}
}

Expand Down
5 changes: 0 additions & 5 deletions src/Console/Commands/Compose.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

$this->config = $config;
$this->config->set('dep_namespace', preg_replace(
"/\\\{2,}$/",
"\\",
$this->config->getDependencyNamespace()."\\"
));

$require = $this->config->getPackages();
if (empty($require)) {
Expand Down

0 comments on commit 2cbde92

Please sign in to comment.