1
<?php
2

3
/*
4
 * This file is part of the Solarium package.
5
 *
6
 * For the full copyright and license information, please view the COPYING
7
 * file that was distributed with this source code.
8
 */
9

10
namespace Solarium\Component\Result\Spellcheck;
11

12
/**
13
 * Select component spellcheck collation result.
14
 */
15
class Collation implements \IteratorAggregate, \Countable
16
{
17
    /**
18
     * Query.
19
     *
20
     * @var string
21
     */
22
    protected $query;
23

24
    /**
25
     * Hit count.
26
     *
27
     * @var int
28
     */
29
    protected $hits;
30

31
    /**
32
     * Corrections.
33
     *
34
     * @var array
35
     */
36
    protected $corrections;
37

38
    /**
39
     * Constructor.
40
     *
41
     * @param string $query
42
     * @param int    $hits
43
     * @param array  $corrections
44
     */
45 12
    public function __construct(string $query, ?int $hits, array $corrections)
46
    {
47 12
        $this->query = $query;
48 12
        $this->hits = $hits;
49 12
        $this->corrections = $corrections;
50
    }
51

52
    /**
53
     * Get query string.
54
     *
55
     * @return string
56
     */
57 12
    public function getQuery(): string
58
    {
59 12
        return $this->query;
60
    }
61

62
    /**
63
     * Get hit count.
64
     *
65
     * Only available if ExtendedResults was enabled in your query
66
     *
67
     * @return int|null
68
     */
69 12
    public function getHits(): ?int
70
    {
71 12
        return $this->hits;
72
    }
73

74
    /**
75
     * Get all corrrections.
76
     *
77
     * Only available if ExtendedResults was enabled in your query
78
     *
79
     * @return array
80
     */
81 12
    public function getCorrections(): ?array
82
    {
83 12
        return $this->corrections;
84
    }
85

86
    /**
87
     * IteratorAggregate implementation.
88
     *
89
     * Only available if ExtendedResults was enabled in your query
90
     *
91
     * @return \ArrayIterator
92
     */
93 12
    public function getIterator(): \ArrayIterator
94
    {
95 12
        return new \ArrayIterator($this->corrections);
96
    }
97

98
    /**
99
     * Countable implementation.
100
     *
101
     * Only available if ExtendedResults was enabled in your query
102
     *
103
     * @return int
104
     */
105 12
    public function count(): int
106
    {
107 12
        return \count($this->corrections);
108
    }
109
}

Read our documentation on viewing source code .

Loading