Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
ParsedNode
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
4 / 4
4
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 getStartOffset
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getEndOffset
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 toArray
n/a
0 / 0
n/a
0 / 0
0
 baseParams
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace CirrusSearch\Parser\AST;
4
5use CirrusSearch\Parser\AST\Visitor\Visitable;
6use Wikimedia\Assert\Assert;
7
8/**
9 * Base class representing a "node" in the query AST.
10 */
11abstract class ParsedNode implements Visitable {
12    /**
13     * @var int
14     */
15    private $startOffset;
16
17    /**
18     * @var int
19     */
20    private $endOffset;
21
22    /**
23     * @param int $startOffset (incl)
24     * @param int $endOffset (excl)
25     */
26    public function __construct( $startOffset, $endOffset ) {
27        Assert::precondition( $startOffset <= $endOffset, '$startOffset <= $endOffset' );
28        $this->startOffset = $startOffset;
29        $this->endOffset = $endOffset;
30    }
31
32    /**
33     * @return int
34     */
35    public function getStartOffset() {
36        return $this->startOffset;
37    }
38
39    /**
40     * @return int
41     */
42    public function getEndOffset() {
43        return $this->endOffset;
44    }
45
46    /**
47     * @return array
48     */
49    abstract public function toArray();
50
51    /**
52     * @return array
53     */
54    protected function baseParams() {
55        return [
56            'startOffset' => $this->startOffset,
57            'endOffset' => $this->endOffset,
58        ];
59    }
60}