Intersect::byValues()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PHPKitchen\Platform\Helper\Collection;
4
5
/**
6
 * Represents
7
 *
8
 * @author Dmitry Kolodko <[email protected]>
9
 * @since 1.0
10
 */
11
class Intersect {
12
    protected $collections;
13
14
    // @todo support of collection
15
    public function byValues(): array {
16
        return array_intersect(...$this->collections);
17
    }
18
19
    // @todo support of collection
20
    public function byKeysComparedBy(callable $compare): array {
21
        $arguments = $this->collections;
22
        $arguments[] = $compare;
23
24
        return array_intersect_ukey(...$arguments);
25
    }
26
27
    // @todo support of collection
28
    public function byKeys(): array {
29
        return array_intersect_key(...$this->collections);
30
    }
31
32
    // @todo support of collection
33
    public function byValuesAndKeys(): array {
34
        return array_intersect_assoc(...$this->collections);
35
    }
36
37
    // @todo support of collection
38
    public function byValuesAndKeysComparedBy(callable $compare): array {
39
        $arguments = $this->collections;
40
        $arguments[] = $compare;
41
42
        return array_intersect_uassoc(...$arguments);
43
    }
44
}