@@ -27,15 +27,17 @@ public function testExceptionMessageDefaultsAgainstIana($code, $reasonPhrase): v
2727 if ($ code < 400 ) {
2828 $ this ->assertTrue (true );
2929 } else {
30+ // generate the class name (should be the same as the error reason without space)
3031 if ($ code >= 400 && $ code <= 499 ) {
31- $ className = 'Chiron\Http\Exception\Client \\' . $ this -> generateClasseName ( $ reasonPhrase ) . 'HttpException ' ;
32+ $ className = 'Chiron\Http\Exception\Client \\' . str_replace ( ' ' , '' , $ reasonPhrase ) . 'HttpException ' ;
3233 }
3334
3435 if ($ code >= 500 && $ code <= 599 ) {
35- $ className = 'Chiron\Http\Exception\Server \\' . $ this -> generateClasseName ( $ reasonPhrase ) . 'HttpException ' ;
36+ $ className = 'Chiron\Http\Exception\Server \\' . str_replace ( ' ' , '' , $ reasonPhrase ) . 'HttpException ' ;
3637 }
3738
38- $ this ->assertTrue (is_subclass_of ($ className , HttpException::class), 'Http Exeption Class " ' . $ className . '" doesnt exist !!! ' );
39+ // remember the classname is insensitive in PHP
40+ $ this ->assertTrue (is_subclass_of ($ className , HttpException::class), 'Http Exeption Class " ' . strtoupper ($ className ) . '" doesnt exist !!! ' );
3941
4042 $ this ->assertEquals (
4143 $ reasonPhrase ,
@@ -45,17 +47,6 @@ public function testExceptionMessageDefaultsAgainstIana($code, $reasonPhrase): v
4547 }
4648 }
4749
48- private function generateClasseName (string $ nameNotFormatted ): string
49- {
50- $ parts = explode (' ' , $ nameNotFormatted );
51-
52- $ formatted = array_map (function ($ part ) {
53- return ucwords (strtolower ($ part ));
54- }, $ parts );
55-
56- return implode ($ formatted );
57- }
58-
5950 /**
6051 * Grab the reason phrase directly from the IANA specs.
6152 */
0 commit comments