SearchFacets   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 64
rs 10
wmc 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __isset() 0 3 1
A current() 0 3 1
A valid() 0 5 2
A next() 0 3 1
A __get() 0 7 2
A __set() 0 3 1
A rewind() 0 3 1
A key() 0 3 1
1
<?php
2
3
/*
4
 * This file was created by developers working at BitBag
5
 * Do you need more information about us and what we do? Visit our https://bitbag.io website!
6
 * We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
7
*/
8
9
declare(strict_types=1);
10
11
namespace BitBag\SyliusElasticsearchPlugin\Model;
12
13
class SearchFacets implements \Iterator
14
{
15
    /** @var array[] */
16
    private $selectedBuckets = [];
17
18
    public function __get(string $facetId)
19
    {
20
        if (!array_key_exists($facetId, $this->selectedBuckets)) {
21
            return [];
22
        }
23
24
        return $this->selectedBuckets[$facetId];
25
    }
26
27
    public function __set(string $facetId, $selectedBuckets)
28
    {
29
        $this->selectedBuckets[$facetId] = $selectedBuckets;
30
    }
31
32
    public function __isset(string $facetId)
33
    {
34
        return isset($this->selectedBuckets[$facetId]);
35
    }
36
37
    /**
38
     * @inheritdoc
39
     */
40
    public function current()
41
    {
42
        return current($this->selectedBuckets);
43
    }
44
45
    /**
46
     * @inheritdoc
47
     */
48
    public function next()
49
    {
50
        return next($this->selectedBuckets);
51
    }
52
53
    /**
54
     * @inheritdoc
55
     */
56
    public function key()
57
    {
58
        return key($this->selectedBuckets);
59
    }
60
61
    /**
62
     * @inheritdoc
63
     */
64
    public function valid()
65
    {
66
        $key = key($this->selectedBuckets);
67
68
        return null !== $key && false !== $key;
69
    }
70
71
    /**
72
     * @inheritdoc
73
     */
74
    public function rewind()
75
    {
76
        reset($this->selectedBuckets);
77
    }
78
}
79