2
2
3
3
declare (strict_types=1 );
4
4
5
- namespace Leuchtfeuer \Locate \Utility ;
5
+ /*
6
+ * This file is part of the "Locate" extension for TYPO3 CMS.
7
+ *
8
+ * For the full copyright and license information, please read the
9
+ * LICENSE.txt file that was distributed with this source code.
10
+ *
11
+ * Team YD <[email protected] >, Leuchtfeuer Digital Marketing
12
+ */
6
13
7
- use Exception ;
14
+ namespace Leuchtfeuer \ Locate \ Utility ;
8
15
9
16
class TypeCaster
10
17
{
@@ -17,7 +24,7 @@ public static function toInt(mixed $value): int
17
24
return (int )$ value ;
18
25
}
19
26
20
- throw new Exception (sprintf ('Value of type "%s" can not be casted to integer. ' , gettype ($ value )), 1727337294 );
27
+ throw new \ Exception (sprintf ('Value of type "%s" can not be casted to integer. ' , gettype ($ value )), 1727337294 );
21
28
}
22
29
23
30
public static function toString (mixed $ value ): string
@@ -32,10 +39,10 @@ public static function toString(mixed $value): string
32
39
return (string )$ value ;
33
40
}
34
41
if (is_object ($ value ) && !method_exists ($ value , '__toString ' )) {
35
- throw new Exception (sprintf ('Object of type "%s" is not stringable. ' , get_class ($ value )), 1727337280 );
42
+ throw new \ Exception (sprintf ('Object of type "%s" is not stringable. ' , get_class ($ value )), 1727337280 );
36
43
}
37
44
38
- throw new Exception (sprintf ('Value of type "%s" can not be casted to string. ' , gettype ($ value )), 1727337295 );
45
+ throw new \ Exception (sprintf ('Value of type "%s" can not be casted to string. ' , gettype ($ value )), 1727337295 );
39
46
}
40
47
41
48
public static function toBool (mixed $ value ): bool
@@ -47,14 +54,14 @@ public static function toBool(mixed $value): bool
47
54
return (bool )$ value ;
48
55
}
49
56
50
- throw new Exception (sprintf ('Value of type "%s" can not be casted to boolean. ' , gettype ($ value )), 1727337296 );
57
+ throw new \ Exception (sprintf ('Value of type "%s" can not be casted to boolean. ' , gettype ($ value )), 1727337296 );
51
58
}
52
59
53
60
/**
54
61
* @template T
55
62
* @param class-string<T> $className
56
63
* @return T
57
- * @throws Exception
64
+ * @throws \ Exception
58
65
*/
59
66
public static function limitToClass (mixed $ value , string $ className )
60
67
{
@@ -63,21 +70,21 @@ public static function limitToClass(mixed $value, string $className)
63
70
}
64
71
65
72
if (gettype ($ value ) === 'object ' ) {
66
- throw new Exception (sprintf ('Object of type "%s" is not instance of "%s" ' , get_class ($ value ), $ className ), 1727337297 );
73
+ throw new \ Exception (sprintf ('Object of type "%s" is not instance of "%s" ' , get_class ($ value ), $ className ), 1727337297 );
67
74
}
68
- throw new Exception (sprintf ('Value of type "%s" is not instance of "%s" ' , gettype ($ value ), $ className ), 1727337298 );
75
+ throw new \ Exception (sprintf ('Value of type "%s" is not instance of "%s" ' , gettype ($ value ), $ className ), 1727337298 );
69
76
}
70
77
71
78
/**
72
79
* @return array<int|string, mixed>
73
- * @throws Exception
80
+ * @throws \ Exception
74
81
*/
75
82
public static function limitToArray (mixed $ value ): array
76
83
{
77
84
if (is_array ($ value )) {
78
85
return $ value ;
79
86
}
80
87
81
- throw new Exception (sprintf ('Value of type "%s" is not an array. ' , gettype ($ value )), 1727337299 );
88
+ throw new \ Exception (sprintf ('Value of type "%s" is not an array. ' , gettype ($ value )), 1727337299 );
82
89
}
83
90
}
0 commit comments