Failed Conditions
Push — master ( c46511...3e8af8 )
by Jordan
01:21 queued 15s
created

ComplexNumbers::make()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 4
nc 3
nop 2
dl 0
loc 9
ccs 0
cts 7
cp 0
crap 12
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Samsara\Fermat;
4
5
use Samsara\Exceptions\UsageError\IntegrityConstraint;
6
use Samsara\Fermat\Values\ImmutableComplexNumber;
7
use Samsara\Fermat\Values\MutableComplexNumber;
8
9
class ComplexNumbers
10
{
11
12
    public const IMMUTABLE = ImmutableComplexNumber::class;
13
    public const MUTABLE = MutableComplexNumber::class;
14
15
    /**
16
     * @param $type
17
     * @param $value
18
     *
19
     * @return Types\ComplexNumber
20
     * @throws IntegrityConstraint
21
     */
22
    public static function make($type, $value)
23
    {
24
25
        if (is_string($value)) {
26
            if ($type === self::MUTABLE) {
27
                return MutableComplexNumber::makeFromString($value);
28
            }
29
30
            return ImmutableComplexNumber::makeFromString($value);
31
        }
32
33
    }
34
35
}