SearchVariant_Caller::call()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 7
c 1
b 0
f 0
nc 4
nop 2
dl 0
loc 14
rs 10
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