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

SetupMigrations   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 25
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A bootstrap() 0 22 1
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