Combine::combine()   A
last analyzed

Complexity

Conditions 3
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 4
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 3
rs 10
1
<?php
2
3
namespace Cocur\Chain\Link;
4
5
use Cocur\Chain\Chain;
6
7
/**
8
 * Class ChangeKeyCase.
9
 *
10
 * @author      Christoph Rosse
11
 */
12
trait Combine
13
{
14
    /**
15
     * Creates an Chain by using one Chain for keys and another for its values.
16
     *
17
     * @param Chain|array $keys   Array or instance of `Cocur\Chain\Chain` of keys to be used. Illegal values for key
18
     *                            will be converted to string.
19
     * @param Chain|array $values array or instance of `Cocur\Chain\Chain` of values to be used
20
     *
21
     * @return self
22
     */
23 2
    public function combine($keys, $values): self
24
    {
25 2
        $this->array = array_combine(
26 2
            $keys instanceof Chain ? $keys->array : $keys,
27 2
            $values instanceof Chain ? $values->array : $values
28
        );
29
30 2
        return $this;
31
    }
32
}
33