Completed
Push — master ( e553d9...156fb9 )
by Jonathan
41:51
created

TagTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 4
dl 0
loc 28
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getTags() 0 6 1
A hasTag() 0 4 1
1
<?php
2
3
namespace Drupal\DrupalExtension;
4
5
/**
6
 * Helper methods to check the tags that are present on a feature or scenario.
7
 */
8
trait TagTrait
9
{
10
    use FeatureTrait, ScenarioTrait;
11
12
    /**
13
     * Returns all tags for the current scenario and feature.
14
     *
15
     * @return string[]
16
     */
17
    protected function getTags()
18
    {
19
        $featureTags = $this->getFeature()->getTags();
20
        $scenarioTags = $this->getScenario()->getTags();
21
        return array_unique(array_merge($featureTags, $scenarioTags));
22
    }
23
24
    /**
25
     * Checks whether the current scenario or feature has the given tag.
26
     *
27
     * @param string $tag
28
     *
29
     * @return bool
30
     */
31
    protected function hasTag($tag)
32
    {
33
        return in_array($tag, $this->getTags());
34
    }
35
}
36