xref: /plugin/struct/meta/SearchResult.php (revision ba7f5789bbbcab95d7a655f6ec50a97b731b40d5)
1<?php
2
3namespace dokuwiki\plugin\struct\meta;
4
5/**
6 * Class SearchResult
7 *
8 * Search is executed only once per request.
9 */
10class SearchResult
11{
12    /** @var Value[][] */
13    protected $rows = [];
14    /** @var array */
15    protected $pids = [];
16    protected $rids = [];
17    /** @var array */
18    protected $revs = [];
19    /** @var int */
20    protected $count = -1;
21
22    /** @var SearchResult */
23    protected static $instance;
24
25    /**
26     * Get the singleton instance of SearchResult
27     *
28     * @return SearchResult
29     */
30    public static function getInstance()
31    {
32        if (is_null(self::$instance)) {
33            $class = static::class;
34            self::$instance = new $class();
35        }
36        return self::$instance;
37    }
38
39    /**
40     * @return array
41     */
42    public function getPids(): array
43    {
44        return $this->pids;
45    }
46
47    /**
48     * @return Value[][]
49     */
50    public function getRows()
51    {
52        return $this->rows;
53    }
54
55    /**
56     * @return array
57     */
58    public function getRids(): array
59    {
60        return $this->rids;
61    }
62
63    /**
64     * @return int
65     */
66    public function getCount(): int
67    {
68        return $this->count;
69    }
70
71    /**
72     * @return array
73     */
74    public function getRevs(): array
75    {
76        return $this->revs;
77    }
78
79    /**
80     * @param string $pid
81     * @return void
82     */
83    public function addPid($pid)
84    {
85        $this->pids[] = $pid;
86    }
87
88    /**
89     * @param int $rid
90     * @return void
91     */
92    public function addRid($rid)
93    {
94        $this->rids[] = $rid;
95    }
96
97    /**
98     * @param int $rev
99     * @return void
100     */
101    public function addRev($rev)
102    {
103        $this->revs[] = $rev;
104    }
105
106    /**
107     * @param array $result
108     * @return void
109     */
110    public function addRow($row)
111    {
112        $this->rows[] = $row;
113    }
114
115    /**
116     * @return void
117     */
118    public function increaseCount()
119    {
120        $this->count++;
121    }
122/**
123     * @return void
124     */
125    public function decreaseCount()
126    {
127        $this->count--;
128    }
129}
130