| Total Complexity | 13 |
| Total Lines | 56 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | trait Taggable |
||
| 8 | { |
||
| 9 | protected $tags = []; |
||
| 10 | protected $tagLoaded = false; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @BeforeScenario |
||
| 14 | */ |
||
| 15 | public function storeTags($event) |
||
| 16 | { |
||
| 17 | if (false === $this->tagLoaded) { |
||
| 18 | if ($event instanceof ScenarioScope) { |
||
| 19 | if (null !== $feature = $event->getFeature()) { |
||
| 20 | $this->tags = array_merge($this->tags, $feature->getTags()); |
||
| 21 | } |
||
| 22 | if (null !== $scenario = $event->getScenario()) { |
||
| 23 | $this->tags = array_merge($this->tags, $scenario->getTags()); |
||
| 24 | } |
||
| 25 | } |
||
| 26 | $this->tagLoaded = true; |
||
| 27 | } |
||
| 28 | } |
||
| 29 | |||
| 30 | protected function hasTag($name) |
||
| 31 | { |
||
| 32 | return in_array($name, $this->tags); |
||
| 33 | } |
||
| 34 | |||
| 35 | protected function hasTags(array $names) |
||
| 36 | { |
||
| 37 | foreach ($names as $name) { |
||
| 38 | if (!(0 === strpos($name, '~')) !== $this->hasTag(str_replace('~', '', $name))) { |
||
| 39 | return false; |
||
| 40 | } |
||
| 41 | } |
||
| 42 | |||
| 43 | return true; |
||
| 44 | } |
||
| 45 | |||
| 46 | protected function getTagContent($name) |
||
| 58 | } |
||
| 59 | |||
| 60 | protected function getTags() |
||
| 63 | } |
||
| 64 | } |
||
| 65 |