Passed
Push — master ( 80e6cc...b083ab )
by Sebastian
03:06
created
src/ClassHelper.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      *                         the vendor name, for example (Vendor\PackageName\Folder\Class).
42 42
      * @return string|null The detected class name, or NULL otherwise.
43 43
      */
44
-    public static function resolveClassName(string $legacyName, string $nsPrefix='') : ?string
44
+    public static function resolveClassName(string $legacyName, string $nsPrefix = '') : ?string
45 45
     {
46 46
         $names = array(
47 47
             str_replace('\\', '_', $legacyName),
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
             $nsPrefix.'\\'.str_replace('_', '\\', $legacyName)
50 50
         );
51 51
 
52
-        foreach($names as $name) {
52
+        foreach ($names as $name) {
53 53
             if (class_exists($name)) {
54 54
                 return ltrim($name, '\\');
55 55
             }
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
      * @return string
69 69
      * @throws ClassNotExistsException
70 70
      */
71
-    public static function requireResolvedClass(string $legacyName, string $nsPrefix='') : string
71
+    public static function requireResolvedClass(string $legacyName, string $nsPrefix = '') : string
72 72
     {
73 73
         $class = self::resolveClassName($legacyName, $nsPrefix);
74 74
 
75
-        if($class !== null)
75
+        if ($class !== null)
76 76
         {
77 77
             return $class;
78 78
         }
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      */
93 93
     public static function requireClassExists(string $className) : void
94 94
     {
95
-        if(class_exists($className))
95
+        if (class_exists($className))
96 96
         {
97 97
             return;
98 98
         }
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
         self::requireClassExists($targetClass);
118 118
         self::requireClassExists($extendsClass);
119 119
 
120
-        if(is_a($targetClass, $extendsClass, true))
120
+        if (is_a($targetClass, $extendsClass, true))
121 121
         {
122 122
             return;
123 123
         }
@@ -142,9 +142,9 @@  discard block
 block discarded – undo
142 142
      * @throws ClassNotExistsException
143 143
      * @throws ClassNotImplementsException
144 144
      */
145
-    public static function requireObjectInstanceOf(string $class, object $object, int $errorCode=0)
145
+    public static function requireObjectInstanceOf(string $class, object $object, int $errorCode = 0)
146 146
     {
147
-        if($object instanceof Throwable)
147
+        if ($object instanceof Throwable)
148 148
         {
149 149
             throw new ClassNotExistsException(
150 150
                 $class,
@@ -153,12 +153,12 @@  discard block
 block discarded – undo
153 153
             );
154 154
         }
155 155
 
156
-        if(!class_exists($class) && !interface_exists($class) && !trait_exists($class))
156
+        if (!class_exists($class) && !interface_exists($class) && !trait_exists($class))
157 157
         {
158 158
             throw new ClassNotExistsException($class, $errorCode);
159 159
         }
160 160
 
161
-        if(is_a($object, $class, true))
161
+        if (is_a($object, $class, true))
162 162
         {
163 163
             return $object;
164 164
         }
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
      */
180 180
     public static function getClassLoader() : ClassLoader
181 181
     {
182
-        if(isset(self::$classLoader)) {
182
+        if (isset(self::$classLoader)) {
183 183
             return self::$classLoader;
184 184
         }
185 185
 
@@ -193,14 +193,14 @@  discard block
 block discarded – undo
193 193
 
194 194
         $autoloadFile = null;
195 195
 
196
-        foreach($paths as $path)
196
+        foreach ($paths as $path)
197 197
         {
198
-            if(file_exists($path)) {
198
+            if (file_exists($path)) {
199 199
                 $autoloadFile = $path;
200 200
             }
201 201
         }
202 202
 
203
-        if($autoloadFile === null) {
203
+        if ($autoloadFile === null) {
204 204
             throw new ClassLoaderNotFoundException($paths);
205 205
         }
206 206
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
      */
252 252
     private static function splitClass($subject) : array
253 253
     {
254
-        if(is_object($subject)) {
254
+        if (is_object($subject)) {
255 255
             $class = get_class($subject);
256 256
         } else {
257 257
             $class = $subject;
Please login to merge, or discard this patch.