SearchVariant_Caller::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SilverStripe\FullTextSearch\Search\Variants;
4
5
/**
6
 * Internal utility class used to hold the state of the SearchVariant::with call
7
 */
8
class SearchVariant_Caller
9
{
10
    protected $variants = null;
11
12
    public function __construct($variants)
13
    {
14
        $this->variants = $variants;
15
    }
16
17
    public function call($method, &...$args)
18
    {
19
        $values = array();
20
21
        foreach ($this->variants as $variant) {
22
            if (method_exists($variant, $method)) {
23
                $value = $variant->$method(...$args);
24
                if ($value !== null) {
25
                    $values[] = $value;
26
                }
27
            }
28
        }
29
30
        return $values;
31
    }
32
}
33