Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
6 / 6 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| MigrationFactory | |
100.00% |
6 / 6 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| create | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Cosray; |
| 6 | |
| 7 | use Celema\Container\Container; |
| 8 | use Celema\Quma\Connection; |
| 9 | use Celema\Quma\Contract\Migration; |
| 10 | use Celema\Quma\Contract\MigrationFactory as QumaMigrationFactory; |
| 11 | use Celema\Quma\Database; |
| 12 | use Celema\Quma\Environment; |
| 13 | use Override; |
| 14 | |
| 15 | final class MigrationFactory implements QumaMigrationFactory |
| 16 | { |
| 17 | public function __construct( |
| 18 | protected readonly Container $container, |
| 19 | ) {} |
| 20 | |
| 21 | /** @param class-string<Migration> $class */ |
| 22 | #[Override] |
| 23 | public function create(string $class, Environment $env): Migration |
| 24 | { |
| 25 | $container = $this->container->scope(); |
| 26 | $container->add(Environment::class, $env)->value(); |
| 27 | $container->add(Connection::class, $env->conn)->value(); |
| 28 | $container->add(Database::class, $env->db)->value(); |
| 29 | |
| 30 | return $container->instance($class); |
| 31 | } |
| 32 | } |