Passed
Push — master ( 177f69...7b0b69 )
by Simon
08:14
created

MockStateTwo   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 50
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setDefaultState() 0 3 1
A appliesToEnvironment() 0 3 1
A stateIsApplicable() 0 3 1
A currentState() 0 3 1
A updateQuery() 0 2 1
A activateState() 0 3 1
1
<?php
2
3
4
namespace Firesphere\SolrCompatibility\Tests;
5
6
use Firesphere\SolrSearch\Interfaces\SiteStateInterface;
7
use Firesphere\SolrSearch\Queries\BaseQuery;
8
use Firesphere\SolrSearch\States\SiteState;
9
use SilverStripe\Dev\TestOnly;
10
11
class MockStateTwo extends SiteState implements TestOnly, SiteStateInterface
12
{
13
    protected $state = 'Cow';
14
15
    public function appliesToEnvironment(): bool
16
    {
17
        return $this->enabled;
18
    }
19
20
    public function currentState(): string
21
    {
22
        return $this->state;
23
    }
24
25
    public function activateState($state)
26
    {
27
        $this->state = $state;
28
    }
29
30
    /**
31
     * Is this state applicable to this extension
32
     * E.g. in case of Fluent, the state "SubsiteID1" does not make sense
33
     *
34
     * @param string $state
35
     * @return bool
36
     */
37
    public function stateIsApplicable($state): bool
38
    {
39
        return in_array($state, ['Cow', 'Sheep']);
40
    }
41
42
    /**
43
     * Reset the SiteState to it's default state
44
     *
45
     * @param null $state
46
     * @return mixed
47
     */
48
    public function setDefaultState($state = null)
49
    {
50
        $this->state = 'Cow';
51
    }
52
53
    /**
54
     * Method to alter the query. Can be no-op.
55
     *
56
     * @param BaseQuery $query
57
     * @return mixed
58
     */
59
    public function updateQuery(&$query)
60
    {
61
        // TODO: Implement updateQuery() method.
62
    }
63
}
64