RandomValue   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
eloc 5
dl 0
loc 27
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A merge() 0 3 2
A __construct() 0 4 3
1
<?php
2
3
namespace Graze\ArrayMerger\ValueMerger;
4
5
class RandomValue implements ValueMergerInterface
6
{
7
    use InvokeMergeTrait;
8
9
    /**
10
     * RandomValue constructor.
11
     *
12
     * @param int $seed
13
     */
14 3
    public function __construct($seed = null)
15
    {
16 3
        if (!is_null($seed) && is_int($seed)) {
17 1
            mt_srand($seed);
18
        }
19 3
    }
20
21
    /**
22
     * Return a random result
23
     *
24
     * @param mixed $value1
25
     * @param mixed $value2
26
     *
27
     * @return mixed
28
     */
29 3
    public function merge($value1, $value2)
30
    {
31 3
        return (mt_rand(1, 2) == 1) ? $value1 : $value2;
32
    }
33
}
34