VarLoader   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 37
c 0
b 0
f 0
wmc 1
lcom 0
cbo 6
rs 10
ccs 9
cts 9
cp 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A collect() 0 14 1
1
<?php
2
3
declare(strict_types = 1);
4
5
/*
6
 * This file is part of the skeleton package.
7
 *
8
 * (c) Gennady Knyazkin <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Gennadyx\Skeleton;
15
16
use Gennadyx\Skeleton\VarSource\BasedOnVars;
17
use Gennadyx\Skeleton\VarSource\Env;
18
use Gennadyx\Skeleton\VarSource\Filesystem;
19
use Gennadyx\Skeleton\VarSource\GitConfig;
20
use MF\Collection\Immutable\Generic\Map;
21
use MF\Validator\TypeValidator;
22
23
/**
24
 * Class VarLoader
25
 *
26
 * @author Gennady Knyazkin <[email protected]>
27
 */
28
class VarLoader
29
{
30
    /**
31
     * Required variables
32
     */
33
    const REQUIRED_VARIABLES = [
34
        'root',
35
        'skeleton',
36
        'vendor',
37
        'name',
38
        'description',
39
        'homepage',
40
        'author_name',
41
        'author_email',
42
        'author_homepage',
43
        'namespace',
44
        'tests_namespace',
45
    ];
46
47
    /**
48
     * @return Map
49
     */
50 2
    public static function collect(): Map
51
    {
52 2
        $source = new Env();
53
        $source
54 2
            ->setNext(new Filesystem())
55 2
            ->setNext(new GitConfig())
56 2
            ->setNext(new BasedOnVars());
57
58 2
        return Map::createGenericFromArray(
59 2
            TypeValidator::TYPE_STRING,
60 2
            TypeValidator::TYPE_STRING,
61 2
            $source->collect(self::REQUIRED_VARIABLES)
62
        );
63
    }
64
}
65