We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 930e052 + 92d4c1b commit 391c83cCopy full SHA for 391c83c
2 files changed
src/Lexer.php
@@ -36,7 +36,7 @@ class Lexer
36
public function __construct($string)
37
{
38
$this->string = $string;
39
- $this->currentCharacter = $string{0};
+ $this->currentCharacter = ($string !== '') ? $string{0} : null;
40
$this->characterPosition = 0;
41
}
42
tests/ParserTest.php
@@ -5,6 +5,37 @@
5
class ParserTest extends TestCase
6
7
8
+ /**
9
+ * @test
10
+ */
11
+ public function shouldParseEmptyCode()
12
+ {
13
+ $parser = new Parser('');
14
+
15
+ $this->assertEquals(
16
+ [],
17
+ $parser->parse()
18
+ );
19
+ }
20
21
22
23
24
+ public function shouldParseBlankCode()
25
26
+ $parser = new Parser(' ');
27
28
29
+ [
30
31
+ 'type' => 'text',
32
+ 'payload' => ' '
33
+ ]
34
+ ],
35
/**
* @test
*/
0 commit comments