Passed
Push — master ( ab5b91...849dc0 )
by Fran
03:17
created

MigrationService   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 25
ccs 0
cts 14
cp 0
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConnectionManager() 0 15 1
1
<?php
2
namespace PSFS\services;
3
4
use Propel\Generator\Manager\MigrationManager;
5
use PSFS\base\types\SimpleService;
6
use PSFS\base\types\traits\Generator\PropelHelperTrait;
7
8
class MigrationService extends SimpleService {
9
    use PropelHelperTrait;
10
11
12
    /**
13
     * @param string $module
14
     * @param string $path
15
     * @return array
16
     * @throws \PSFS\base\exception\GeneratorException
17
     */
18
    public function getConnectionManager(string $module, string $path): array {
19
        $modulePath = str_replace(CORE_DIR . DIRECTORY_SEPARATOR, '', $path . $module);
20
        $generatorConfig = $this->getConfigGenerator($modulePath);
21
22
        $manager = new MigrationManager();
23
        $manager->setGeneratorConfig($generatorConfig);
24
        $manager->setSchemas($this->getSchemas(
25
            $generatorConfig->getSection('paths')['schemaDir'],
26
            $generatorConfig->getSection('generator')['recursive'])
27
        );
28
        $connections = $generatorConfig->getBuildConnections();
29
        $manager->setConnections($connections);
30
        $manager->setMigrationTable($generatorConfig->getConfigProperty('migrations.tableName'));
0 ignored issues
show
Bug introduced by
It seems like $generatorConfig->getCon...'migrations.tableName') can also be of type null; however, parameter $migrationTable of Propel\Generator\Manager...er::setMigrationTable() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

30
        $manager->setMigrationTable(/** @scrutinizer ignore-type */ $generatorConfig->getConfigProperty('migrations.tableName'));
Loading history...
31
        $manager->setWorkingDirectory($generatorConfig->getSection('paths')['migrationDir']);
32
        return [$manager, $generatorConfig];
33
    }
34
}
35