SpacingTrait::popSpacer()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Vanderlee\Comprehend\Parser\Structure;
4
5
use Vanderlee\Comprehend\Core\ArgumentsTrait;
6
use Vanderlee\Comprehend\Core\Context;
7
use Vanderlee\Comprehend\Parser\Parser;
8
9
/**
10
 * Classes implementing this can scan.
11
 *
12
 * @author Martijn
13
 */
14
trait SpacingTrait
15
{
16
    use ArgumentsTrait;
17
18
    /**
19
     * Parser used for scanning the text.
20
     *
21
     * @var Parser
22
     */
23
    private $spacer = false;
24
25 198
    private function pushSpacer(Context $context)
26
    {
27 198
        if ($this->spacer !== false) {
0 ignored issues
show
introduced by
The condition $this->spacer !== false is always true.
Loading history...
28 21
            $context->pushSpacer($this->spacer);
29
        }
30 198
    }
31
32 197
    private function popSpacer(Context $context)
33
    {
34 197
        if ($this->spacer !== false) {
0 ignored issues
show
introduced by
The condition $this->spacer !== false is always true.
Loading history...
35 20
            $context->popSpacer();
36
        }
37 197
    }
38
39
    /**
40
     * Set a spacing parser for this parser or disable or enable (if a previous
41
     * spacing parser is enabled) spacing parsing.
42
     *
43
     * @param Parser|bool|null $spacer
44
     *
45
     * @return $this
46
     */
47 7
    public function spacing($spacer = true)
48
    {
49 7
        if ($spacer === true) {
50 1
            $this->spacer = true;
0 ignored issues
show
Documentation Bug introduced by
It seems like true of type true is incompatible with the declared type Vanderlee\Comprehend\Parser\Parser of property $spacer.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
51 7
        } elseif ($spacer === null || $spacer === false) {
0 ignored issues
show
introduced by
The condition $spacer === false is always true.
Loading history...
52 1
            $this->spacer = null;
53
        } else {
54 7
            $this->spacer = self::getArgument($spacer);
55
        }
56
57 7
        return $this;
58
    }
59
}
60