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
Push — master ( 3a8d53...0dbe84 )
by Tomasz
02:24
created

ProcessedShortcode   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 119
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 17
Bugs 6 Features 9
Metric Value
wmc 16
c 17
b 6
f 9
lcom 1
cbo 3
dl 0
loc 119
ccs 50
cts 50
cp 1
rs 10

14 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
B createFromContext() 0 28 1
A withContent() 0 7 1
A hasAncestor() 0 12 3
A getParent() 0 4 1
A getTextContent() 0 4 1
A getPosition() 0 4 1
A getNamePosition() 0 4 1
A getText() 0 4 1
A getShortcodeText() 0 4 1
A getOffset() 0 4 1
A getIterationNumber() 0 4 1
A getRecursionLevel() 0 4 1
A getProcessor() 0 4 1
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