Completed
Push — revert-211-search-element-in-r... ( d31b08 )
by Albin
03:01
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
use Knp\FriendlyContexts\Utils\Asserter;
8
use Knp\FriendlyContexts\Utils\TextFormater;
9
10
abstract class RawMinkContext extends Context implements MinkAwareContext
11
{
12
    private $mink;
13
14
    private $minkParameters;
15
16
    public function setMink(Mink $mink)
17
    {
18
        $this->mink = $mink;
19
    }
20
21
    public function getMink()
22
    {
23
        return $this->mink;
24
    }
25
26
    public function setMinkParameters(array $parameters)
27
    {
28
        $this->minkParameters = $parameters;
29
    }
30
31
    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...
32
    {
33
       if (!isset($this->minkParameters[$offset])) {
34
            throw new \Exception(sprintf(
35
                'Invalid mink parameter "%s".',
36
                $offset
37
            ));
38
        }
39
40
        return $this->minkParameters[$offset];
41
    }
42
43
    public function getSession($name = null)
44
    {
45
        return $this->getMink()->getSession($name);
46
    }
47
48
    public function assertSession($name = null)
49
    {
50
        return $this->getMink()->assertSession($name);
51
    }
52
53
    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...
54
    {
55
        $startUrl = rtrim($this->getMinkParameter('base_url'), '/') . '/';
56
57
        return 0 !== strpos($path, 'http') ? $startUrl . ltrim($path, '/') : $path;
58
    }
59
}
60