Passed
Push — master ( f15a7f...39a5d6 )
by Sebastian
03:19
created
src/ClassHelper.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
      *                         the vendor name, for example (Vendor\PackageName\Folder\Class).
41 41
      * @return string|null The detected class name, or NULL otherwise.
42 42
      */
43
-    public static function resolveClassName(string $legacyName, string $nsPrefix='') : ?string
43
+    public static function resolveClassName(string $legacyName, string $nsPrefix = '') : ?string
44 44
     {
45 45
         $names = array(
46 46
             str_replace('\\', '_', $legacyName),
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
             $nsPrefix.'\\'.str_replace('_', '\\', $legacyName)
49 49
         );
50 50
 
51
-        foreach($names as $name) {
51
+        foreach ($names as $name) {
52 52
             if (class_exists($name)) {
53 53
                 return ltrim($name, '\\');
54 54
             }
@@ -67,11 +67,11 @@  discard block
 block discarded – undo
67 67
      * @return string
68 68
      * @throws ClassNotExistsException
69 69
      */
70
-    public static function requireResolvedClass(string $legacyName, string $nsPrefix='') : string
70
+    public static function requireResolvedClass(string $legacyName, string $nsPrefix = '') : string
71 71
     {
72 72
         $class = self::resolveClassName($legacyName, $nsPrefix);
73 73
 
74
-        if($class !== null)
74
+        if ($class !== null)
75 75
         {
76 76
             return $class;
77 77
         }
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      */
92 92
     public static function requireClassExists(string $className) : void
93 93
     {
94
-        if(class_exists($className))
94
+        if (class_exists($className))
95 95
         {
96 96
             return;
97 97
         }
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
         self::requireClassExists($targetClass);
117 117
         self::requireClassExists($extendsClass);
118 118
 
119
-        if(is_a($targetClass, $extendsClass, true))
119
+        if (is_a($targetClass, $extendsClass, true))
120 120
         {
121 121
             return;
122 122
         }
@@ -142,19 +142,19 @@  discard block
 block discarded – undo
142 142
      * @throws ClassNotImplementsException
143 143
      * @throws Throwable
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 $object;
150 150
         }
151 151
 
152
-        if(!class_exists($class) && !interface_exists($class) && !trait_exists($class))
152
+        if (!class_exists($class) && !interface_exists($class) && !trait_exists($class))
153 153
         {
154 154
             throw new ClassNotExistsException($class, $errorCode);
155 155
         }
156 156
 
157
-        if(is_a($object, $class, true))
157
+        if (is_a($object, $class, true))
158 158
         {
159 159
             return $object;
160 160
         }
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
      */
176 176
     public static function getClassLoader() : ClassLoader
177 177
     {
178
-        if(isset(self::$classLoader)) {
178
+        if (isset(self::$classLoader)) {
179 179
             return self::$classLoader;
180 180
         }
181 181
 
@@ -189,14 +189,14 @@  discard block
 block discarded – undo
189 189
 
190 190
         $autoloadFile = null;
191 191
 
192
-        foreach($paths as $path)
192
+        foreach ($paths as $path)
193 193
         {
194
-            if(file_exists($path)) {
194
+            if (file_exists($path)) {
195 195
                 $autoloadFile = $path;
196 196
             }
197 197
         }
198 198
 
199
-        if($autoloadFile === null) {
199
+        if ($autoloadFile === null) {
200 200
             throw new ClassLoaderNotFoundException($paths);
201 201
         }
202 202
 
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
      */
248 248
     private static function splitClass($subject) : array
249 249
     {
250
-        if(is_object($subject)) {
250
+        if (is_object($subject)) {
251 251
             $class = get_class($subject);
252 252
         } else {
253 253
             $class = $subject;
Please login to merge, or discard this patch.