93% of 271OPs |
90% of 30Lines |
73% of 41Branches |
90% of 20Paths |
Method | OPs | OPs % | Lines | Line % | Branches | Branches % | Paths | Path % |
---|---|---|---|---|---|---|---|---|
mageekguy\atoum\tools\variable\analyzer::getTypeOf() | 137 | 92% | 19 | 89% | 29 | 66% | 10 | 90% |
mageekguy\atoum\tools\variable\analyzer::dump() | 26 | 100% | 3 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\tools\variable\analyzer::isObject() | 13 | 100% | 1 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\tools\variable\analyzer::isException() | 8 | 0% | 1 | 0% | 1 | 0% | 1 | 0% |
mageekguy\atoum\tools\variable\analyzer::isBoolean() | 13 | 100% | 1 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\tools\variable\analyzer::isInteger() | 13 | 100% | 1 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\tools\variable\analyzer::isFloat() | 13 | 100% | 1 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\tools\variable\analyzer::isString() | 13 | 100% | 1 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\tools\variable\analyzer::isUtf8() | 22 | 100% | 1 | 100% | 4 | 100% | 2 | 100% |
mageekguy\atoum\tools\variable\analyzer::isArray() | 13 | 100% | 1 | 100% | 1 | 100% | 1 | 100% |
# | |
---|---|
1 |
<?php |
2 |
|
3 |
namespace mageekguy\atoum\tools\variable; |
4 |
|
5 |
class analyzer |
6 |
{ |
7 |
public function getTypeOf($mixed)89% |
8 |
{ |
9 |
switch (gettype($mixed)) |
10 |
{ |
11 |
case 'boolean': |
12 |
return sprintf('boolean(%s)', $mixed == false ? 'false' : 'true'); |
13 |
|
14 |
case 'integer': |
15 |
return sprintf('integer(%s)', $mixed); |
16 |
|
17 |
case 'double': |
18 |
return sprintf('float(%s)', $mixed); |
19 |
|
20 |
case 'NULL': |
21 |
return 'null'; |
22 |
|
23 |
case 'object': |
24 |
return sprintf('object(%s)', get_class($mixed)); |
25 |
|
26 |
case 'resource': |
27 |
return sprintf('%s of type %s', $mixed, get_resource_type($mixed)); |
28 |
|
29 |
case 'string': |
30 |
return sprintf('string(%s) \'%s\'', strlen($mixed), $mixed); |
31 |
|
32 |
case 'array': |
33 |
return sprintf('array(%s)', sizeof($mixed)); |
34 |
} |
35 |
} |
36 |
|
37 |
public function dump($mixed)100% |
38 |
{ |
39 |
ob_start(); |
40 |
|
41 |
var_dump($mixed); |
42 |
|
43 |
return trim(ob_get_clean()); |
44 |
} |
45 |
|
46 |
public function isObject($mixed)100% |
47 |
{ |
48 |
return (is_object($mixed) === true); |
49 |
} |
50 |
|
51 |
public function isException($mixed)0% |
52 |
{ |
53 |
return ($mixed instanceof \exception); |
54 |
} |
55 |
|
56 |
public function isBoolean($mixed)100% |
57 |
{ |
58 |
return (is_bool($mixed) === true); |
59 |
} |
60 |
|
61 |
public function isInteger($mixed)100% |
62 |
{ |
63 |
return (is_int($mixed) === true); |
64 |
} |
65 |
|
66 |
public function isFloat($mixed)100% |
67 |
{ |
68 |
return (is_float($mixed) === true); |
69 |
} |
70 |
|
71 |
public function isString($mixed)100% |
72 |
{ |
73 |
return (is_string($mixed) === true); |
74 |
} |
75 |
|
76 |
public function isUtf8($mixed)100% |
77 |
{ |
78 |
return ($this->isString($mixed) === true && preg_match('/^.*$/us', $mixed) === 1); |
79 |
} |
80 |
|
81 |
public function isArray($mixed)100% |
82 |
{ |
83 |
return (is_array($mixed) === true); |
84 |
} |
85 |
} |