@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | if (version_compare(PHP_VERSION, '5.4.0', '<')) { |
| 9 | - throw new Exception('The TopMcApi requires PHP version 5.4 or higher.'); |
|
| 9 | + throw new Exception('The TopMcApi requires PHP version 5.4 or higher.'); |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | /** |
@@ -18,29 +18,29 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | spl_autoload_register(function ($class) |
| 20 | 20 | { |
| 21 | - // project-specific namespace prefix |
|
| 22 | - $prefix = 'TopMcFrance\\\Api\\'; |
|
| 21 | + // project-specific namespace prefix |
|
| 22 | + $prefix = 'TopMcFrance\\\Api\\'; |
|
| 23 | 23 | |
| 24 | - // base directory for the namespace prefix |
|
| 25 | - $base_dir = __DIR__ . '/src/'; |
|
| 24 | + // base directory for the namespace prefix |
|
| 25 | + $base_dir = __DIR__ . '/src/'; |
|
| 26 | 26 | |
| 27 | - // does the class use the namespace prefix? |
|
| 28 | - $len = strlen($prefix); |
|
| 29 | - if (strncmp($prefix, $class, $len) !== 0) { |
|
| 27 | + // does the class use the namespace prefix? |
|
| 28 | + $len = strlen($prefix); |
|
| 29 | + if (strncmp($prefix, $class, $len) !== 0) { |
|
| 30 | 30 | // no, move to the next registered autoloader |
| 31 | 31 | return; |
| 32 | - } |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - // get the relative class name |
|
| 35 | - $relative_class = substr($class, $len); |
|
| 34 | + // get the relative class name |
|
| 35 | + $relative_class = substr($class, $len); |
|
| 36 | 36 | |
| 37 | - // replace the namespace prefix with the base directory, replace namespace |
|
| 38 | - // separators with directory separators in the relative class name, append |
|
| 39 | - // with .php |
|
| 40 | - $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php'; |
|
| 37 | + // replace the namespace prefix with the base directory, replace namespace |
|
| 38 | + // separators with directory separators in the relative class name, append |
|
| 39 | + // with .php |
|
| 40 | + $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php'; |
|
| 41 | 41 | |
| 42 | - // if the file exists, require it |
|
| 43 | - if (file_exists($file)) { |
|
| 42 | + // if the file exists, require it |
|
| 43 | + if (file_exists($file)) { |
|
| 44 | 44 | require $file; |
| 45 | - } |
|
| 45 | + } |
|
| 46 | 46 | }); |
| 47 | 47 | \ No newline at end of file |
@@ -36,20 +36,20 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | public function checkCode($code){ |
| 38 | 38 | |
| 39 | - $response = $this->getResponse($code); |
|
| 39 | + $response = $this->getResponse($code); |
|
| 40 | 40 | |
| 41 | - if($response->etat === true){ |
|
| 42 | - return true; |
|
| 43 | - } else { |
|
| 44 | - switch ($response->etat){ |
|
| 45 | - case '1' : |
|
| 41 | + if($response->etat === true){ |
|
| 42 | + return true; |
|
| 43 | + } else { |
|
| 44 | + switch ($response->etat){ |
|
| 45 | + case '1' : |
|
| 46 | 46 | throw ApiException::alreadyUsed($code, $response); |
| 47 | - case '2' : |
|
| 47 | + case '2' : |
|
| 48 | 48 | throw ApiException::invalidCode($code, $response); |
| 49 | - default: |
|
| 49 | + default: |
|
| 50 | 50 | throw ApiException::unknowException($code, $response); |
| 51 | - } |
|
| 52 | - } |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | $result = file_get_contents($this->buildURI($code)); |
| 72 | 72 | |
| 73 | 73 | if($result === false){ |
| 74 | - throw new \Exception("Impossible to accès to TopMcFrance"); |
|
| 74 | + throw new \Exception("Impossible to accès to TopMcFrance"); |
|
| 75 | 75 | } |
| 76 | 76 | return json_decode($result); |
| 77 | 77 | } |