@@ -59,15 +59,15 @@ discard block |
||
| 59 | 59 | * @inheritDoc |
| 60 | 60 | */ |
| 61 | 61 | public function load($className) { |
| 62 | - if(count($this->registeredMaps) < 1) { |
|
| 62 | + if (count($this->registeredMaps) < 1) { |
|
| 63 | 63 | return FALSE; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - foreach($this->registeredMaps as $mapName => $map) { |
|
| 67 | - if(isset($map[$className])) { |
|
| 66 | + foreach ($this->registeredMaps as $mapName => $map) { |
|
| 67 | + if (isset($map[$className])) { |
|
| 68 | 68 | $classFile = $map[$className]; |
| 69 | 69 | |
| 70 | - if(file_exists($classFile)) { |
|
| 70 | + if (file_exists($classFile)) { |
|
| 71 | 71 | include_once $classFile; |
| 72 | 72 | |
| 73 | 73 | return TRUE; |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | * @throws \BuildR\ClassLoader\Modules\Map\MapModuleException |
| 88 | 88 | */ |
| 89 | 89 | public function registerMap($mapName, $map) { |
| 90 | - if($this->mapIsRegistered($mapName)) { |
|
| 90 | + if ($this->mapIsRegistered($mapName)) { |
|
| 91 | 91 | throw MapModuleException::mapNameOccupied($mapName); |
| 92 | 92 | } |
| 93 | 93 | |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | * @return bool |
| 103 | 103 | */ |
| 104 | 104 | public function removeMap($mapName) { |
| 105 | - if(!$this->mapIsRegistered($mapName)) { |
|
| 105 | + if (!$this->mapIsRegistered($mapName)) { |
|
| 106 | 106 | return FALSE; |
| 107 | 107 | } |
| 108 | 108 | |
@@ -57,14 +57,14 @@ discard block |
||
| 57 | 57 | * @inheritDoc |
| 58 | 58 | */ |
| 59 | 59 | public function load($className) { |
| 60 | - if(count($this->registeredTransformers) < 1) { |
|
| 60 | + if (count($this->registeredTransformers) < 1) { |
|
| 61 | 61 | return FALSE; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - foreach($this->registeredTransformers as $name => $transformerCallable) { |
|
| 64 | + foreach ($this->registeredTransformers as $name => $transformerCallable) { |
|
| 65 | 65 | $transformerResult = call_user_func_array($transformerCallable, [$className]); |
| 66 | 66 | |
| 67 | - if($transformerResult !== FALSE && file_exists($transformerResult)) { |
|
| 67 | + if ($transformerResult !== FALSE && file_exists($transformerResult)) { |
|
| 68 | 68 | include_once $transformerResult; |
| 69 | 69 | |
| 70 | 70 | return TRUE; |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * @throws \BuildR\ClassLoader\Modules\Transformable\TransformableModuleException |
| 84 | 84 | */ |
| 85 | 85 | public function registerTransformer($name, callable $transformer) { |
| 86 | - if($this->transformerIsRegistered($name)) { |
|
| 86 | + if ($this->transformerIsRegistered($name)) { |
|
| 87 | 87 | throw TransformableModuleException::nameOccupied($name); |
| 88 | 88 | } |
| 89 | 89 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | * @return bool |
| 99 | 99 | */ |
| 100 | 100 | public function removeTransformer($name) { |
| 101 | - if($this->transformerIsRegistered($name)) { |
|
| 101 | + if ($this->transformerIsRegistered($name)) { |
|
| 102 | 102 | unset($this->registeredTransformers[$name]); |
| 103 | 103 | |
| 104 | 104 | return TRUE; |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | public function preLoad($moduleClassName) { |
| 34 | 34 | $interfaces = class_implements($moduleClassName); |
| 35 | 35 | |
| 36 | - if(!in_array(ClassLoaderModuleInterface::class, $interfaces)) { |
|
| 36 | + if (!in_array(ClassLoaderModuleInterface::class, $interfaces)) { |
|
| 37 | 37 | throw ModuleException::invalid($moduleClassName); |
| 38 | 38 | } |
| 39 | 39 | |
@@ -27,10 +27,10 @@ discard block |
||
| 27 | 27 | * @type array |
| 28 | 28 | */ |
| 29 | 29 | protected static $files = [ |
| 30 | - 'Modules' . DIRECTORY_SEPARATOR . 'ClassLoaderModuleInterface.php', |
|
| 31 | - 'Modules' . DIRECTORY_SEPARATOR . 'AbstractClassLoaderModule.php', |
|
| 32 | - 'Exception' . DIRECTORY_SEPARATOR . 'ModuleException.php', |
|
| 33 | - 'Exception' . DIRECTORY_SEPARATOR . 'ClassLoaderException.php', |
|
| 30 | + 'Modules'.DIRECTORY_SEPARATOR.'ClassLoaderModuleInterface.php', |
|
| 31 | + 'Modules'.DIRECTORY_SEPARATOR.'AbstractClassLoaderModule.php', |
|
| 32 | + 'Exception'.DIRECTORY_SEPARATOR.'ModuleException.php', |
|
| 33 | + 'Exception'.DIRECTORY_SEPARATOR.'ClassLoaderException.php', |
|
| 34 | 34 | 'ModuleLoader.php', |
| 35 | 35 | 'ClassLoader.php', |
| 36 | 36 | ]; |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @param $additionalFile |
| 42 | 42 | */ |
| 43 | 43 | public function extend($additionalFile) { |
| 44 | - if($this->isLoaded === TRUE) { |
|
| 44 | + if ($this->isLoaded === TRUE) { |
|
| 45 | 45 | trigger_error('The initializer is loaded, so you cannot extend a loaded initializer!', E_USER_NOTICE); |
| 46 | 46 | } |
| 47 | 47 | |
@@ -72,15 +72,15 @@ discard block |
||
| 72 | 72 | * @return void |
| 73 | 73 | */ |
| 74 | 74 | public function load() { |
| 75 | - if($this->isLoaded === TRUE) { |
|
| 75 | + if ($this->isLoaded === TRUE) { |
|
| 76 | 76 | trigger_error("Unable to load ClassLoader because its already loaded!", E_USER_NOTICE); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - $rootDir = __DIR__ . DIRECTORY_SEPARATOR; |
|
| 79 | + $rootDir = __DIR__.DIRECTORY_SEPARATOR; |
|
| 80 | 80 | ksort(self::$files); |
| 81 | 81 | |
| 82 | - foreach(self::$files as $priority => $file) { |
|
| 83 | - $fileAbsolute = $rootDir . $file; |
|
| 82 | + foreach (self::$files as $priority => $file) { |
|
| 83 | + $fileAbsolute = $rootDir.$file; |
|
| 84 | 84 | |
| 85 | 85 | include_once $fileAbsolute; |
| 86 | 86 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | /** @type \BuildR\ClassLoader\Modules\ClassLoaderModuleInterface $module */ |
| 86 | 86 | $module = $this->moduleLoader->preLoad($moduleClassName); |
| 87 | 87 | |
| 88 | - if($priorityOverride !== NULL) { |
|
| 88 | + if ($priorityOverride !== NULL) { |
|
| 89 | 89 | $module->setPriority($priorityOverride); |
| 90 | 90 | } |
| 91 | 91 | |
@@ -105,12 +105,12 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | public function getModule($moduleName, $priority) { |
| 107 | 107 | foreach ($this->modules as $modulePriority => $module) { |
| 108 | - if(call_user_func([$module, 'getName']) === $moduleName && $modulePriority == $priority) { |
|
| 108 | + if (call_user_func([$module, 'getName']) === $moduleName && $modulePriority == $priority) { |
|
| 109 | 109 | return $module; |
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - throw ModuleException::notFound('Name: ' . $moduleName); |
|
| 113 | + throw ModuleException::notFound('Name: '.$moduleName); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | public function removeModule($moduleName, $priority) { |
| 128 | 128 | foreach ($this->modules as $modulePriority => $module) { |
| 129 | - if(call_user_func([$module, 'getName']) === $moduleName && $modulePriority == $priority) { |
|
| 129 | + if (call_user_func([$module, 'getName']) === $moduleName && $modulePriority == $priority) { |
|
| 130 | 130 | unset($this->modules[$priority]); |
| 131 | 131 | ksort($this->modules); |
| 132 | 132 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - throw ModuleException::notFound('Name: ' . $moduleName . ' Priority: ' . $priority); |
|
| 137 | + throw ModuleException::notFound('Name: '.$moduleName.' Priority: '.$priority); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | protected function registerModule(ClassLoaderModuleInterface $module) { |
| 160 | 160 | $priority = $module->getPriority(); |
| 161 | 161 | |
| 162 | - if(!isset($this->modules[$priority])) { |
|
| 162 | + if (!isset($this->modules[$priority])) { |
|
| 163 | 163 | $this->modules[$priority] = $module; |
| 164 | 164 | $this->priorityIncreaseCounter = 0; |
| 165 | 165 | ksort($this->modules); |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | return $module; |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - if($this->priorityIncreaseCounter >= self::PRIORITY_INCREASE_RETRY_COUNT) { |
|
| 171 | + if ($this->priorityIncreaseCounter >= self::PRIORITY_INCREASE_RETRY_COUNT) { |
|
| 172 | 172 | $this->priorityIncreaseCounter = 0; |
| 173 | 173 | throw ClassLoaderException::priorityIncreaseLimit(); |
| 174 | 174 | } |
@@ -193,8 +193,8 @@ discard block |
||
| 193 | 193 | * @return bool |
| 194 | 194 | */ |
| 195 | 195 | public function loadClass($className) { |
| 196 | - foreach($this->modules as $loader) { |
|
| 197 | - if($loader->load($className) === TRUE) { |
|
| 196 | + foreach ($this->modules as $loader) { |
|
| 197 | + if ($loader->load($className) === TRUE) { |
|
| 198 | 198 | return TRUE; |
| 199 | 199 | } |
| 200 | 200 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * @inheritDoc |
| 57 | 57 | */ |
| 58 | 58 | public function load($className) { |
| 59 | - if(count($this->registeredNamespaces) < 1) { |
|
| 59 | + if (count($this->registeredNamespaces) < 1) { |
|
| 60 | 60 | return FALSE; |
| 61 | 61 | } |
| 62 | 62 | |
@@ -65,14 +65,14 @@ discard block |
||
| 65 | 65 | $basePath = $singleNamespace[1]; |
| 66 | 66 | |
| 67 | 67 | $prefixLength = strlen($prefix); |
| 68 | - if(strncmp($prefix, $className, $prefixLength) !== 0) { |
|
| 68 | + if (strncmp($prefix, $className, $prefixLength) !== 0) { |
|
| 69 | 69 | continue; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | $relativeClassName = substr($className, $prefixLength); |
| 73 | - $fileLocation = $basePath . str_replace('\\', DIRECTORY_SEPARATOR, $relativeClassName) . '.php'; |
|
| 73 | + $fileLocation = $basePath.str_replace('\\', DIRECTORY_SEPARATOR, $relativeClassName).'.php'; |
|
| 74 | 74 | |
| 75 | - if(file_exists($fileLocation)) { |
|
| 75 | + if (file_exists($fileLocation)) { |
|
| 76 | 76 | include_once $fileLocation; |
| 77 | 77 | |
| 78 | 78 | return TRUE; |
@@ -91,13 +91,13 @@ discard block |
||
| 91 | 91 | * @throws \BuildR\ClassLoader\Modules\PSR4\PSR4ModuleException |
| 92 | 92 | */ |
| 93 | 93 | public function registerNamespace($namespace, $basePath) { |
| 94 | - if($this->namespaceIsRegistered($namespace)) { |
|
| 94 | + if ($this->namespaceIsRegistered($namespace)) { |
|
| 95 | 95 | throw PSR4ModuleException::namespaceOccupied($namespace); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | $this->registeredNamespaces[] = [ |
| 99 | 99 | $namespace, |
| 100 | - realpath($basePath) . DIRECTORY_SEPARATOR |
|
| 100 | + realpath($basePath).DIRECTORY_SEPARATOR |
|
| 101 | 101 | ]; |
| 102 | 102 | } |
| 103 | 103 | |
@@ -107,8 +107,8 @@ discard block |
||
| 107 | 107 | * @param string $namespace The namespace name |
| 108 | 108 | */ |
| 109 | 109 | public function unRegisterNamespace($namespace) { |
| 110 | - foreach($this->registeredNamespaces as $key => $registeredNamespace) { |
|
| 111 | - if($registeredNamespace[0] == $namespace) { |
|
| 110 | + foreach ($this->registeredNamespaces as $key => $registeredNamespace) { |
|
| 111 | + if ($registeredNamespace[0] == $namespace) { |
|
| 112 | 112 | unset($this->registeredNamespaces[$key]); |
| 113 | 113 | } |
| 114 | 114 | } |
@@ -122,8 +122,8 @@ discard block |
||
| 122 | 122 | * @return bool |
| 123 | 123 | */ |
| 124 | 124 | public function namespaceIsRegistered($namespace) { |
| 125 | - foreach($this->registeredNamespaces as $key => $registeredNamespace) { |
|
| 126 | - if($registeredNamespace[0] == $namespace) { |
|
| 125 | + foreach ($this->registeredNamespaces as $key => $registeredNamespace) { |
|
| 126 | + if ($registeredNamespace[0] == $namespace) { |
|
| 127 | 127 | return TRUE; |
| 128 | 128 | } |
| 129 | 129 | } |
@@ -54,22 +54,22 @@ discard block |
||
| 54 | 54 | * @inheritDoc |
| 55 | 55 | */ |
| 56 | 56 | public function load($className) { |
| 57 | - if(count($this->registeredPrefixes) < 1) { |
|
| 57 | + if (count($this->registeredPrefixes) < 1) { |
|
| 58 | 58 | return FALSE; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - foreach($this->registeredPrefixes as $singlePrefix) { |
|
| 61 | + foreach ($this->registeredPrefixes as $singlePrefix) { |
|
| 62 | 62 | $prefix = $singlePrefix[0]; |
| 63 | 63 | $basePath = $singlePrefix[1]; |
| 64 | 64 | |
| 65 | 65 | $pos = strpos($className, $prefix); |
| 66 | - if($pos === FALSE || $pos > 0) { |
|
| 66 | + if ($pos === FALSE || $pos > 0) { |
|
| 67 | 67 | continue; |
| 68 | 68 | } |
| 69 | 69 | $pathNamespace = ltrim(substr($className, strlen($prefix)), '_'); |
| 70 | - $file = $basePath . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $pathNamespace) . '.php'; |
|
| 70 | + $file = $basePath.DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $pathNamespace).'.php'; |
|
| 71 | 71 | |
| 72 | - if(file_exists($file)) { |
|
| 72 | + if (file_exists($file)) { |
|
| 73 | 73 | include_once $file; |
| 74 | 74 | |
| 75 | 75 | return TRUE; |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * @throws \BuildR\ClassLoader\Modules\PEAR\PEARModuleException |
| 89 | 89 | */ |
| 90 | 90 | public function registerPrefix($prefix, $basePath) { |
| 91 | - if($this->prefixIsRegistered($prefix)) { |
|
| 91 | + if ($this->prefixIsRegistered($prefix)) { |
|
| 92 | 92 | throw PEARModuleException::prefixOccupied($prefix); |
| 93 | 93 | } |
| 94 | 94 | |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | * @param string $prefix The prefix name |
| 105 | 105 | */ |
| 106 | 106 | public function unRegisterPrefix($prefix) { |
| 107 | - foreach($this->registeredPrefixes as $key => $registeredPrefix) { |
|
| 108 | - if($registeredPrefix[0] == $prefix) { |
|
| 107 | + foreach ($this->registeredPrefixes as $key => $registeredPrefix) { |
|
| 108 | + if ($registeredPrefix[0] == $prefix) { |
|
| 109 | 109 | unset($this->registeredPrefixes[$key]); |
| 110 | 110 | } |
| 111 | 111 | } |
@@ -119,8 +119,8 @@ discard block |
||
| 119 | 119 | * @return bool |
| 120 | 120 | */ |
| 121 | 121 | public function prefixIsRegistered($prefix) { |
| 122 | - foreach($this->registeredPrefixes as $key => $registeredPrefix) { |
|
| 123 | - if($registeredPrefix[0] == $prefix) { |
|
| 122 | + foreach ($this->registeredPrefixes as $key => $registeredPrefix) { |
|
| 123 | + if ($registeredPrefix[0] == $prefix) { |
|
| 124 | 124 | return TRUE; |
| 125 | 125 | } |
| 126 | 126 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @inheritDoc |
| 55 | 55 | */ |
| 56 | 56 | public function load($className) { |
| 57 | - if(count($this->registeredNamespaces) < 1) { |
|
| 57 | + if (count($this->registeredNamespaces) < 1) { |
|
| 58 | 58 | return FALSE; |
| 59 | 59 | } |
| 60 | 60 | |
@@ -64,23 +64,23 @@ discard block |
||
| 64 | 64 | $className = substr($className, $pos + 1); |
| 65 | 65 | |
| 66 | 66 | //Create the normalized class name |
| 67 | - $normalizedClass = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR; |
|
| 67 | + $normalizedClass = str_replace('\\', DIRECTORY_SEPARATOR, $namespace).DIRECTORY_SEPARATOR; |
|
| 68 | 68 | $normalizedClass .= str_replace('_', DIRECTORY_SEPARATOR, $className); |
| 69 | 69 | |
| 70 | 70 | //Loop through registered namespaces |
| 71 | - foreach($this->registeredNamespaces as $singleNamespace) { |
|
| 71 | + foreach ($this->registeredNamespaces as $singleNamespace) { |
|
| 72 | 72 | $prefix = str_replace('\\', DIRECTORY_SEPARATOR, $singleNamespace[0]); |
| 73 | 73 | $basePath = $singleNamespace[1]; |
| 74 | 74 | |
| 75 | 75 | $pos = stripos($normalizedClass, $prefix); |
| 76 | - if($pos === FALSE || $pos > 1) { |
|
| 76 | + if ($pos === FALSE || $pos > 1) { |
|
| 77 | 77 | continue; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | // build the full path |
| 81 | - $file = rtrim($basePath, '/') . DIRECTORY_SEPARATOR . ltrim($normalizedClass, '/') . '.php'; |
|
| 81 | + $file = rtrim($basePath, '/').DIRECTORY_SEPARATOR.ltrim($normalizedClass, '/').'.php'; |
|
| 82 | 82 | |
| 83 | - if(file_exists($file)) { |
|
| 83 | + if (file_exists($file)) { |
|
| 84 | 84 | include_once $file; |
| 85 | 85 | |
| 86 | 86 | return TRUE; |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * @throws \BuildR\ClassLoader\Modules\PSR0\PSR0ModuleException |
| 97 | 97 | */ |
| 98 | 98 | public function registerNamespace($namespace, $basePath) { |
| 99 | - if($this->namespaceIsRegistered($namespace)) { |
|
| 99 | + if ($this->namespaceIsRegistered($namespace)) { |
|
| 100 | 100 | throw PSR0ModuleException::namespaceOccupied($namespace); |
| 101 | 101 | } |
| 102 | 102 | |
@@ -112,8 +112,8 @@ discard block |
||
| 112 | 112 | * @param string $namespace The namespace name |
| 113 | 113 | */ |
| 114 | 114 | public function unRegisterNamespace($namespace) { |
| 115 | - foreach($this->registeredNamespaces as $key => $registeredNamespace) { |
|
| 116 | - if($registeredNamespace[0] == $namespace) { |
|
| 115 | + foreach ($this->registeredNamespaces as $key => $registeredNamespace) { |
|
| 116 | + if ($registeredNamespace[0] == $namespace) { |
|
| 117 | 117 | unset($this->registeredNamespaces[$key]); |
| 118 | 118 | } |
| 119 | 119 | } |
@@ -127,8 +127,8 @@ discard block |
||
| 127 | 127 | * @return bool |
| 128 | 128 | */ |
| 129 | 129 | public function namespaceIsRegistered($namespace) { |
| 130 | - foreach($this->registeredNamespaces as $key => $registeredNamespace) { |
|
| 131 | - if($registeredNamespace[0] == $namespace) { |
|
| 130 | + foreach ($this->registeredNamespaces as $key => $registeredNamespace) { |
|
| 131 | + if ($registeredNamespace[0] == $namespace) { |
|
| 132 | 132 | return TRUE; |
| 133 | 133 | } |
| 134 | 134 | } |