1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Behat Gherkin. |
5
|
|
|
* (c) Konstantin Kudryashov <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Behat\Gherkin\Keywords; |
12
|
|
|
|
13
|
|
|
use Symfony\Component\Yaml\Yaml; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Cucumber-translations reader. |
17
|
|
|
* |
18
|
|
|
* $keywords = new Behat\Gherkin\Keywords\CucumberKeywords($i18nYmlPath); |
19
|
|
|
* |
20
|
|
|
* @author Konstantin Kudryashov <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
class CucumberKeywords extends ArrayKeywords |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* Initializes holder with yaml string OR file. |
26
|
|
|
* |
27
|
|
|
* @param string $yaml Yaml string |
28
|
|
|
*/ |
29
|
5 |
|
public function __construct($yaml) |
30
|
|
|
{ |
31
|
5 |
|
parent::__construct(Yaml::parse($yaml)); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Returns Feature keywords (splitted by "|"). |
36
|
|
|
* |
37
|
|
|
* @return string |
38
|
|
|
*/ |
39
|
|
|
public function getGivenKeywords() |
40
|
|
|
{ |
41
|
|
|
return $this->prepareStepString(parent::getGivenKeywords()); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Returns When keywords (splitted by "|"). |
46
|
|
|
* |
47
|
|
|
* @return string |
48
|
|
|
*/ |
49
|
|
|
public function getWhenKeywords() |
50
|
|
|
{ |
51
|
|
|
return $this->prepareStepString(parent::getWhenKeywords()); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Returns Then keywords (splitted by "|"). |
56
|
|
|
* |
57
|
|
|
* @return string |
58
|
|
|
*/ |
59
|
|
|
public function getThenKeywords() |
60
|
|
|
{ |
61
|
|
|
return $this->prepareStepString(parent::getThenKeywords()); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Returns And keywords (splitted by "|"). |
66
|
|
|
* |
67
|
|
|
* @return string |
68
|
|
|
*/ |
69
|
|
|
public function getAndKeywords() |
70
|
|
|
{ |
71
|
|
|
return $this->prepareStepString(parent::getAndKeywords()); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Returns But keywords (splitted by "|"). |
76
|
|
|
* |
77
|
|
|
* @return string |
78
|
|
|
*/ |
79
|
|
|
public function getButKeywords() |
80
|
|
|
{ |
81
|
|
|
return $this->prepareStepString(parent::getButKeywords()); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Trim *| from the begining of the list. |
86
|
|
|
* |
87
|
|
|
* @param string $keywordsString Keywords string |
88
|
|
|
* |
89
|
|
|
* @return string |
90
|
|
|
*/ |
91
|
|
|
private function prepareStepString($keywordsString) |
92
|
|
|
{ |
93
|
|
|
if (0 === mb_strpos($keywordsString, '*|', 0, 'UTF-8')) { |
94
|
|
|
$keywordsString = mb_substr($keywordsString, 2, mb_strlen($keywordsString, 'utf8') - 2, 'utf8'); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
return $keywordsString; |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|