Completed
Push — feature/database-migrations ( b550b6 )
by Avtandil
02:27
created

SetupMigrations::bootstrap()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 22
ccs 0
cts 13
cp 0
crap 2
rs 9.568
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Longman\TelegramBot\Bootstrap;
5
6
use Illuminate\Database\Migrations\DatabaseMigrationRepository;
7
use Illuminate\Database\Migrations\MigrationCreator;
8
use Illuminate\Database\Migrations\Migrator;
9
use Illuminate\Filesystem\Filesystem;
10
use Longman\TelegramBot\Application;
11
12
use function env;
13
14
class SetupMigrations
15
{
16
    public function bootstrap(Application $app)
17
    {
18
        $app->singleton('files', function (Application $app) {
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
19
            return new Filesystem();
20
        });
21
22
        $app->singleton('migration.repository', function (Application $app) {
23
            $table = env('TG_DB_MIGRATIONS_TABLE', 'migrations');
24
25
            return new DatabaseMigrationRepository($app['db.resolver'], $table);
26
        });
27
28
        $app->singleton('migrator', function (Application $app) {
29
            $repository = $app['migration.repository'];
30
31
            return new Migrator($repository, $app['db.resolver'], $app['files']);
32
        });
33
34
        $app->singleton('migration.creator', function (Application $app) {
35
            return new MigrationCreator($app['files']);
36
        });
37
    }
38
}
39