AbstractGlobalConfiguration::getSupportingDirs()   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
nc 1
dl 0
loc 4
c 0
b 0
f 0
cc 1
eloc 2
nop 0
rs 10
1
<?php
2
3
4
namespace SmartWeb\ModuleTesting\Codeception;
5
6
use Illuminate\Support\Arr;
7
use Illuminate\Support\Str;
8
use function collect;
9
10
11
/**
12
 * Class AbstractGlobalConfiguration
13
 *
14
 * @package SmartWeb\ModuleTesting\Codeception
15
 */
16
class AbstractGlobalConfiguration extends AbstractConfiguration implements GlobalConfigurationInterface
17
{
18
    
19
    /**
20
     * @var string[][]
21
     */
22
    protected static $supportingDirs = [];
23
    
24
    /**
25
     * Get an attribute from the container using "dot" notation.
26
     *
27
     * @param string $key
28
     * @param mixed  $default
29
     *
30
     * @return mixed
31
     */
32
    public function get(string $key, $default = null)
33
    {
34
        return Arr::get($this->attributes, $key, $default);
35
    }
36
    
37
    /**
38
     * @return array
39
     */
40
    public function toArray() : array
41
    {
42
        return $this->attributes;
43
    }
44
    
45
    /**
46
     * @return string[]
47
     */
48
    final public function getPaths()
49
    {
50
        return $this[self::PATHS];
51
    }
52
    
53
    /**
54
     * @return string[]
55
     */
56
    final public function getSupportingDirs()
57
    {
58
        return $this->resolveSupportingDirs();
59
    }
60
    
61
    /**
62
     * @return string[]
63
     */
64
    final protected function resolveSupportingDirs()
65
    {
66
        return ['_data', '_support', '_output', '_envs'];
67
    }
68
    
69
    /**
70
     * @param string $filter
71
     *
72
     * @return array
73
     */
74
    protected function filterPaths(string $filter) : array
75
    {
76
        return collect($this->getPaths())
77
            ->filter(
78
                function (string $dir) use ($filter)
79
                {
80
                    return Str::startsWith($dir, $filter);
81
                }
82
            )
83
            ->all();
84
    }
85
    
86
    /**
87
     * @return string
88
     */
89
    final public function getTestsDir() : string
90
    {
91
        return $this[self::TESTS_DIR];
92
    }
93
    
94
    /**
95
     * @return string
96
     */
97
    final public function getDataDir() : string
98
    {
99
        return $this[self::DATA_DIR];
100
    }
101
    
102
    /**
103
     * @return string
104
     */
105
    final public function getOutputDir() : string
106
    {
107
        return $this[self::DATA_DIR];
108
    }
109
    
110
    /**
111
     * @return string
112
     */
113
    final public function getSupportDir() : string
114
    {
115
        return $this[self::DATA_DIR];
116
    }
117
    
118
    /**
119
     * @return string
120
     */
121
    final public function getEnvironmentsDir() : string
122
    {
123
        return $this[self::DATA_DIR];
124
    }
125
    
126
    /**
127
     * @return string
128
     */
129
    public function getNamespace() : string
130
    {
131
        return $this[self::NAMESPACE];
132
    }
133
    
134
}
135