Completed
Pull Request — master (#252)
by Oliver
12:09
created

FeatureContext::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 0
1
<?php
2
3
use Behat\Behat\Context\Context;
4
use Symfony\Component\Process\PhpExecutableFinder;
5
use Symfony\Component\Process\Process;
6
7
class FeatureContext implements Context
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
8
{
9
    /**
10
     * @var string
11
     */
12
    private $workingDir;
13
14
    /**
15
     * @var string
16
     */
17
    private $phpBin;
18
19
    /**
20
     * @var Process
21
     */
22
    private $process;
23
24
    public function __construct()
25
    {
26
        $phpFinder = new PhpExecutableFinder();
27
        if (false === $php = $phpFinder->find()) {
28
            throw new \RuntimeException('Unable to find the PHP executable. The testsuite cannot run.');
29
        }
30
31
        $this->phpBin = $php;
32
    }
33
34
    /**
35
     * Prepares test folders in the temporary directory.
36
     *
37
     * @BeforeScenario
38
     */
39
    public function prepareTestFolders()
40
    {
41
        $dir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'behat' . DIRECTORY_SEPARATOR . md5(microtime() . rand(0, 10000));
42
43
        mkdir($dir . '/features/bootstrap', 0777, true);
44
45
        $this->workingDir = $dir;
46
        $this->process = new Process(null);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
47
        $this->process->setTimeout(20);
48
    }
49
}
50