LocalProject::getComposeConfigPath()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Dock\Cli\IO;
4
5
use Dock\Docker\Compose\Project;
6
7
class LocalProject implements Project
8
{
9
    public function getProjectBasePath()
10
    {
11
        $baseDir = getcwd();
12
13
        do {
14
            if (is_file($baseDir.self::CONFIG_FILE)) {
15
                return $baseDir;
16
            }
17
            $baseDir = dirname($baseDir);
18
        } while ($baseDir !== '/');
19
20
        throw new \Exception('Did not find `docker-compose.yml` in any parent directories.');
21
    }
22
23
    public function getComposeConfigPath()
24
    {
25
        return $this->getProjectBasePath().self::CONFIG_FILE;
26
    }
27
28
    public function getCurrentRelativePath()
29
    {
30
        return substr(getcwd(), strlen($this->getProjectBasePath()) + 1);
31
    }
32
}
33