GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — develop (#141)
by Gwenaël
14:16 queued 08:27
created
build/build.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -49,20 +49,20 @@  discard block
 block discarded – undo
49 49
 ini_set('display_errors', 1);
50 50
 
51 51
 // Load our autoloader
52
-require __DIR__ .'/../vendor/autoload.php';
52
+require __DIR__.'/../vendor/autoload.php';
53 53
 
54 54
 // Load configuration
55 55
 require 'build_config.php';
56 56
 
57 57
 // Folder definitions
58
-define('BUILDBASE', __DIR__ .'/');
58
+define('BUILDBASE', __DIR__.'/');
59 59
 
60 60
 // Don't stop script exectuion on 404...
61 61
 function show_404($page = '', $log_error = TRUE) {}
62 62
 
63 63
 // Make sure we have access to CI() object.
64 64
 ob_start();
65
-	require( BUILDBASE .'../index.php' );
65
+	require(BUILDBASE.'../index.php');
66 66
 ob_end_clean();
67 67
 
68 68
 //--------------------------------------------------------------------
@@ -73,12 +73,12 @@  discard block
 block discarded – undo
73 73
 
74 74
 if (empty($release))
75 75
 {
76
-	$release = CLI::prompt("Which script", array_keys($config['builds']) );
76
+	$release = CLI::prompt("Which script", array_keys($config['builds']));
77 77
 }
78 78
 
79
-if (! array_key_exists($release, $config['builds']))
79
+if ( ! array_key_exists($release, $config['builds']))
80 80
 {
81
-	CLI::error('Invalid build specified: '. $release);
81
+	CLI::error('Invalid build specified: '.$release);
82 82
 	exit(1);
83 83
 }
84 84
 
@@ -89,20 +89,20 @@  discard block
 block discarded – undo
89 89
 $class_name = $config['builds'][$release];
90 90
 
91 91
 
92
-if (! file_exists(BUILDBASE ."scripts/{$class_name}.php"))
92
+if ( ! file_exists(BUILDBASE."scripts/{$class_name}.php"))
93 93
 {
94
-	CLI::error('Unable to find build script: '. $class_name .'.php');
94
+	CLI::error('Unable to find build script: '.$class_name.'.php');
95 95
 	exit(1);
96 96
 }
97 97
 
98
-require BUILDBASE ."lib/BaseBuilder.php";
99
-require BUILDBASE ."scripts/{$class_name}.php";
98
+require BUILDBASE."lib/BaseBuilder.php";
99
+require BUILDBASE."scripts/{$class_name}.php";
100 100
 
101
-$builder = new $class_name( $config['destinations'][$release], get_instance() );
101
+$builder = new $class_name($config['destinations'][$release], get_instance());
102 102
 
103
-if (! is_object($builder))
103
+if ( ! is_object($builder))
104 104
 {
105
-	CLI::error('Unable to make new class: '. $class_name);
105
+	CLI::error('Unable to make new class: '.$class_name);
106 106
 	exit(1);
107 107
 }
108 108
 
@@ -118,4 +118,4 @@  discard block
 block discarded – undo
118 118
 $end_time = microtime(true);
119 119
 $elapsed_time = number_format($end_time - $start_time, 4);
120 120
 
121
-CLI::write('Done in '. $elapsed_time .' seconds', 'green');
122 121
\ No newline at end of file
122
+CLI::write('Done in '.$elapsed_time.' seconds', 'green');
123 123
\ No newline at end of file
Please login to merge, or discard this patch.
build/lib/BaseBuilder.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -10,9 +10,9 @@  discard block
 block discarded – undo
10 10
 
11 11
 	//--------------------------------------------------------------------
12 12
 
13
-	public function __construct($ci=null)
13
+	public function __construct($ci = null)
14 14
 	{
15
-	    $this->ci =& $ci;
15
+	    $this->ci = & $ci;
16 16
 	}
17 17
 
18 18
 	//--------------------------------------------------------------------
@@ -30,16 +30,16 @@  discard block
 block discarded – undo
30 30
 
31 31
 		@$this->ensureFolder($destination);
32 32
 
33
-		while (false !== ( $file = readdir($dir)) )
33
+		while (false !== ($file = readdir($dir)))
34 34
 		{
35
-			if ( ! in_array($file, $this->ignore_files) )
35
+			if ( ! in_array($file, $this->ignore_files))
36 36
 			{
37
-				if ( is_dir($source .'/'. $file) )
37
+				if (is_dir($source.'/'.$file))
38 38
 				{
39
-					$this->copyFolder($source .'/'. $file, $destination .'/'. $file);
39
+					$this->copyFolder($source.'/'.$file, $destination.'/'.$file);
40 40
 				}
41 41
 				else {
42
-					copy($source .'/'. $file, $destination .'/'. $file);
42
+					copy($source.'/'.$file, $destination.'/'.$file);
43 43
 				}
44 44
 			}
45 45
 		}
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 * @param $path
75 75
 	 * @param array $leave_files
76 76
 	 */
77
-	public function cleanFolder($path, $leave_files=[])
77
+	public function cleanFolder($path, $leave_files = [])
78 78
 	{
79 79
 		foreach (glob("{$path}/*") as $file)
80 80
 		{
@@ -97,25 +97,25 @@  discard block
 block discarded – undo
97 97
 
98 98
 	//--------------------------------------------------------------------
99 99
 
100
-	public function compressFolder($source, $destination, $include_dir=false)
100
+	public function compressFolder($source, $destination, $include_dir = false)
101 101
 	{
102
-		if (! extension_loaded('zip') ) {
102
+		if ( ! extension_loaded('zip')) {
103 103
 			CLI::error('ZipArchive extension is required.');
104 104
 			exit(1);
105 105
 		}
106 106
 
107
-		if (! file_exists($source)) {
107
+		if ( ! file_exists($source)) {
108 108
 			CLI::error('Source folder not found for zipping.');
109 109
 			exit(1);
110 110
 		}
111 111
 
112 112
 		if (file_exists($destination))
113 113
 		{
114
-			unlink ($destination);
114
+			unlink($destination);
115 115
 		}
116 116
 
117 117
 		$zip = new ZipArchive();
118
-		if (! $zip->open($destination, ZIPARCHIVE::CREATE))
118
+		if ( ! $zip->open($destination, ZIPARCHIVE::CREATE))
119 119
 		{
120 120
 			CLI::error('Unknown error opening zip file.');
121 121
 			exit(1);
@@ -129,12 +129,12 @@  discard block
 block discarded – undo
129 129
 
130 130
 			if ($include_dir) {
131 131
 
132
-				$arr = explode("/",$source);
133
-				$maindir = $arr[count($arr)- 1];
132
+				$arr = explode("/", $source);
133
+				$maindir = $arr[count($arr) - 1];
134 134
 
135 135
 				$source = "";
136
-				for ($i=0; $i < count($arr) - 1; $i++) {
137
-					$source .= '/' . $arr[$i];
136
+				for ($i = 0; $i < count($arr) - 1; $i++) {
137
+					$source .= '/'.$arr[$i];
138 138
 				}
139 139
 
140 140
 				$source = substr($source, 1);
@@ -147,18 +147,18 @@  discard block
 block discarded – undo
147 147
 				$file = str_replace('\\', '/', $file);
148 148
 
149 149
 				// Ignore "." and ".." folders
150
-				if( in_array(substr($file, strrpos($file, '/')+1), array('.', '..', '.DS_Store')) )
150
+				if (in_array(substr($file, strrpos($file, '/') + 1), array('.', '..', '.DS_Store')))
151 151
 					continue;
152 152
 
153 153
 				$file = realpath($file);
154 154
 
155 155
 				if (is_dir($file) === true)
156 156
 				{
157
-					$zip->addEmptyDir(str_replace($source . '/', '', $file . '/'));
157
+					$zip->addEmptyDir(str_replace($source.'/', '', $file.'/'));
158 158
 				}
159 159
 				else if (is_file($file) === true)
160 160
 				{
161
-					$zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file));
161
+					$zip->addFromString(str_replace($source.'/', '', $file), file_get_contents($file));
162 162
 				}
163 163
 			}
164 164
 		}
Please login to merge, or discard this patch.
build/scripts/InitialCleanup.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -16,11 +16,11 @@  discard block
 block discarded – undo
16 16
 
17 17
 	protected $ignore_files = ['.', '..', '.git', 'vendor', '.idea', '.travis.yml', 'build'];
18 18
 
19
-	public function __construct($destination, $ci=null)
19
+	public function __construct($destination, $ci = null)
20 20
 	{
21 21
 		parent::__construct($ci);
22 22
 
23
-	    $this->source_path = realpath(BUILDBASE .'../');
23
+	    $this->source_path = realpath(BUILDBASE.'../');
24 24
 
25 25
 		if (empty($this->source_path))
26 26
 		{
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		$this->cleanTestsFolder();
47 47
 
48 48
 		CLI::write("\tRemoving application modules...");
49
-		$this->cleanFolder($this->dest_path .'/application/modules', ['index.html', '.htaccess']);
49
+		$this->cleanFolder($this->dest_path.'/application/modules', ['index.html', '.htaccess']);
50 50
 
51 51
 		CLI::write("\tGenerating default encryption key for config file...");
52 52
 		$this->generateEncryptionKey();
@@ -61,10 +61,10 @@  discard block
 block discarded – undo
61 61
 	private function cleanTempFiles()
62 62
 	{
63 63
 		// Remove Log Files
64
-		$this->cleanFolder($this->dest_path .'/application/logs', ['index.html', '.htaccess']);
64
+		$this->cleanFolder($this->dest_path.'/application/logs', ['index.html', '.htaccess']);
65 65
 
66 66
 		// Cache Files
67
-		$this->cleanFolder($this->dest_path .'/application/cache', ['index.html', '.htaccess']);
67
+		$this->cleanFolder($this->dest_path.'/application/cache', ['index.html', '.htaccess']);
68 68
 	}
69 69
 
70 70
 	//--------------------------------------------------------------------
@@ -72,15 +72,15 @@  discard block
 block discarded – undo
72 72
 	public function cleanTestsFolder()
73 73
 	{
74 74
 		// Remove coverage Files
75
-		$this->cleanFolder($this->dest_path .'/tests/_output', ['.gitignore']);
75
+		$this->cleanFolder($this->dest_path.'/tests/_output', ['.gitignore']);
76 76
 
77 77
 		// Remove our Acceptance tests
78
-		$this->cleanFolder($this->dest_path .'/tests/acceptance/myth');
79
-		rmdir($this->dest_path .'/tests/acceptance/myth');
78
+		$this->cleanFolder($this->dest_path.'/tests/acceptance/myth');
79
+		rmdir($this->dest_path.'/tests/acceptance/myth');
80 80
 
81 81
 		// Remove our Unit tests
82
-		$this->cleanFolder($this->dest_path .'/tests/unit/myth');
83
-		rmdir($this->dest_path .'/tests/unit/myth');
82
+		$this->cleanFolder($this->dest_path.'/tests/unit/myth');
83
+		rmdir($this->dest_path.'/tests/unit/myth');
84 84
 	}
85 85
 
86 86
 	//--------------------------------------------------------------------
@@ -94,13 +94,13 @@  discard block
 block discarded – undo
94 94
 		$length = 16;
95 95
 
96 96
 		$this->ci->load->library('Encryption');
97
-		$key = bin2hex( $this->ci->encryption->create_key( $length ) );
97
+		$key = bin2hex($this->ci->encryption->create_key($length));
98 98
 
99 99
 		$replace = "hex2bin( '$key' )";
100 100
 
101 101
 		$kit = new FileKit();
102 102
 
103
-		$kit->replaceIn(BUILDBASE .'../application/config/config.php', "'PLEASE_CHANGE_ME!'", $replace);
103
+		$kit->replaceIn(BUILDBASE.'../application/config/config.php', "'PLEASE_CHANGE_ME!'", $replace);
104 104
 	}
105 105
 
106 106
 	//--------------------------------------------------------------------
Please login to merge, or discard this patch.
build/scripts/SprintRelease.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 
18 18
 	public function __construct($destination)
19 19
 	{
20
-	    $this->source_path = realpath(BUILDBASE .'../');
20
+	    $this->source_path = realpath(BUILDBASE.'../');
21 21
 
22 22
 		if (empty($this->source_path))
23 23
 		{
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
 			exit(1);
26 26
 		}
27 27
 
28
-		$this->dest_path = BUILDBASE . $destination;
29
-		$this->dest_path = rtrim($this->dest_path, '/ ') .'/'. date('Y-m-d');
28
+		$this->dest_path = BUILDBASE.$destination;
29
+		$this->dest_path = rtrim($this->dest_path, '/ ').'/'.date('Y-m-d');
30 30
 	}
31 31
 
32 32
 	//--------------------------------------------------------------------
@@ -51,10 +51,10 @@  discard block
 block discarded – undo
51 51
 		$this->cleanTestsFolder();
52 52
 
53 53
 		CLI::write("\tRemoving application modules...");
54
-		$this->cleanFolder($this->dest_path .'/application/modules', ['index.html', '.htaccess']);
54
+		$this->cleanFolder($this->dest_path.'/application/modules', ['index.html', '.htaccess']);
55 55
 
56 56
 		CLI::write("\tCompressing files...");
57
-		$this->compressFolder($this->dest_path, $this->dest_path .'/Sprint_'. date('Y-m-d') .'.zip');
57
+		$this->compressFolder($this->dest_path, $this->dest_path.'/Sprint_'.date('Y-m-d').'.zip');
58 58
 	}
59 59
 
60 60
 	//--------------------------------------------------------------------
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
 	private function cleanTempFiles()
67 67
 	{
68 68
 		// Remove Log Files
69
-		$this->cleanFolder($this->dest_path .'/application/logs', ['index.html', '.htaccess']);
69
+		$this->cleanFolder($this->dest_path.'/application/logs', ['index.html', '.htaccess']);
70 70
 
71 71
 		// Cache Files
72
-		$this->cleanFolder($this->dest_path .'/application/cache', ['index.html', '.htaccess']);
72
+		$this->cleanFolder($this->dest_path.'/application/cache', ['index.html', '.htaccess']);
73 73
 	}
74 74
 
75 75
 	//--------------------------------------------------------------------
@@ -77,15 +77,15 @@  discard block
 block discarded – undo
77 77
 	public function cleanTestsFolder()
78 78
 	{
79 79
 		// Remove coverage Files
80
-		$this->cleanFolder($this->dest_path .'/tests/_output', ['.gitignore']);
80
+		$this->cleanFolder($this->dest_path.'/tests/_output', ['.gitignore']);
81 81
 
82 82
 		// Remove our Acceptance tests
83
-		$this->cleanFolder($this->dest_path .'/tests/acceptance/myth');
84
-		rmdir($this->dest_path .'/tests/acceptance/myth');
83
+		$this->cleanFolder($this->dest_path.'/tests/acceptance/myth');
84
+		rmdir($this->dest_path.'/tests/acceptance/myth');
85 85
 
86 86
 		// Remove our Unit tests
87
-		$this->cleanFolder($this->dest_path .'/tests/unit/myth');
88
-		rmdir($this->dest_path .'/tests/unit/myth');
87
+		$this->cleanFolder($this->dest_path.'/tests/unit/myth');
88
+		rmdir($this->dest_path.'/tests/unit/myth');
89 89
 	}
90 90
 
91 91
 	//--------------------------------------------------------------------
Please login to merge, or discard this patch.
index.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -268,7 +268,7 @@
 block discarded – undo
268 268
 	define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));
269 269
 
270 270
     // Path to the myth folder
271
-    define('MYTHPATH', rtrim( str_replace('\\', '/', $myth_folder), '/ ') .'/' );
271
+    define('MYTHPATH', rtrim(str_replace('\\', '/', $myth_folder), '/ ').'/');
272 272
 
273 273
 	// The path to the "application" folder
274 274
 	if (is_dir($application_folder))
Please login to merge, or discard this patch.
myth/Api/Auth/APIAuthentication.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 
42 42
 	//--------------------------------------------------------------------
43 43
 
44
-	public function __construct($ci=null)
44
+	public function __construct($ci = null)
45 45
 	{
46 46
 		parent::__construct($ci);
47 47
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 		// so request authorization by the client.
108 108
 		if (empty($username) || empty($password))
109 109
 		{
110
-			$this->ci->output->set_header('WWW-Authenticate: Basic realm="'. config_item('api.realm') .'"');
110
+			$this->ci->output->set_header('WWW-Authenticate: Basic realm="'.config_item('api.realm').'"');
111 111
 			return false;
112 112
 		}
113 113
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 		// No digest string? Then you're done. Go home.
158 158
 		if (empty($digest_string))
159 159
 		{
160
-			$this->ci->output->set_header( sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque) );
160
+			$this->ci->output->set_header(sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque));
161 161
 			return false;
162 162
 		}
163 163
 
@@ -167,18 +167,18 @@  discard block
 block discarded – undo
167 167
 		preg_match_all('@(username|nonce|uri|nc|cnonce|qop|response)=[\'"]?([^\'",]+)@', $digest_string, $matches);
168 168
 		$digest = (empty($matches[1]) || empty($matches[2])) ? array() : array_combine($matches[1], $matches[2]);
169 169
 
170
-		if (! array_key_exists('username', $digest))
170
+		if ( ! array_key_exists('username', $digest))
171 171
 		{
172
-			$this->ci->output->set_header( sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque) );
172
+			$this->ci->output->set_header(sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque));
173 173
 			return false;
174 174
 		}
175 175
 
176 176
 		// Grab the user that corresponds to that "username"
177 177
 		// exact field determined in the api config file - api.auth_field setting.
178
-		$user = $this->user_model->as_array()->find_by( config_item('api.auth_field'), $digest['username'] );
179
-		if (!  $user)
178
+		$user = $this->user_model->as_array()->find_by(config_item('api.auth_field'), $digest['username']);
179
+		if ( ! $user)
180 180
 		{
181
-			$this->ci->output->set_header( sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque) );
181
+			$this->ci->output->set_header(sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque));
182 182
 			return false;
183 183
 		}
184 184
 
@@ -187,16 +187,16 @@  discard block
 block discarded – undo
187 187
 
188 188
 		if ($digest['qop'] == 'auth')
189 189
 		{
190
-			$A2 = md5( strtoupper( $_SERVER['REQUEST_METHOD'] ) .':'. $digest['uri'] );
190
+			$A2 = md5(strtoupper($_SERVER['REQUEST_METHOD']).':'.$digest['uri']);
191 191
 		} else {
192 192
 			$body = file_get_contents('php://input');
193
-			$A2 = md5( strtoupper( $_SERVER['REQUEST_METHOD'] ) .':'. $digest['uri'] .':'. md5($body) );
193
+			$A2 = md5(strtoupper($_SERVER['REQUEST_METHOD']).':'.$digest['uri'].':'.md5($body));
194 194
 		}
195
-		$valid_response = md5($A1 .':'. $digest['nonce'].':'. $digest['nc'] .':'. $digest['cnonce'] .':'. $digest['qop'] .':'. $A2);
195
+		$valid_response = md5($A1.':'.$digest['nonce'].':'.$digest['nc'].':'.$digest['cnonce'].':'.$digest['qop'].':'.$A2);
196 196
 
197 197
 		if ($digest['response'] != $valid_response)
198 198
 		{
199
-			$this->ci->output->set_header( sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque) );
199
+			$this->ci->output->set_header(sprintf('WWW-Authenticate: Digest realm="%s", nonce="%s", opaque="%s"', config_item('api.realm'), $nonce, $opaque));
200 200
 			return false;
201 201
 		}
202 202
 
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 				break;
234 234
 		}
235 235
 
236
-		if (! $user)
236
+		if ( ! $user)
237 237
 		{
238 238
 			$this->user = null;
239 239
 			return $user;
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 
247 247
 		// If throttling time is above zero, we can't allow
248 248
 		// logins now.
249
-		if ($time = (int)$this->isThrottled($user['email']) > 0)
249
+		if ($time = (int) $this->isThrottled($user['email']) > 0)
250 250
 		{
251 251
 			$this->error = sprintf(lang('api.throttled'), $time);
252 252
 			return false;
@@ -274,13 +274,13 @@  discard block
 block discarded – undo
274 274
 	{
275 275
 	    $blacklist = explode(',', config_item('api.ip_blacklist'));
276 276
 
277
-		array_walk($blacklist, function (&$item, $key) {
277
+		array_walk($blacklist, function(&$item, $key) {
278 278
 			$item = trim($item);
279 279
 		});
280 280
 
281 281
 		if (in_array($this->ci->input->ip_address(), $blacklist))
282 282
 		{
283
-			throw new \Exception( lang('api.ip_denied'), 401);
283
+			throw new \Exception(lang('api.ip_denied'), 401);
284 284
 		}
285 285
 
286 286
 		return true;
@@ -299,13 +299,13 @@  discard block
 block discarded – undo
299 299
 
300 300
 		array_push($whitelist, '127.0.0.1', '0.0.0.0');
301 301
 
302
-		array_walk($whitelist, function (&$item, $key) {
302
+		array_walk($whitelist, function(&$item, $key) {
303 303
 			$item = trim($item);
304 304
 		});
305 305
 
306
-		if (! in_array($this->ci->input->ip_address(), $whitelist))
306
+		if ( ! in_array($this->ci->input->ip_address(), $whitelist))
307 307
 		{
308
-			throw new \Exception( lang('api.ip_denied'), 401);
308
+			throw new \Exception(lang('api.ip_denied'), 401);
309 309
 		}
310 310
 
311 311
 		return true;
@@ -362,9 +362,9 @@  discard block
 block discarded – undo
362 362
 	 *
363 363
 	 * @return bool|mixed|void
364 364
 	 */
365
-	public function login($credentials, $remember=false)
365
+	public function login($credentials, $remember = false)
366 366
 	{
367
-		throw new \BadMethodCallException( lang('api.unused_method') );
367
+		throw new \BadMethodCallException(lang('api.unused_method'));
368 368
 	}
369 369
 
370 370
 	//--------------------------------------------------------------------
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 	 */
380 380
 	public function logout()
381 381
 	{
382
-		throw new \BadMethodCallException( lang('api.unused_method') );
382
+		throw new \BadMethodCallException(lang('api.unused_method'));
383 383
 	}
384 384
 
385 385
 	//--------------------------------------------------------------------
Please login to merge, or discard this patch.
myth/Api/Server/ApiController.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 		$this->request->lang    = $this->detectLanguage();
215 215
 
216 216
 		// Load our language, requested.
217
-		if (! empty($this->request->lang))
217
+		if ( ! empty($this->request->lang))
218 218
 		{
219 219
 			$file = ! empty($this->language_file) ? $this->language_file : 'application';
220 220
 
@@ -233,20 +233,20 @@  discard block
 block discarded – undo
233 233
 		$this->config->load('api');
234 234
 
235 235
 		// Gather config defaults when a value isn't set for this controller
236
-		if ( empty($this->enable_logging) ) $this->enable_logging = config_item('api.enable_logging');
237
-		if ( empty($this->enable_rate_limits) ) $this->enable_rate_limits = config_item('api.enable_rate_limits');
238
-		if ( empty($this->rate_limits) ) $this->rate_limits = config_item('api.rate_limits');
236
+		if (empty($this->enable_logging)) $this->enable_logging = config_item('api.enable_logging');
237
+		if (empty($this->enable_rate_limits)) $this->enable_rate_limits = config_item('api.enable_rate_limits');
238
+		if (empty($this->rate_limits)) $this->rate_limits = config_item('api.rate_limits');
239 239
 
240 240
 		// Should we restrict to SSL requests?
241 241
 		if (config_item('api.require_ssl') === true && ! $this->request->ssl)
242 242
 		{
243
-			$this->failForbidden( lang('api.ssl_required') );
243
+			$this->failForbidden(lang('api.ssl_required'));
244 244
 		}
245 245
 
246 246
 		// Should we restrict to only allow AJAX requests?
247
-		if (config_item('api.ajax_only') === true && ! $this->input->is_ajax_request() )
247
+		if (config_item('api.ajax_only') === true && ! $this->input->is_ajax_request())
248 248
 		{
249
-			$this->failForbidden( lang('api.ajax_required') );
249
+			$this->failForbidden(lang('api.ajax_required'));
250 250
 		}
251 251
 
252 252
 		$this->detectPage();
@@ -258,17 +258,17 @@  discard block
 block discarded – undo
258 258
 			// in a single codebase.
259 259
 			get_instance()->config->set_item('api.authenticate_lib', $this->authenticate_class);
260 260
 
261
-			if (! $this->restrict(null, true) )
261
+			if ( ! $this->restrict(null, true))
262 262
 			{
263 263
 				$this->logTime();
264
-				$this->failUnauthorized( lang('api.unauthorized') );
264
+				$this->failUnauthorized(lang('api.unauthorized'));
265 265
 			}
266 266
 		}
267 267
 
268 268
 		// Has the user hit rate limits for this hour?
269 269
 		if ($this->enable_rate_limits && ! $this->isWithinLimits())
270 270
 		{
271
-			$this->failTooManyRequests( sprintf( lang('api.too_many_requests'), $this->rate_limits) );
271
+			$this->failTooManyRequests(sprintf(lang('api.too_many_requests'), $this->rate_limits));
272 272
 		}
273 273
 
274 274
 		// NEVER allow profiling via API.
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 		}
303 303
 		else
304 304
 		{
305
-			return $this->fail( lang('api.unknown_endpoint'), 'not_implemented');
305
+			return $this->fail(lang('api.unknown_endpoint'), 'not_implemented');
306 306
 		}
307 307
 	}
308 308
 
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 	 *
324 324
 	 * @return mixed
325 325
 	 */
326
-	public function respond ($data = null, $status_code = 200)
326
+	public function respond($data = null, $status_code = 200)
327 327
 	{
328 328
 		// If data is null and not code provide, error and bail
329 329
 		if ($data === null && $status_code === null)
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 
350 350
 		set_status_header($status_code);
351 351
 
352
-		header('Content-Length: ' . strlen($output));
352
+		header('Content-Length: '.strlen($output));
353 353
 
354 354
 		exit($output);
355 355
 	}
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 	 *
367 367
 	 * @return mixed
368 368
 	 */
369
-	protected function fail ($description, $status_code, $error_code = 'invalid_request')
369
+	protected function fail($description, $status_code, $error_code = 'invalid_request')
370 370
 	{
371 371
 		if (is_string($status_code))
372 372
 		{
@@ -577,26 +577,26 @@  discard block
 block discarded – undo
577 577
 
578 578
 		$params['page'] = ($this->page > 1 ? $this->page + 1 : 2);
579 579
 
580
-		if (! $clean_get)
580
+		if ( ! $clean_get)
581 581
 		{
582
-			if ( ! isset($_GET) || ! is_array($_GET) )
582
+			if ( ! isset($_GET) || ! is_array($_GET))
583 583
 			{
584 584
 				$_GET = [];
585 585
 			}
586 586
 
587
-			foreach ( $_GET as $key => $value )
587
+			foreach ($_GET as $key => $value)
588 588
 			{
589
-				$params[ $key ] = $value;
589
+				$params[$key] = $value;
590 590
 			}
591 591
 
592 592
 			// Ensure we get a correct per_page value
593
-			if (! array_key_exists('per_page', $params))
593
+			if ( ! array_key_exists('per_page', $params))
594 594
 			{
595 595
 				$params['per_page'] = $this->per_page;
596 596
 			}
597 597
 		}
598 598
 
599
-		return site_url($path) .'?'. http_build_query($params);
599
+		return site_url($path).'?'.http_build_query($params);
600 600
 	}
601 601
 
602 602
 	//--------------------------------------------------------------------
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
 	 *
618 618
 	 * @return string
619 619
 	 */
620
-	public function prevURL ($path, $clean_get = false)
620
+	public function prevURL($path, $clean_get = false)
621 621
 	{
622 622
 		// If paging is turned off, get out of here
623 623
 		if ($this->per_page == 0)
@@ -629,26 +629,26 @@  discard block
 block discarded – undo
629 629
 
630 630
 		$params['page'] = ($this->page > 1 ? $this->page - 1 : 1);
631 631
 
632
-		if (! $clean_get)
632
+		if ( ! $clean_get)
633 633
 		{
634
-			if ( ! isset($_GET) || ! is_array($_GET) )
634
+			if ( ! isset($_GET) || ! is_array($_GET))
635 635
 			{
636 636
 				$_GET = [];
637 637
 			}
638 638
 
639
-			foreach ( $_GET as $key => $value )
639
+			foreach ($_GET as $key => $value)
640 640
 			{
641 641
 				$params[$key] = $value;
642 642
 			}
643 643
 
644 644
 			// Ensure we get a correct per_page value
645
-			if (! array_key_exists('per_page', $params))
645
+			if ( ! array_key_exists('per_page', $params))
646 646
 			{
647 647
 				$params['per_page'] = $this->per_page;
648 648
 			}
649 649
 		}
650 650
 
651
-		return site_url($path) .'?'. http_build_query($params);
651
+		return site_url($path).'?'.http_build_query($params);
652 652
 	}
653 653
 
654 654
 	//--------------------------------------------------------------------
@@ -667,11 +667,11 @@  discard block
 block discarded – undo
667 667
 	protected function detectPage( )
668 668
 	{
669 669
 		// Is a per-page limit being set?
670
-		$this->per_page = isset($_GET['per_page']) ? (int)$_GET['per_page'] : $this->per_page;
670
+		$this->per_page = isset($_GET['per_page']) ? (int) $_GET['per_page'] : $this->per_page;
671 671
 
672
-		$page = (int)$this->input->get('page');
672
+		$page = (int) $this->input->get('page');
673 673
 
674
-		if (! $page || $page == 1)
674
+		if ( ! $page || $page == 1)
675 675
 		{
676 676
 			$offset = 0;
677 677
 		}
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
 
686 686
 		// If they've specifically passed in page=0, then we need
687 687
 		// to ignore paging...
688
-		if ((int)$this->input->get('page') === 0 && ! is_null($this->input->get('page')) )
688
+		if ((int) $this->input->get('page') === 0 && ! is_null($this->input->get('page')))
689 689
 		{
690 690
 			$this->per_page = 0;
691 691
 		}
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
 		$method = strtolower($this->input->server('REQUEST_METHOD'));
708 708
 
709 709
 		// If it's not an allowed method, let's default to a GET
710
-		if (! in_array($method, $this->allowed_http_methods))
710
+		if ( ! in_array($method, $this->allowed_http_methods))
711 711
 		{
712 712
 			$method = 'get';
713 713
 		}
@@ -782,14 +782,14 @@  discard block
 block discarded – undo
782 782
 	 */
783 783
 	public function detectFields()
784 784
 	{
785
-	    if (! array_key_exists('fields', $_GET))
785
+	    if ( ! array_key_exists('fields', $_GET))
786 786
 	    {
787 787
 		    return;
788 788
 	    }
789 789
 
790 790
 		$fields = explode(',', $_GET['fields']);
791 791
 
792
-		if (! is_array($fields))
792
+		if ( ! is_array($fields))
793 793
 		{
794 794
 			return;
795 795
 		}
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
 	 */
810 810
 	public function logTime()
811 811
 	{
812
-		if (! $this->enable_logging)
812
+		if ( ! $this->enable_logging)
813 813
 		{
814 814
 			return;
815 815
 		}
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
 			'duration' => microtime(true) - $this->start_time,
821 821
 			'user_id'  => $this->authenticate->id(),
822 822
 			'ip_address' => $this->input->ip_address(),
823
-			'request'  => $this->uri->uri_string() .'?'. $_SERVER['QUERY_STRING'],
823
+			'request'  => $this->uri->uri_string().'?'.$_SERVER['QUERY_STRING'],
824 824
 			'method'   => $this->request->method
825 825
 		];
826 826
 
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 	{
842 842
 		$model = new LogModel();
843 843
 
844
-		if ($model->requestsThisHourForUser( $this->authenticate->id() ) > $this->rate_limits)
844
+		if ($model->requestsThisHourForUser($this->authenticate->id()) > $this->rate_limits)
845 845
 		{
846 846
 			return false;
847 847
 		}
Please login to merge, or discard this patch.
myth/Api/Server/LogModel.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,11 +55,11 @@
 block discarded – undo
55 55
 		$time = date('Y-m-d H:00:00');
56 56
 
57 57
 		$query = $this->db->select('id')
58
-						  ->where('user_id', (int)$user_id)
58
+						  ->where('user_id', (int) $user_id)
59 59
 						  ->where('created_on >=', $time)
60 60
 						  ->get($this->table_name);
61 61
 
62
-		return (int)$query->num_rows();
62
+		return (int) $query->num_rows();
63 63
 	}
64 64
 
65 65
 	//--------------------------------------------------------------------
Please login to merge, or discard this patch.
myth/Auth/AuthTrait.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 *
57 57
 	 * @return bool
58 58
 	 */
59
-	public function restrict($uri=null, $return_only=false)
59
+	public function restrict($uri = null, $return_only = false)
60 60
 	{
61 61
 	    $this->setupAuthClasses();
62 62
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
 		if (method_exists($this, 'setMessage'))
69 69
 		{
70
-			$this->setMessage( lang('auth.not_logged_in') );
70
+			$this->setMessage(lang('auth.not_logged_in'));
71 71
 		}
72 72
 
73 73
 		if ($return_only)
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
 		if (empty($uri))
79 79
 		{
80
-			redirect( \Myth\Route::named('login') );
80
+			redirect(\Myth\Route::named('login'));
81 81
 		}
82 82
 
83 83
 		redirect($uri);
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
 	 *
107 107
 	 * @return bool
108 108
 	 */
109
-	public function restrictToGroups($groups, $uri='')
109
+	public function restrictToGroups($groups, $uri = '')
110 110
 	{
111 111
 	    $this->setupAuthClasses();
112 112
 
113 113
 		if ($this->authenticate->isLoggedIn())
114 114
 		{
115
-			if ($this->authorize->inGroup($groups, $this->authenticate->id() ) )
115
+			if ($this->authorize->inGroup($groups, $this->authenticate->id()))
116 116
 			{
117 117
 				return true;
118 118
 			}
@@ -120,15 +120,15 @@  discard block
 block discarded – undo
120 120
 
121 121
 		if (method_exists($this, 'setMessage'))
122 122
 		{
123
-			$this->setMessage( lang('auth.not_enough_privilege') );
123
+			$this->setMessage(lang('auth.not_enough_privilege'));
124 124
 		}
125 125
 
126 126
 		if (empty($uri))
127 127
 		{
128
-			redirect( \Myth\Route::named('login') .'?request_uri='. current_url() );
128
+			redirect(\Myth\Route::named('login').'?request_uri='.current_url());
129 129
 		}
130 130
 
131
-		redirect($uri .'?request_uri='. current_url());
131
+		redirect($uri.'?request_uri='.current_url());
132 132
 	}
133 133
 
134 134
 	//--------------------------------------------------------------------
@@ -147,13 +147,13 @@  discard block
 block discarded – undo
147 147
 	 *
148 148
 	 * @return bool
149 149
 	 */
150
-	public function restrictWithPermissions($permissions, $uri='')
150
+	public function restrictWithPermissions($permissions, $uri = '')
151 151
 	{
152 152
 	    $this->setupAuthClasses();
153 153
 
154 154
 		if ($this->authenticate->isLoggedIn())
155 155
 		{
156
-			if ($this->authorize->hasPermission($permissions, $this->authenticate->id() ) )
156
+			if ($this->authorize->hasPermission($permissions, $this->authenticate->id()))
157 157
 			{
158 158
 				return true;
159 159
 			}
@@ -161,15 +161,15 @@  discard block
 block discarded – undo
161 161
 
162 162
 		if (method_exists($this, 'setMessage'))
163 163
 		{
164
-			$this->setMessage( lang('auth.not_enough_privilege') );
164
+			$this->setMessage(lang('auth.not_enough_privilege'));
165 165
 		}
166 166
 
167 167
 		if (empty($uri))
168 168
 		{
169
-			redirect( \Myth\Route::named('login') .'?request_uri='. current_url() );
169
+			redirect(\Myth\Route::named('login').'?request_uri='.current_url());
170 170
 		}
171 171
 
172
-		redirect($uri .'?request_uri='. current_url());
172
+		redirect($uri.'?request_uri='.current_url());
173 173
 	}
174 174
 
175 175
 	//--------------------------------------------------------------------
@@ -198,16 +198,16 @@  discard block
 block discarded – undo
198 198
 		$auth = config_item('auth.authenticate_lib');
199 199
 
200 200
 		if (empty($auth)) {
201
-			throw new \RuntimeException( lang('auth.no_authenticate') );
201
+			throw new \RuntimeException(lang('auth.no_authenticate'));
202 202
 		}
203 203
 
204
-		$this->authenticate = new $auth( get_instance() );
204
+		$this->authenticate = new $auth(get_instance());
205 205
 
206 206
 		get_instance()->load->model('auth/user_model', 'user_model', true);
207
-		$this->authenticate->useModel( get_instance()->user_model );
207
+		$this->authenticate->useModel(get_instance()->user_model);
208 208
 
209 209
 		// Try to log us in automatically.
210
-		if (! $this->authenticate->isLoggedIn())
210
+		if ( ! $this->authenticate->isLoggedIn())
211 211
 		{
212 212
 			$this->authenticate->viaRemember();
213 213
 		}
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 		$auth = config_item('auth.authorize_lib');
219 219
 
220 220
 		if (empty($auth)) {
221
-			throw new \RuntimeException( lang('auth.no_authenticate') );
221
+			throw new \RuntimeException(lang('auth.no_authenticate'));
222 222
 		}
223 223
 
224 224
 		$this->authorize = new $auth();
Please login to merge, or discard this patch.