Completed
Push — master ( f8a1a1...93e29b )
by Randy
02:37
created

Either::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Dgame\Ensurance;
4
5
/**
6
 * Class Either
7
 * @package Dgame\Ensurance
8
 */
9
final class Either
10
{
11
    /**
12
     * @var mixed
13
     */
14
    private $value;
15
    /**
16
     * @var bool
17
     */
18
    private $ensured = false;
19
20
    /**
21
     * Either constructor.
22
     *
23
     * @param                    $value
24
     * @param bool               $ensured
25
     */
26
    public function __construct($value, bool $ensured)
27
    {
28
        $this->value   = $value;
29
        $this->ensured = $ensured;
30
    }
31
32
    /**
33
     * @param $value
34
     *
35
     * @return mixed
36
     */
37
    public function or($value)
38
    {
39
        return $this->ensured ? $this->value : $value;
40
    }
41
}