Completed
Pull Request — develop (#27)
by Carlo
03:15
created

Parameter::setParameter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
namespace Magefix\Behat\Page\Element;
3
4
use SensioLabs\Behat\PageObjectExtension\PageObject\Element;
5
6
/**
7
 * Class Parameter
8
 * @package Magefix\Behat\Page\Element
9
 * @author  Carlo Tasca <[email protected]>
10
 */
11
abstract class Parameter extends Element implements Parameterable
12
{
13
    /**
14
     * @var string
15
     */
16
    private $parameter = '';
17
18
    /**
19
     * @param $parameter
20
     */
21
    public function setParameter($parameter)
22
    {
23
        $this->parameter = $parameter;
24
    }
25
26
    /**
27
     * @return string
28
     * @throws \Exception
29
     */
30
    public function getXpath()
31
    {
32
        if (empty($this->parameter)) {
33
            throw new \Exception("Parameter not set for element Xpath");
34
        }
35
36
        $realXPath = str_replace('{parameter}', $this->parameter, $this->selector['xpath']);
37
        $this->selector = ['xpath' => $realXPath];
38
39
        return $realXPath;
40
    }
41
}
42