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

Parameter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 31
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setParameter() 0 4 1
A getXpath() 0 11 2
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