Skip to content

Commit

Permalink
[TASK] Make ProviderFactory available in service container
Browse files Browse the repository at this point in the history
  • Loading branch information
eliashaeussler committed Mar 22, 2023
1 parent c6d3533 commit fad9ebf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static function simulateCreateProject(Script\Event $event): never
private static function createApplication(IO\Messenger $messenger, string $targetDirectory): Console\Application
{
$filesystem = new Filesystem\Filesystem();
$providerFactory = Template\Provider\ProviderFactory::create($messenger, $filesystem);
$providerFactory = new Template\Provider\ProviderFactory($messenger, $filesystem);

return new Console\Application(
$messenger,
Expand Down
17 changes: 8 additions & 9 deletions src/Template/Provider/ProviderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,20 @@
final class ProviderFactory
{
/**
* @param non-empty-list<ProviderInterface> $providers
* @var non-empty-list<ProviderInterface>
*/
private function __construct(
private readonly array $providers,
) {
}
private readonly array $providers;

public static function create(IO\Messenger $messenger, Filesystem\Filesystem $filesystem): self
{
return new self([
public function __construct(
IO\Messenger $messenger,
Filesystem\Filesystem $filesystem,
) {
$this->providers = [
// sorted by priority
new PackagistProvider($messenger, $filesystem),
new ComposerProvider($messenger, $filesystem),
new VcsProvider($messenger, $filesystem),
]);
];
}

/**
Expand Down
6 changes: 1 addition & 5 deletions tests/src/Template/Provider/ProviderFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

use CPSIT\ProjectBuilder as Src;
use CPSIT\ProjectBuilder\Tests;
use Symfony\Component\Filesystem;

/**
* ProviderFactoryTest.
Expand All @@ -39,10 +38,7 @@ final class ProviderFactoryTest extends Tests\ContainerAwareTestCase

protected function setUp(): void
{
$this->subject = Src\Template\Provider\ProviderFactory::create(
self::$container->get(Src\IO\Messenger::class),
self::$container->get(Filesystem\Filesystem::class),
);
$this->subject = self::$container->get(Src\Template\Provider\ProviderFactory::class);
}

/**
Expand Down

0 comments on commit fad9ebf

Please sign in to comment.