CursorState   A
last analyzed

Coupling/Cohesion

Components 1
Dependencies 0

Complexity

Total Complexity 10

Size/Duplication

Total Lines 140
Duplicated Lines 0 %

Test Coverage

Coverage 89.66%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 10
c 2
b 0
f 0
lcom 1
cbo 0
dl 0
loc 140
ccs 26
cts 29
cp 0.8966
rs 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A getCurrentPosition() 0 4 1
A getLength() 0 4 1
A getLine() 0 4 1
A getPreviousPosition() 0 4 1
A __construct() 0 11 1
A getNextNonSpaceCache() 0 4 1
A getIndent() 0 4 1
A getColumn() 0 4 1
A getPartiallyConsumedTab() 0 4 1
A getFirstNonSpaceCache() 0 6 1
1
<?php
2
3
/*
4
 * This file is part of the league/commonmark package.
5
 *
6
 * (c) Colin O'Dell <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace League\CommonMark;
13
14
class CursorState
15
{
16
    /**
17
     * @var string
18
     */
19
    private $line;
20
21
    /**
22
     * @var int
23
     */
24
    private $length;
25
26
    /**
27
     * @var int
28
     */
29
    private $currentPosition;
30
31
    /**
32
     * @var int
33
     */
34
    private $previousPosition;
35
36
    /**
37
     * @var int|null
38
     */
39
    private $nextNonSpaceCache;
40
41
    /**
42
     * @var int
43
     */
44
    private $indent;
45
46
    /**
47
     * @var int
48
     */
49
    private $column;
50
51
    /**
52
     * @var bool
53
     */
54
    private $partiallyConsumedTab;
55
56
    /**
57
     * @param string   $line
58
     * @param int      $length
59
     * @param int      $currentPosition
60
     * @param int      $previousPosition
61
     * @param int|null $nextNonSpaceCache
62
     * @param int      $indent
63
     * @param int      $column
64
     * @param bool     $partiallyConsumedTab
65
     */
66 1011
    public function __construct($line, $length, $currentPosition, $previousPosition, $nextNonSpaceCache, $indent, $column, $partiallyConsumedTab)
67
    {
68 1011
        $this->line = $line;
69 1011
        $this->length = $length;
70 1011
        $this->currentPosition = $currentPosition;
71 1011
        $this->previousPosition = $previousPosition;
72 1011
        $this->nextNonSpaceCache = $nextNonSpaceCache;
73 1011
        $this->indent = $indent;
74 1011
        $this->column = $column;
75 1011
        $this->partiallyConsumedTab = $partiallyConsumedTab;
76 1011
    }
77
78
    /**
79
     * @return int
80
     */
81 855
    public function getCurrentPosition()
82
    {
83 855
        return $this->currentPosition;
84
    }
85
86
    /**
87
     * @return int
88
     */
89 795
    public function getLength()
90
    {
91 795
        return $this->length;
92
    }
93
94
    /**
95
     * @return string
96
     */
97 795
    public function getLine()
98
    {
99 795
        return $this->line;
100
    }
101
102
    /**
103
     * @return int
104
     */
105 795
    public function getPreviousPosition()
106
    {
107 795
        return $this->previousPosition;
108
    }
109
110
    /**
111
     * @return int|null
112
     *
113
     * @deprecated Use getNextNonSpaceCache() instead
114
     */
115
    public function getFirstNonSpaceCache()
116
    {
117
        @trigger_error('CursorState::getFirstNonSpaceCache() will be removed in a future 0.x release.  Use getNextNonSpaceCache() instead. See https://github.com/thephpleague/commonmark/issues/280', E_USER_DEPRECATED);
0 ignored issues
show
Security Best Practice introduced by Colin O'Dell
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
118
119
        return $this->nextNonSpaceCache;
120
    }
121
122
    /**
123
     * @return int|null
124
     */
125 795
    public function getNextNonSpaceCache()
126
    {
127 795
        return $this->nextNonSpaceCache;
128
    }
129
130
    /**
131
     * @return int
132
     */
133 795
    public function getIndent()
134
    {
135 795
        return $this->indent;
136
    }
137
138
    /**
139
     * @return int
140
     */
141 795
    public function getColumn()
142
    {
143 795
        return $this->column;
144
    }
145
146
    /**
147
     * @return bool
148
     */
149 795
    public function getPartiallyConsumedTab()
150
    {
151 795
        return $this->partiallyConsumedTab;
152
    }
153
}
154