| Conditions | 4 |
| Paths | 5 |
| Total Lines | 24 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 35 | 13 | public function getMigrationDirectory() : string |
|
| 36 | { |
||
| 37 | 13 | $dir = $this->configuration->getMigrationsDirectory(); |
|
| 38 | 13 | $dir = $dir ?? getcwd(); |
|
| 39 | |||
| 40 | 13 | assert($dir !== false, 'Unable to determine current working directory.'); |
|
| 41 | |||
| 42 | 13 | $dir = rtrim($dir, '/'); |
|
| 43 | |||
| 44 | 13 | if (! file_exists($dir)) { |
|
| 45 | 1 | throw DirectoryDoesNotExist::new($dir); |
|
| 46 | } |
||
| 47 | |||
| 48 | 12 | if ($this->configuration->areMigrationsOrganizedByYear()) { |
|
| 49 | 3 | $dir .= $this->appendDir(date('Y')); |
|
| 50 | } |
||
| 51 | |||
| 52 | 12 | if ($this->configuration->areMigrationsOrganizedByYearAndMonth()) { |
|
| 53 | 2 | $dir .= $this->appendDir(date('m')); |
|
| 54 | } |
||
| 55 | |||
| 56 | 12 | $this->createDirIfNotExists($dir); |
|
| 57 | |||
| 58 | 12 | return $dir; |
|
| 59 | } |
||
| 80 |