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