Conditions | 8 |
Paths | 14 |
Total Lines | 29 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 8.3518 |
Changes | 0 |
1 | <?php |
||
24 | 21 | public function __invoke( $N ) |
|
25 | { |
||
26 | 21 | if ($N instanceOf NDeviationProviderInterface): |
|
27 | $N = $N->getNDeviation()->getValue(); |
||
28 | |||
29 | 21 | elseif ($N instanceOf NDeviationInterface): |
|
30 | 12 | $N = $N->getValue(); |
|
31 | 9 | elseif (is_string( $N )): |
|
32 | 9 | if (filter_var($N, FILTER_VALIDATE_FLOAT) === false): |
|
33 | 9 | return $N; |
|
34 | endif; |
||
35 | elseif (!is_numeric( $N )): |
||
36 | throw new \InvalidArgumentException("Numeric value, NDeviationInterface, or NDeviationProviderInterface expected."); |
||
37 | endif; |
||
38 | |||
39 | |||
40 | 18 | $N_str = sprintf( $this->format, abs($N)); |
|
41 | |||
42 | 18 | if ($N > 0) { |
|
43 | 9 | $N_str = "𝑵 +" . $N_str; |
|
44 | 9 | } elseif ($N < 0) { |
|
45 | 6 | $N_str = "𝑵 -" . $N_str; |
|
46 | } else { // == 0.0 |
||
47 | // $N_str = "𝑵"; |
||
48 | 3 | $N_str = "𝑵 ±" . $N_str; |
|
49 | } |
||
50 | |||
51 | 18 | return $N_str; |
|
52 | } |
||
53 | } |
||
54 |