Completed
Push — master ( 01b890...8110dc )
by Robbie
01:11
created

SilverStripeLoader   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 33
ccs 10
cts 10
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getTasks() 0 15 2
A getCommandFactory() 0 4 1
1
<?php
2
3
namespace SilverLeague\Console\Framework\Loader;
4
5
use SilverLeague\Console\Command\Factory;
6
use SilverLeague\Console\Framework\ConsoleBase;
7
use SilverStripe\Core\ClassInfo;
8
use SilverStripe\Core\Injector\Injector;
9
10
/**
11
 * The class responsible for loading/instantiating SilverStripe and accessing its class hierarchy, etc
12
 *
13
 * @package silverstripe-console
14
 * @author  Robbie Averill <[email protected]>
15
 */
16
class SilverStripeLoader extends ConsoleBase
17
{
18
    /**
19
     * Return a set of Tasks from SilverStripe
20
     *
21
     * @return array
22
     */
23 1
    public function getTasks()
24
    {
25 1
        $commands = [];
26 1
        $tasks = ClassInfo::subclassesFor('SilverStripe\\Dev\\BuildTask');
27
28
        // Remove the BuildTask itself
29 1
        array_shift($tasks);
30
31 1
        foreach ($tasks as $taskClass) {
32 1
            $task = Injector::inst()->get($taskClass);
33 1
            $commands[] = $this->getCommandFactory()->getCommandFromTask($task);
34
        }
35
36 1
        return $commands;
37
    }
38
39
    /**
40
     * Get a new command factory instance to generate the console Command
41
     *
42
     * @return Factory
43
     */
44 2
    public function getCommandFactory()
45
    {
46 2
        return new Factory($this->getApplication());
47
    }
48
}
49