Skip to content

Commit

Permalink
Make container factory static
Browse files Browse the repository at this point in the history
Remove route test trait
  • Loading branch information
odan committed Sep 1, 2022
1 parent e087fcb commit 0342485
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 37 deletions.
2 changes: 1 addition & 1 deletion bin/console.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}

/** @var ContainerInterface $container */
$container = (new ContainerFactory())->createInstance();
$container = ContainerFactory::createInstance();

try {
/** @var Application $application */
Expand Down
2 changes: 1 addition & 1 deletion config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
require_once __DIR__ . '/../vendor/autoload.php';

// Build DI Container instance
$container = (new ContainerFactory())->createInstance();
$container = ContainerFactory::createInstance();

// Create App instance
return $container->get(App::class);
7 changes: 2 additions & 5 deletions src/Factory/ContainerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,14 @@
use DI\ContainerBuilder;
use Psr\Container\ContainerInterface;

/**
* Container Factory.
*/
final class ContainerFactory
{
/**
* Get container.
* Create a new container instance.
*
* @return ContainerInterface|Container The container
*/
public function createInstance(): ContainerInterface
public static function createInstance(): ContainerInterface
{
$containerBuilder = new ContainerBuilder();

Expand Down
3 changes: 1 addition & 2 deletions tests/Traits/AppTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ trait AppTestTrait
use HttpJsonTestTrait;
use LoggerTestTrait;
use MockTestTrait;
use RouteTestTrait;

protected App $app;

Expand All @@ -32,7 +31,7 @@ trait AppTestTrait
*/
protected function setUp(): void
{
$container = (new ContainerFactory())->createInstance();
$container = ContainerFactory::createInstance();
$this->app = $container->get(App::class);

$this->setUpContainer($container);
Expand Down
28 changes: 0 additions & 28 deletions tests/Traits/RouteTestTrait.php

This file was deleted.

0 comments on commit 0342485

Please sign in to comment.