SearchVariant_Caller   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A call() 0 14 4
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