Completed
Pull Request — master (#162)
by
unknown
02:07
created

ScenarioNode::getScenarioOutline()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 8
cts 8
cp 1
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
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\Node;
12
13
/**
14
 * Represents Gherkin Scenario.
15
 *
16
 * @author Konstantin Kudryashov <[email protected]>
17
 */
18
class ScenarioNode implements ScenarioInterface
19
{
20
    /**
21
     * @var string
22
     */
23
    private $title;
24
    /**
25
     * @var array
26
     */
27
    private $tags = array();
28
    /**
29
     * @var StepNode[]
30
     */
31
    private $steps = array();
32
    /**
33
     * @var string
34
     */
35
    private $keyword;
36
    /**
37
     * @var integer
38
     */
39
    private $line;
40
41
    /**
42
     * Initializes scenario.
43
     *
44
     * @param null|string $title
45
     * @param array       $tags
46
     * @param StepNode[]  $steps
47
     * @param string      $keyword
48
     * @param integer     $line
49
     */
50 220
    public function __construct($title, array $tags, array $steps, $keyword, $line)
51
    {
52 220
        $this->title = $title;
53 220
        $this->tags = $tags;
54 220
        $this->steps = $steps;
55 220
        $this->keyword = $keyword;
56 220
        $this->line = $line;
57 220
    }
58
59
    /**
60
     * Returns node type string
61
     *
62
     * @return string
63
     */
64
    public function getNodeType()
65
    {
66
        return 'Scenario';
67
    }
68
69
    /**
70
     * Returns scenario title.
71
     *
72
     * @return null|string
73
     */
74 7
    public function getTitle()
75
    {
76 7
        return $this->title;
77
    }
78
79
    /**
80
     * Checks if scenario is tagged with tag.
81
     *
82
     * @param string $tag
83
     *
84
     * @return Boolean
85
     */
86
    public function hasTag($tag)
87
    {
88
        return in_array($tag, $this->getTags());
89
    }
90
91
    /**
92
     * Checks if scenario has tags (both inherited from feature and own).
93
     *
94
     * @return Boolean
95
     */
96 1
    public function hasTags()
97
    {
98 1
        return 0 < count($this->getTags());
99
    }
100
101
    /**
102
     * Returns scenario tags (including inherited from feature).
103
     *
104
     * @return array
105
     */
106 3
    public function getTags()
107
    {
108 3
        return $this->tags;
109
    }
110
111
    /**
112
     * Checks if scenario has steps.
113
     *
114
     * @return Boolean
115
     */
116
    public function hasSteps()
117
    {
118
        return 0 < count($this->steps);
119
    }
120
121
    /**
122
     * Returns scenario steps.
123
     *
124
     * @return StepNode[]
125
     */
126 1
    public function getSteps()
127
    {
128 1
        return $this->steps;
129
    }
130
131
    /**
132
     * Returns scenario keyword.
133
     *
134
     * @return string
135
     */
136
    public function getKeyword()
137
    {
138
        return $this->keyword;
139
    }
140
141
    /**
142
     * Returns scenario declaration line number.
143
     *
144
     * @return integer
145
     */
146 16
    public function getLine()
147
    {
148 16
        return $this->line;
149
    }
150
151 1
    public function getScenarioOutline(ExampleTableNode $example)
152
    {
153 1
        return new OutlineNode(
154 1
            $this->title,
155 1
            $this->tags,
156 1
            $this->steps,
157 1
            $example,
158 1
            'Scenario Outline',
159 1
            $this->line
160
        );
161
    }
162
}
163