GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#32)
by Tomasz
02:18
created

ProcessedShortcode::hasAncestor()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 12
ccs 7
cts 7
cp 1
rs 9.4285
cc 3
eloc 6
nc 3
nop 1
crap 3
1
<?php
2
namespace Thunder\Shortcode\Shortcode;
3
4
use Thunder\Shortcode\Parser\ParserInterface;
5
use Thunder\Shortcode\Processor\ProcessorContext;
6
use Thunder\Shortcode\Processor\ProcessorInterface;
7
8
/**
9
 * @author Tomasz Kowalczyk <[email protected]>
10
 */
11
final class ProcessedShortcode extends AbstractShortcode implements ParsedShortcodeInterface
12
{
13
    /** @var ShortcodeInterface */
14
    private $parent;
15
    private $position;
16
    private $namePosition;
17
    private $text;
18
    private $textContent;
19
    private $offset;
20
    private $shortcodeText;
21
    private $iterationNumber;
22
    private $recursionLevel;
23
    /** @var ProcessorInterface */
24
    private $processor;
25
26 37
    private function __construct()
27
    {
28 37
    }
29
30 37
    public static function createFromContext(ProcessorContext $context)
31
    {
32 37
        $self = new self();
33
34
        // basic properties
35 37
        $self->name = $context->shortcode->getName();
36 37
        $self->parameters = $context->shortcode->getParameters();
37 37
        $self->content = $context->shortcode->getContent();
38 37
        $self->bbCode = $context->shortcode->getBbCode();
39 37
        $self->textContent = $context->textContent;
40
41
        // runtime context
42 37
        $self->parent = $context->parent;
43 37
        $self->position = $context->position;
44 37
        $self->namePosition = $context->namePosition[$self->name];
45 37
        $self->text = $context->text;
46 37
        $self->shortcodeText = $context->shortcodeText;
47
48
        // processor state
49 37
        $self->iterationNumber = $context->iterationNumber;
50 37
        $self->recursionLevel = $context->recursionLevel;
51 37
        $self->processor = $context->processor;
52
53
        // text context
54 37
        $self->offset = $context->offset;
55
56 37
        return $self;
57
    }
58
59 35
    public function withContent($content)
60
    {
61 35
        $self = clone $this;
62 35
        $self->content = $content;
63
64 35
        return $self;
65
    }
66
67 1
    public function hasAncestor($name)
68
    {
69 1
        $self = $this;
70
71 1
        while($self = $self->getParent()) {
72 1
            if($self->getName() === $name) {
73 1
                return true;
74
            }
75 1
        }
76
77 1
        return false;
78
    }
79
80 4
    public function getParent()
81
    {
82 4
        return $this->parent;
83
    }
84
85 2
    public function getTextContent()
86
    {
87 2
        return $this->textContent;
88
    }
89
90 2
    public function getPosition()
91
    {
92 2
        return $this->position;
93
    }
94
95 2
    public function getNamePosition()
96
    {
97 2
        return $this->namePosition;
98
    }
99
100 1
    public function getText()
101
    {
102 1
        return $this->text;
103
    }
104
105 1
    public function getShortcodeText()
106
    {
107 1
        return $this->shortcodeText;
108
    }
109
110 1
    public function getOffset()
111
    {
112 1
        return $this->offset;
113
    }
114
115 1
    public function getIterationNumber()
116
    {
117 1
        return $this->iterationNumber;
118
    }
119
120 1
    public function getRecursionLevel()
121
    {
122 1
        return $this->recursionLevel;
123
    }
124
125 1
    public function getProcessor()
126
    {
127 1
        return $this->processor;
128
    }
129
}
130