Conditions | 5 |
Paths | 3 |
Total Lines | 13 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 5 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php namespace BuildR\Utils\Factories; |
||
33 | 91 | public static function create($string) { |
|
34 | 91 | if(is_array($string)) { |
|
35 | 1 | throw new InvalidArgumentException('Arrays cannot be casted to string!'); |
|
36 | } |
||
37 | |||
38 | 90 | if(is_object($string) && |
|
39 | 90 | !(($string instanceof StringConvertibleInterface) || (method_exists($string, '__toString')))) { |
|
40 | 1 | throw new InvalidArgumentException('The given value is an object but cant converted to string!'); |
|
41 | } |
||
42 | |||
43 | 89 | $value = (string) $string; |
|
44 | 89 | return new StringObject($value); |
|
45 | } |
||
46 | |||
48 |