1<?php
2
3namespace dokuwiki\plugin\struct\meta;
4
5/**
6 * Handler for the row value parser
7 */
8class FilterValueListHandler
9{
10    protected $row = [];
11    protected $current_row = 0;
12    protected $token = '';
13
14    /**
15     * @return array
16     */
17    public function getRow()
18    {
19        return $this->row;
20    }
21
22    /**
23     * @param string match contains the text that was matched
24     * @param int state - the type of match made (see below)
25     * @param int pos - byte index where match was made
26     */
27    public function row($match, $state, $pos)
28    {
29        switch ($state) {
30            // The start of the list...
31            case DOKU_LEXER_ENTER:
32                break;
33
34            // The end of the list
35            case DOKU_LEXER_EXIT:
36                $this->row[$this->current_row] = $this->token;
37                break;
38
39            case DOKU_LEXER_MATCHED:
40                $this->row[$this->current_row] = $this->token;
41                $this->token = '';
42                $this->current_row++;
43                break;
44        }
45        return true;
46    }
47
48    /**
49     * @param string match contains the text that was matched
50     * @param int state - the type of match made (see below)
51     * @param int pos - byte index where match was made
52     */
53    public function singleQuoteString($match, $state, $pos)
54    {
55        if ($state === DOKU_LEXER_UNMATCHED) {
56            $this->token .= $match;
57        }
58        return true;
59    }
60
61    /**
62     * @param string match contains the text that was matched
63     * @param int state - the type of match made (see below)
64     * @param int pos - byte index where match was made
65     */
66    public function escapeSequence($match, $state, $pos)
67    {
68        //add escape character to the token
69        $this->token .= $match[1];
70        return true;
71    }
72
73    /**
74     * @param string match contains the text that was matched
75     * @param int state - the type of match made (see below)
76     * @param int pos - byte index where match was made
77     */
78    public function number($match, $state, $pos)
79    {
80        $this->token = $match;
81        return true;
82    }
83}
84