Completed
Pull Request — master (#72)
by Thibaud
08:29
created

QuerySuggestion::getValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 1
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
/*
4
 * This file is part of Phraseanet SDK.
5
 *
6
 * (c) Alchemy <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace PhraseanetSDK\Entity;
13
14
class QuerySuggestion
15
{
16
    /**
17
     * @param \stdClass[] $values
18
     * @return QuerySuggestion[]
19
     */
20 1
    public static function fromList(array $values)
21
    {
22 1
        $suggestions = array();
23
24 1
        foreach ($values as $value) {
25
            $suggestions[] = self::fromValue($value);
26 1
        }
27
28 1
        return $suggestions;
29
    }
30
31
    /**
32
     * @param \stdClass $value
33
     * @return QuerySuggestion
34
     */
35
    public static function fromValue(\stdClass $value)
36
    {
37
        return new self($value);
38
    }
39
40
    /**
41
     * @var \stdClass
42
     */
43
    protected $source;
44
45
    /**
46
     * @param \stdClass $source
47
     */
48
    public function __construct(\stdClass $source)
49
    {
50
        $this->source = $source;
51
    }
52
53
    /**
54
     * @return \stdClass
55
     */
56
    public function getRawData()
57
    {
58
        return $this->source;
59
    }
60
61
    /**
62
     * Get the suggestion value
63
     *
64
     * @return string
65
     */
66
    public function getValue()
67
    {
68
        return $this->source->value;
69
    }
70
71
    /**
72
     * Tell whether the suggestion is current
73
     *
74
     * @return Boolean
75
     */
76
    public function isCurrent()
77
    {
78
        return $this->source->current;
79
    }
80
81
    /**
82
     * Get the suggestion hit
83
     *
84
     * @return integer
85
     */
86
    public function getHits()
87
    {
88
        return $this->source->hits;
89
    }
90
}
91