PromptContextTrait::iGetPrompted()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
/**
3
 * This file is part of the phpspec-behavior package.
4
 * (c) 2017 Timo Michna <timomichna/yahoo.de>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace features\Behavior\Context\Console;
11
12
use Prophecy\Argument;
13
14
/**
15
 * Class features\Behavior\Context\Console\PromptContextTrait */
16
trait PromptContextTrait
17
{
18
    /**
19
     * @Given I get prompted and answer yes
20
     */
21
    public function iGetPromptedAndAnswerYes()
22
    {
23
        $this->getWriterProphecy()
0 ignored issues
show
Bug introduced by
It seems like getWriterProphecy() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
24
            ->confirm(
25
                Argument::type('string'),
26
                Argument::any(),
27
                Argument::any()
28
            )->willReturn(
29
                true
30
            );
31
    }
32
33
    /**
34
     * @Given I get prompted and answer no
35
     */
36
    public function iGetPromptedAndAnswerNo()
37
    {
38
        $this->getWriterProphecy()
0 ignored issues
show
Bug introduced by
It seems like getWriterProphecy() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
39
            ->confirm(
40
                Argument::type('string'),
41
                Argument::any(),
42
                Argument::any()
43
            )->willReturn(
44
                false
45
            );
46
    }
47
48
    /**
49
     * @Then I get prompted
50
     */
51
    public function iGetPrompted()
52
    {
53
        $this->getWriterProphecy()
0 ignored issues
show
Bug introduced by
It seems like getWriterProphecy() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
54
            ->confirm(
55
                Argument::type('string'),
56
                Argument::any(),
57
                Argument::any()
58
            )->shouldHaveBeenCalled();
59
    }
60
61
    /**
62
     * @Then I do not get prompted
63
     */
64
    public function iDoNotGetPrompted()
65
    {
66
        $this->getWriterProphecy()
0 ignored issues
show
Bug introduced by
It seems like getWriterProphecy() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
67
            ->confirm(
68
                Argument::type('string'),
69
                Argument::any(),
70
                Argument::any()
71
            )->shouldNotHaveBeenCalled();
72
    }
73
}
74
75