GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

FeatureContext::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
use Behat\Behat\Tester\Exception\PendingException;
4
use Behat\Behat\Context\Context;
5
use Behat\Behat\Context\SnippetAcceptingContext;
6
use Behat\Gherkin\Node\PyStringNode;
7
use Behat\Gherkin\Node\TableNode;
8
use Behat\Behat\Hook\Scope\AfterScenarioScope;
9
10
use Symfony\Component\Finder\Finder;
11
12
/**
13
 * Defines application features from the specific context.
14
 */
15
class FeatureContext implements Context, SnippetAcceptingContext
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...
16
{
17
    private $dir;
18
19
    /**
20
     * Initializes context.
21
     *
22
     * Every scenario gets its own context instance.
23
     * You can also pass arbitrary arguments to the
24
     * context constructor through behat.yml.
25
     */
26
    public function __construct()
27
    {
28
    }
29
30
    /**
31
     * @Given there is :dir directory in root of the application
32
     */
33
    public function thereIsDirectoryInRootOfTheApplication($dir)
34
    {
35
        if (!file_exists($dir)) {
36
            mkdir($dir);
37
        }
38
        $this->dir = $dir;
39
    }
40
41
    /**
42
     * @Given I am in a root directory of application
43
     */
44
    public function iAmInARootDirectoryOfApplication()
45
    {
46
47
    }
48
49
    /**
50
    * @Given I run :command
51
    */
52
    public function iRun($command)
53
    {
54
        exec($command);
55
    }
56
57
    /**
58
     * @Then I see the file witch name contains :fileName
59
     */
60
    public function iSeeTheFileWitchNameContains($fileName)
61
    {
62
        $this->fileName = $fileName;
0 ignored issues
show
Bug introduced by
The property fileName does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
63
        $pattern =  getcwd() . '/' . $this->dir;
64
        if (count((new Finder())->files()->in($pattern)->name('*' . $fileName)) === 0) {
65
            throw new \Exception('File does not exist');
66
        }
67
    }
68
69
    /**
70
     * @Then this file body contains:
71
     */
72
    public function thisFileBodyContains(PyStringNode $string)
73
    {
74
        $pattern =  getcwd() . '/' . $this->dir;
75
        $content = '';
76
        foreach ((new Finder())->files()->in($pattern)->name('*' . $this->fileName) as $file) {
77
            $content = $file->getContents();
78
        }
79
        if (strpos($content, $string->getRaw()) === false) {
80
            throw new \Exception('File contains wrong data');
81
        }
82
    }
83
84
    /**
85
      * @AfterScenario
86
      */
87
     public function deleteMigrations(AfterScenarioScope $scope)
0 ignored issues
show
Unused Code introduced by
The parameter $scope is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
88
     {
89
         $pattern =  getcwd() . '/' . $this->dir . '/*.php';
90
         array_map('unlink', glob($pattern));
91
     }
92
}
93