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.

ProcessedShortcode::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 25

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 17
CRAP Score 1

Importance

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