| Total Complexity | 9 |
| Total Lines | 57 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | trait HasPathsTrait |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @param $path |
||
| 15 | */ |
||
| 16 | 1 | public function addBasePath($path) |
|
| 17 | { |
||
| 18 | 1 | $this->setPath($path . DIRECTORY_SEPARATOR . 'migrations', 'migrations'); |
|
| 19 | 1 | $this->setPath($path . DIRECTORY_SEPARATOR . 'seeds', 'seeds'); |
|
| 20 | 1 | } |
|
| 21 | |||
| 22 | /** |
||
| 23 | * @param string $type |
||
| 24 | */ |
||
| 25 | 2 | public function initPaths($type = 'migrations') |
|
| 26 | { |
||
| 27 | 2 | $paths = []; |
|
| 28 | 2 | if (in_array($type, ['migrations', 'seeds'])) { |
|
| 29 | 2 | $test = Helper::normalizePath(Helper::getBasePath(), 'database', $type); |
|
| 30 | 2 | if (is_dir($test)) { |
|
| 31 | 2 | $paths[] = $test; |
|
| 32 | } |
||
| 33 | } |
||
| 34 | 2 | $this->setPath($paths, $type); |
|
| 35 | 2 | } |
|
| 36 | |||
| 37 | /** |
||
| 38 | * @param $type |
||
| 39 | * @param $path |
||
| 40 | */ |
||
| 41 | 3 | public function setPath($path, $type = 'migrations') |
|
| 42 | { |
||
| 43 | 3 | $path = is_array($path) ? $path : [$path]; |
|
| 44 | 3 | $this->params['paths'][$type] = $path; |
|
|
|
|||
| 45 | 3 | } |
|
| 46 | |||
| 47 | /** |
||
| 48 | * Register a custom migration path. |
||
| 49 | * |
||
| 50 | * @param string $path |
||
| 51 | * @param string $type |
||
| 52 | * @return void |
||
| 53 | */ |
||
| 54 | 1 | public function path($path, $type = 'migrations') |
|
| 55 | { |
||
| 56 | 1 | $existing = $this->params['paths'][$type]; |
|
| 57 | 1 | $existing = is_array($existing) ? $existing : [$existing]; |
|
| 58 | 1 | $this->params['paths'][$type] = array_unique(array_merge($existing, [$path])); |
|
| 59 | 1 | } |
|
| 60 | |||
| 61 | /** |
||
| 62 | * @param string $type |
||
| 63 | * @return mixed |
||
| 64 | */ |
||
| 65 | 2 | public function paths($type = 'migrations') |
|
| 68 | } |
||
| 69 | } |