1 | <?php |
||
15 | class Line |
||
16 | { |
||
17 | use TGetter; |
||
18 | |||
19 | /** |
||
20 | * Line content. |
||
21 | * |
||
22 | * @access private |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | private $content; |
||
27 | |||
28 | /** |
||
29 | * Whether this line is last line. |
||
30 | * |
||
31 | * @access private |
||
32 | * |
||
33 | * @var bool |
||
34 | */ |
||
35 | private $isLast=false; |
||
|
|||
36 | |||
37 | /** |
||
38 | * Constructor. |
||
39 | * |
||
40 | * @access public |
||
41 | * |
||
42 | * @param string | bool $content String content for normal line and false for last line. |
||
43 | */ |
||
44 | public function __construct( /*string|bool*/$content ) |
||
50 | |||
51 | /** |
||
52 | * Getting content without indentation. |
||
53 | * |
||
54 | * @access public |
||
55 | * |
||
56 | * @return string |
||
57 | */ |
||
58 | public function getContent():string |
||
62 | |||
63 | /** |
||
64 | * Getting full content. |
||
65 | * |
||
66 | * @access public |
||
67 | * |
||
68 | * @return string |
||
69 | */ |
||
70 | public function getFullContent():string |
||
74 | |||
75 | /** |
||
76 | * Getting a section of content, like call substr(). |
||
77 | * |
||
78 | * @access public |
||
79 | * |
||
80 | * @param int $start |
||
81 | * @param int ...$lengths |
||
82 | * |
||
83 | * @return string |
||
84 | */ |
||
85 | public function slice( int$start=0, int...$lengths ):string |
||
89 | |||
90 | /** |
||
91 | * Getting single character from content. |
||
92 | * |
||
93 | * @access public |
||
94 | * |
||
95 | * @param int $offset |
||
96 | * |
||
97 | * @return string |
||
98 | */ |
||
99 | public function getChar( int$offset ):string |
||
103 | |||
104 | /** |
||
105 | * Matching a preg pattern and return whether matches. |
||
106 | * |
||
107 | * @access public |
||
108 | * |
||
109 | * @param string $pattern |
||
110 | * |
||
111 | * @return bool |
||
112 | */ |
||
113 | public function pregMatch( string$pattern ):bool |
||
117 | |||
118 | /** |
||
119 | * Matching a preg pattern and return the all or one of groups of matchment. |
||
120 | * |
||
121 | * @access public |
||
122 | * |
||
123 | * @param string $pattern |
||
124 | * @param int | string $match Group index or name |
||
125 | * |
||
126 | * @return string |
||
127 | */ |
||
128 | public function pregGet( string$pattern, /*int|string*/$match=0 ):string |
||
133 | |||
134 | /** |
||
135 | * Multiple matching a preg pattern and map result with a callback. |
||
136 | * |
||
137 | * @access public |
||
138 | * |
||
139 | * @param string $pattern |
||
140 | * @param callable $callback |
||
141 | * |
||
142 | * @return array |
||
143 | */ |
||
144 | public function pregMap( string$pattern, callable$callback ):array |
||
149 | |||
150 | /** |
||
151 | * Getting the indent level of this line, the number of starting tab characters. |
||
152 | * |
||
153 | * @access public |
||
154 | * |
||
155 | * @return int |
||
156 | */ |
||
157 | public function getIndentLevel():int |
||
161 | |||
162 | /** |
||
163 | * Converting this object to string, returning content without indentation. |
||
164 | * |
||
165 | * @access public |
||
166 | * |
||
167 | * @return string |
||
168 | */ |
||
169 | public function __toString():string |
||
173 | |||
174 | /** |
||
175 | * Wether this line is empty. |
||
176 | * |
||
177 | * @access public |
||
178 | * |
||
179 | * @return bool |
||
180 | */ |
||
181 | public function isEmpty():bool |
||
185 | |||
186 | /** |
||
187 | * Whether this line is last line. |
||
188 | * |
||
189 | * @access public |
||
190 | * |
||
191 | * @return bool |
||
192 | */ |
||
193 | public function isLast():bool |
||
197 | |||
198 | /** |
||
199 | * Whether this line is last line. |
||
200 | * |
||
201 | * @access public |
||
202 | * |
||
203 | * @return bool |
||
204 | */ |
||
205 | public function noMore():bool |
||
209 | |||
210 | /** |
||
211 | * Whether next line exists. |
||
212 | * |
||
213 | * @access public |
||
214 | * |
||
215 | * @return bool |
||
216 | */ |
||
217 | public function hasMore():bool |
||
221 | |||
222 | /** |
||
223 | * Getting line with sub level indent( tab space tab ). |
||
224 | * |
||
225 | * @access public |
||
226 | * |
||
227 | * @return \Htsl\ReadingBuffer\Line |
||
228 | */ |
||
229 | public function getSubIndentLine():self |
||
233 | } |
||
234 |
This check looks for improperly formatted assignments.
Every assignment must have exactly one space before and one space after the equals operator.
To illustrate:
will have no issues, while
will report issues in lines 1 and 2.