MigrationFile::getNameFile()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Luke\Migration\Config;
4
5
use database\migrations;
0 ignored issues
show
Bug introduced by
The type database\migrations was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
7
class MigrationFile
8
{
9
    public function actionMigration()
10
    {
11
        $this->file_exists();
12
        $this->browser_dir();
13
    }
14
15
    private function file_exists()
16
    {
17
        if (!file_exists(CONFIG_PATH)) {
18
            throw new \Exception('Arquivo não existe');
19
        }
20
    }
21
22
    private function browser_dir()
23
    {
24
        $dirs = glob(CONFIG_PATH . "/*");
25
26
        array_map(function ($dir) {
27
            echo "\e[32m" . $this->getNameFile($dir);
28
            $value = include_once($dir);
29
            $value->up();
30
        }, $dirs);
31
    }
32
33
    private function getNameFile($file): string
34
    {
35
        $names = explode('/', $file);
36
37
        return str_replace(".php", "", $names[array_key_last($names)]);
38
    }
39
}
40