|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
namespace JsonDecodeStream\Internal; |
|
5
|
|
|
|
|
6
|
|
|
class StackFrame |
|
7
|
|
|
{ |
|
8
|
|
|
const TYPE_ARRAY = 1; |
|
9
|
|
|
const TYPE_OBJECT = 2; |
|
10
|
|
|
|
|
11
|
|
|
protected $type; |
|
12
|
|
|
protected $elementCount = 0; |
|
13
|
|
|
protected $lastKey = null; |
|
14
|
|
|
protected $awaitsComa = false; |
|
15
|
|
|
protected $awaitsKey = false; |
|
16
|
|
|
protected $awaitsKeyDelimiter = false; |
|
17
|
|
|
|
|
18
|
61 |
|
protected function __construct($type) |
|
19
|
|
|
{ |
|
20
|
61 |
|
$this->type = $type; |
|
21
|
61 |
|
} |
|
22
|
|
|
|
|
23
|
39 |
|
public static function array() |
|
24
|
|
|
{ |
|
25
|
39 |
|
return new static(self::TYPE_ARRAY); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
51 |
|
public static function object() |
|
29
|
|
|
{ |
|
30
|
51 |
|
$frame = new static(self::TYPE_OBJECT); |
|
31
|
51 |
|
$frame->setAwaitsKey(true); |
|
32
|
51 |
|
return $frame; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
54 |
|
public function isArray() |
|
36
|
|
|
{ |
|
37
|
54 |
|
return $this->type == self::TYPE_ARRAY; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
53 |
|
public function isObject() |
|
41
|
|
|
{ |
|
42
|
53 |
|
return $this->type == self::TYPE_OBJECT; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
51 |
|
public function setAwaitsComa(bool $is) |
|
46
|
|
|
{ |
|
47
|
51 |
|
$this->awaitsComa = $is; |
|
48
|
51 |
|
} |
|
49
|
|
|
|
|
50
|
53 |
|
public function isAwaitsComa() |
|
51
|
|
|
{ |
|
52
|
53 |
|
return $this->awaitsComa; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
51 |
|
public function setAwaitsKey(bool $is) |
|
56
|
|
|
{ |
|
57
|
51 |
|
$this->awaitsKey = $is; |
|
58
|
51 |
|
} |
|
59
|
|
|
|
|
60
|
53 |
|
public function isAwaitsKey() |
|
61
|
|
|
{ |
|
62
|
53 |
|
return $this->awaitsKey; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
43 |
|
public function setAwaitsKeyDelimiter(bool $is) |
|
66
|
|
|
{ |
|
67
|
43 |
|
$this->awaitsKeyDelimiter = $is; |
|
68
|
43 |
|
} |
|
69
|
|
|
|
|
70
|
53 |
|
public function isAwaitsKeyDelimiter() |
|
71
|
|
|
{ |
|
72
|
53 |
|
return $this->awaitsKeyDelimiter; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
56 |
|
public function setLastKey($key) |
|
76
|
|
|
{ |
|
77
|
56 |
|
$this->lastKey = $key; |
|
78
|
56 |
|
} |
|
79
|
|
|
|
|
80
|
26 |
|
public function getLastKey() |
|
81
|
|
|
{ |
|
82
|
26 |
|
return $this->lastKey; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
51 |
|
public function incrementElementCount() |
|
86
|
|
|
{ |
|
87
|
51 |
|
return $this->elementCount++; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
37 |
|
public function getElementCount() |
|
91
|
|
|
{ |
|
92
|
37 |
|
return $this->elementCount; |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|