Passed
Push — master ( 634a3a...c6537c )
by Jefersson
49s
created

ComposedFormatter::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
ccs 0
cts 6
cp 0
rs 9.4285
cc 1
eloc 9
nc 1
nop 4
crap 2
1
<?php
2
/*
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the MIT license.
17
 */
18
19
namespace KawaiiGherkin\Formatter;
20
21
/**
22
 * @author Jefersson Nathan <[email protected]>
23
 */
24
final class ComposedFormatter
25
{
26
    /**
27
     * @var AbstractFormatter
28
     */
29
    private $featureDescription;
30
31
    /**
32
     * @var AbstractFormatter
33
     */
34
    private $background;
35
36
    /**
37
     * @var AbstractFormatter
38
     */
39
    private $scenario;
40
41
    /**
42
     * @var AbstractFormatter
43
     */
44
    private $tags;
45
46
    /**
47
     * @param AbstractFormatter $featureDescription
48
     * @param AbstractFormatter $background
49
     * @param AbstractFormatter $scenario
50
     * @param AbstractFormatter $tags
51
     */
52
    public function __construct(
53
        AbstractFormatter $featureDescription,
54
        AbstractFormatter $background,
55
        AbstractFormatter $scenario,
56
        AbstractFormatter $tags
57
    ) {
58
        $this->featureDescription = $featureDescription;
59
        $this->background         = $background;
60
        $this->scenario           = $scenario;
61
        $this->tags               = $tags;
62
    }
63
64
    public function __invoke($feature)
0 ignored issues
show
Complexity introduced by
This operation has 625 execution paths which exceeds the configured maximum of 200.

A high number of execution paths generally suggests many nested conditional statements and make the code less readible. This can usually be fixed by splitting the method into several smaller methods.

You can also find more information in the “Code” section of your repository.

Loading history...
65
    {
66
        $formatted  = $feature->getLanguage() && $feature->getLanguage() !== 'en' ? '# language: ' . trim($feature->getLanguage()) . "\n" : '';
67
        $formatted .= $feature->hasTags() ? $this->tags->format($feature->getTags()) . "\n" : '';
68
        $formatted .= $this->featureDescription->format($feature) . "\n\n";
69
        $formatted .= $feature->hasBackground() ? $this->background->format($feature->getBackground()) . "\n" : '';
70
        $formatted .= $feature->hasScenarios() ? $this->scenario->format($feature->getScenarios()) : '';
71
72
        return $formatted;
73
    }
74
}
75