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

ComplexNumbers   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 22
ccs 0
cts 7
cp 0
rs 10
c 1
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A make() 0 9 3
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
}