Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
MigrationFactory
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 create
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Cosray;
6
7use Celema\Container\Container;
8use Celema\Quma\Connection;
9use Celema\Quma\Contract\Migration;
10use Celema\Quma\Contract\MigrationFactory as QumaMigrationFactory;
11use Celema\Quma\Database;
12use Celema\Quma\Environment;
13use Override;
14
15final 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}