Completed
Push — master ( a8cd91...de13b2 )
by Alfred
02:05
created

BaseGherkinToDusk   A

Complexity

Total Complexity 26

Size/Duplication

Total Lines 197
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 1

Test Coverage

Coverage 52.86%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 26
c 1
b 0
f 0
lcom 3
cbo 1
dl 0
loc 197
ccs 37
cts 70
cp 0.5286
rs 10

16 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getFileName() 0 4 1
A setFileName() 0 5 1
A getFilesystem() 0 4 1
A setFilesystem() 0 9 2
A getFileNameAndPath() 0 7 2
A setFileNameAndPath() 0 11 2
A getSourcePath() 0 7 2
A setSourcePath() 0 8 2
A getDestinationFolderRoot() 0 7 2
A setDestinationFolderRoot() 0 8 2
A getContext() 0 4 1
A setContext() 0 5 1
A getPathToFeature() 0 4 1
A setPathToFeature() 0 5 1
A getContextFolder() 0 12 4
1
<?php
2
3
4
namespace GD;
5
6
use Behat\Gherkin\Parser;
7
use Illuminate\Filesystem\Filesystem;
8
9
class BaseGherkinToDusk
10
{
11
12
    protected $features_folder = '/tests/features/';
13
14
    protected $source_path = null;
15
16
    protected $context = "domain";
17
18
    protected $path_to_feature = null;
19
20
21
22
    /**
23
     * Conventions
24
     * file should be in tests/features for now
25
     * @var null
26
     */
27
    protected $file_name = null;
28
29
    protected $file_name_and_path = null;
30
31
    protected $destination_folder_root = null;
32
33
    /**
34
     * @var Filesystem
35
     */
36
    protected $filesystem;
37
38
    /**
39
     * @var Parser
40
     */
41
    protected $parser;
42
43 33
    public function __construct(Filesystem $filesystem, Parser $parser = null)
44
    {
45 33
        $this->filesystem = $filesystem;
46 33
        $this->parser = $parser;
47 33
    }
48
49
50
    public function getFileName()
51
    {
52
        return $this->file_name;
53
    }
54
55
    public function setFileName($file_name)
56
    {
57
        $this->file_name = $file_name;
58
        return $this;
59
    }
60
61
    /**
62
     * @return Filesystem
63
     */
64 21
    public function getFilesystem()
65
    {
66 21
        return $this->filesystem;
67
    }
68
69
    /**
70
     * @param null $filesystem
71
     * @return $this
72
     */
73
    public function setFilesystem($filesystem = null)
74
    {
75
        if (!$filesystem) {
76
            $filesystem = new Filesystem();
77
        }
78
79
        $this->filesystem = $filesystem;
80
        return $this;
81
    }
82
83
    /**
84
     * @return null
85
     */
86
    public function getFileNameAndPath()
87
    {
88
        if ($this->file_name_and_path == null) {
89
            $this->setFileNameAndPath();
90
        }
91
        return $this->file_name_and_path;
92
    }
93
94
    /**
95
     * @param null $file_name_and_path
96
     */
97
    public function setFileNameAndPath($file_name_and_path = null)
98
    {
99
        if (!$file_name_and_path) {
100
            $file_name_and_path =
101
                $this->getSourcePath() . $this->features_folder . $this->getFileName();
102
        }
103
104
        $this->file_name_and_path = $file_name_and_path;
105
106
        return $this;
107
    }
108
109
110
111
    /**
112
     * @return null
113
     */
114 33
    public function getSourcePath()
115
    {
116 33
        if ($this->source_path == null) {
117 33
            $this->setSourcePath();
118 22
        }
119 33
        return $this->source_path;
120
    }
121
122
    /**
123
     * @param null $source_path
124
     */
125 33
    public function setSourcePath($source_path = null)
126
    {
127 33
        if (!$source_path) {
128 33
            $source_path = getcwd() . '/tests/features/';
129 22
        }
130
131 33
        $this->source_path = $source_path;
132 33
    }
133
134
    /**
135
     * @return null
136
     */
137 33
    public function getDestinationFolderRoot()
138
    {
139 33
        if (!$this->destination_folder_root) {
140 33
            $this->setDestinationFolderRoot();
141 22
        }
142 33
        return $this->destination_folder_root;
143
    }
144
145
    /**
146
     * @param null $destination_folder_root
147
     */
148 33
    public function setDestinationFolderRoot($destination_folder_root = null)
149
    {
150 33
        if (!$destination_folder_root) {
151 33
            $destination_folder_root = getcwd() . sprintf('/tests/%s', $this->getContextFolder());
152 22
        }
153
154 33
        $this->destination_folder_root = $destination_folder_root;
155 33
    }
156
157
    /**
158
     * @return string
159
     */
160
    public function getContext()
161
    {
162
        return $this->context;
163
    }
164
165
    /**
166
     * @param string $context
167
     * @return $this
168
     */
169
    public function setContext($context)
170
    {
171
        $this->context = $context;
172
        return $this;
173
    }
174
175
    /**
176
     * @return null
177
     */
178 21
    public function getPathToFeature()
179
    {
180 21
        return $this->path_to_feature;
181
    }
182
183
    /**
184
     * @param null $path_to_feature
185
     * @return $this
186
     */
187 21
    public function setPathToFeature($path_to_feature)
188
    {
189 21
        $this->path_to_feature = $path_to_feature;
190 21
        return $this;
191
    }
192
193 33
    private function getContextFolder()
194
    {
195 33
        switch ($this->context) {
196 33
            case "domain":
197 33
                return "Unit";
198
            case "ui":
199
            case "browser":
200
                return "Browser";
201
            default:
202
                return "Unit";
203
        }
204
    }
205
}
206