Completed
Push — master ( 92b26f...232625 )
by Albin
06:25 queued 03:33
created

RawMinkContext::elementAction()   B

Complexity

Conditions 5
Paths 16

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 15
rs 8.8571
cc 5
eloc 8
nc 16
nop 5
1
<?php
2
3
namespace Knp\FriendlyContexts\Context;
4
5
use Behat\Mink\Mink;
6
use Behat\MinkExtension\Context\MinkAwareContext;
7
8
abstract class RawMinkContext extends Context implements MinkAwareContext
9
{
10
    private $mink;
11
12
    private $minkParameters;
13
14
    public function setMink(Mink $mink)
15
    {
16
        $this->mink = $mink;
17
    }
18
19
    public function getMink()
20
    {
21
        return $this->mink;
22
    }
23
24
    public function setMinkParameters(array $parameters)
25
    {
26
        $this->minkParameters = $parameters;
27
    }
28
29
    public function getMinkParameter($offset)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
30
    {
31
       if (!isset($this->minkParameters[$offset])) {
32
            throw new \Exception(sprintf(
33
                'Invalid mink parameter "%s".',
34
                $offset
35
            ));
36
        }
37
38
        return $this->minkParameters[$offset];
39
    }
40
41
    public function getSession($name = null)
42
    {
43
        return $this->getMink()->getSession($name);
44
    }
45
46
    public function assertSession($name = null)
47
    {
48
        return $this->getMink()->assertSession($name);
49
    }
50
51
    public function locatePath($path)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
52
    {
53
        $startUrl = rtrim($this->getMinkParameter('base_url'), '/') . '/';
54
55
        return 0 !== strpos($path, 'http') ? $startUrl . ltrim($path, '/') : $path;
56
    }
57
}
58