Completed
Push — master ( a18f4a...b0c220 )
by Greg
01:31
created

SiteAliasCommands   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 4
dl 0
loc 30
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A list() 0 18 2
1
<?php
2
3
namespace Consolidation\SiteAlias\Cli;
4
5
use Consolidation\SiteAlias\SiteAliasFileLoader;
6
use Consolidation\SiteAlias\Util\YamlDataFileLoader;
7
8
class SiteAliasCommands extends \Robo\Tasks
9
{
10
    protected $aliasLoader;
11
12
    /**
13
     * List available site aliases
14
     *
15
     * @command site:list
16
     * @format yaml
17
     * @return array
18
     */
19
    public function list($dir)
20
    {
21
        $this->aliasLoader = new SiteAliasFileLoader();
22
        $ymlLoader = new YamlDataFileLoader();
23
        $this->aliasLoader->addLoader('yml', $ymlLoader);
24
25
        $this->io()->note("loading from $dir");
26
27
        $this->aliasLoader->addSearchLocation($dir);
28
29
        $all = $this->aliasLoader->loadAll();
30
31
        if (empty($all)) {
32
            throw new \Exception("No aliases found");
33
        }
34
35
        return $all;
36
    }
37
}
38