Passed
Push — master ( 48d931...92cc23 )
by Christian
01:59
created
wp-autoloader.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	 * @return void
99 99
 	 */
100 100
 	public function register() {
101
-		spl_autoload_register( array( $this, 'loadClass' ) );
101
+		spl_autoload_register(array($this, 'loadClass'));
102 102
 	}
103 103
 
104 104
 	/**
@@ -113,23 +113,23 @@  discard block
 block discarded – undo
113 113
 	 *
114 114
 	 * @return void
115 115
 	 */
116
-	public function addNamespace( $prefix, $base_dir, $prepend = false ) {
116
+	public function addNamespace($prefix, $base_dir, $prepend = false) {
117 117
 		// normalize namespace prefix
118
-		$prefix = trim( $prefix, '\\' ) . '\\';
118
+		$prefix = trim($prefix, '\\') . '\\';
119 119
 
120 120
 		// normalize the base directory with a trailing separator
121
-		$base_dir = rtrim( $base_dir, DIRECTORY_SEPARATOR ) . '/';
121
+		$base_dir = rtrim($base_dir, DIRECTORY_SEPARATOR) . '/';
122 122
 
123 123
 		// initialize the namespace prefix array
124
-		if ( isset( $this->prefixes[ $prefix ] ) === false ) {
124
+		if (isset($this->prefixes[ $prefix ]) === false) {
125 125
 			$this->prefixes[ $prefix ] = array();
126 126
 		}
127 127
 
128 128
 		// retain the base directory for the namespace prefix
129
-		if ( $prepend ) {
130
-			array_unshift( $this->prefixes[ $prefix ], $base_dir );
129
+		if ($prepend) {
130
+			array_unshift($this->prefixes[ $prefix ], $base_dir);
131 131
 		} else {
132
-			array_push( $this->prefixes[ $prefix ], $base_dir );
132
+			array_push($this->prefixes[ $prefix ], $base_dir);
133 133
 		}
134 134
 	}
135 135
 
@@ -141,29 +141,29 @@  discard block
 block discarded – undo
141 141
 	 * @return mixed The mapped file name on success, or boolean false on
142 142
 	 * failure.
143 143
 	 */
144
-	public function loadClass( $class ) {
144
+	public function loadClass($class) {
145 145
 		// the current namespace prefix
146 146
 		$prefix = $class;
147 147
 
148 148
 		// work backwards through the namespace names of the fully-qualified
149 149
 		// class name to find a mapped file name
150
-		while ( false !== $pos = strrpos( $prefix, '\\' ) ) {
150
+		while (false !== $pos = strrpos($prefix, '\\')) {
151 151
 
152 152
 			// retain the trailing namespace separator in the prefix
153
-			$prefix = substr( $class, 0, $pos + 1 );
153
+			$prefix = substr($class, 0, $pos + 1);
154 154
 
155 155
 			// the rest is the relative class name
156
-			$relative_class = substr( $class, $pos + 1 );
156
+			$relative_class = substr($class, $pos + 1);
157 157
 
158 158
 			// try to load a mapped file for the prefix and relative class
159
-			$mapped_file = $this->loadMappedFile( $prefix, $relative_class );
160
-			if ( $mapped_file ) {
159
+			$mapped_file = $this->loadMappedFile($prefix, $relative_class);
160
+			if ($mapped_file) {
161 161
 				return $mapped_file;
162 162
 			}
163 163
 
164 164
 			// remove the trailing namespace separator for the next iteration
165 165
 			// of strrpos()
166
-			$prefix = rtrim( $prefix, '\\' );
166
+			$prefix = rtrim($prefix, '\\');
167 167
 		}
168 168
 
169 169
 		// never found a mapped file
@@ -179,22 +179,22 @@  discard block
 block discarded – undo
179 179
 	 * @return mixed Boolean false if no mapped file can be loaded, or the
180 180
 	 * name of the mapped file that was loaded.
181 181
 	 */
182
-	protected function loadMappedFile( $prefix, $relative_class ) {
182
+	protected function loadMappedFile($prefix, $relative_class) {
183 183
 		// are there any base directories for this namespace prefix?
184
-		if ( isset( $this->prefixes[ $prefix ] ) === false ) {
184
+		if (isset($this->prefixes[ $prefix ]) === false) {
185 185
 			return false;
186 186
 		}
187 187
 
188 188
 		// look through base directories for this namespace prefix
189
-		foreach ( $this->prefixes[ $prefix ] as $base_dir ) {
189
+		foreach ($this->prefixes[ $prefix ] as $base_dir) {
190 190
 
191 191
 			// replace the namespace prefix with the base directory,
192 192
 			// replace namespace separators with directory separators
193 193
 			// in the relative class name, append with .php
194
-			$file = $base_dir . str_replace( '\\', '/', $relative_class ) . '.php';
194
+			$file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
195 195
 
196 196
 			// if the mapped file exists, require it
197
-			if ( $this->requireFile( $file ) ) {
197
+			if ($this->requireFile($file)) {
198 198
 				// yes, we're done
199 199
 				return $file;
200 200
 			}
@@ -211,8 +211,8 @@  discard block
 block discarded – undo
211 211
 	 *
212 212
 	 * @return bool True if the file exists, false if not.
213 213
 	 */
214
-	protected function requireFile( $file ) {
215
-		if ( file_exists( $file ) ) {
214
+	protected function requireFile($file) {
215
+		if (file_exists($file)) {
216 216
 			require $file;
217 217
 
218 218
 			return true;
Please login to merge, or discard this patch.