Completed
Push — master ( 354bbd...8413c0 )
by John
03:53
created
src/Response/DefaultResponseFactory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
      * @throws UnknownResponseTypeException
12 12
      */
13 13
     public function getResponse(ResponseData $data, string $type): Response {
14
-        switch(strtolower($type)) {
14
+        switch (strtolower($type)) {
15 15
             case "json":
16 16
                 return new JSONResponse($data);
17 17
             default:
Please login to merge, or discard this patch.
src/Endpoint/DoctrineEndpoint.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
 class DoctrineEndpoint extends DefaultEndpoint {
10 10
     protected $entityManager;
11 11
 
12
-    public function __construct(EntityManager $em){
12
+    public function __construct(EntityManager $em) {
13 13
         $this->entityManager = $em;
14 14
     }
15 15
 }
Please login to merge, or discard this patch.
src/Endpoint/DoctrineNamespaceEndpointFactory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,6 +20,6 @@
 block discarded – undo
20 20
      * @throws UnknownEndpointException
21 21
      */
22 22
     public function getEndpoint(string $name, string $version): Endpoint {
23
-        return new ($this->buildVersionedEndpointNamespace($version) . $name)($this->entityManager);
23
+        return new ($this->buildVersionedEndpointNamespace($version).$name)($this->entityManager);
24 24
     }
25 25
 }
Please login to merge, or discard this patch.
src/Endpoint/NamespaceEndpointFactory.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
      * @throws UnknownEndpointException
23 23
      */
24 24
     public function getEndpoint(string $name, string $version): Endpoint {
25
-        return new ($this->buildVersionedEndpointNamespace($version) . $name);
25
+        return new ($this->buildVersionedEndpointNamespace($version).$name);
26 26
     }
27 27
 
28 28
     /**
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         $classesInNamespace = [];
35 35
 
36 36
         $namespace = $this->buildVersionedEndpointNamespace($version);
37
-        foreach(get_declared_classes() as $name) {
37
+        foreach (get_declared_classes() as $name) {
38 38
             if (strpos($name, $namespace) === 0) {
39 39
                 $classesInNamespace[] = $name;
40 40
             }
@@ -44,6 +44,6 @@  discard block
 block discarded – undo
44 44
     }
45 45
 
46 46
     protected function buildVersionedEndpointNamespace(string $version): string {
47
-        return $this->endpointNamespace . '\Endpoints\v' . str_replace('.', '_', $version) . '\\';
47
+        return $this->endpointNamespace.'\Endpoints\v'.str_replace('.', '_', $version).'\\';
48 48
     }
49 49
 }
Please login to merge, or discard this patch.
src/Router/Router.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      * @param ResponseFactory $responseFactory
44 44
      * @param EndpointFactory $endpointFactory
45 45
      */
46
-    public function __construct(AccessControl $accessControl, Throttle $throttle, ResponseFactory $responseFactory, EndpointFactory $endpointFactory){
46
+    public function __construct(AccessControl $accessControl, Throttle $throttle, ResponseFactory $responseFactory, EndpointFactory $endpointFactory) {
47 47
         $this->accessControl = $accessControl;
48 48
         $this->throttle = $throttle;
49 49
         $this->responseFactory = $responseFactory;
@@ -66,11 +66,11 @@  discard block
 block discarded – undo
66 66
 
67 67
         $endpoint = $this->endpointFactory->getEndpoint($request->getEndpoint(), $request->getVersion());
68 68
 
69
-        if($this->throttle->shouldThrottle($request)) {
69
+        if ($this->throttle->shouldThrottle($request)) {
70 70
             throw new ThrottleLimitExceededException('Request limit exceeded');
71 71
         }
72 72
 
73
-        if(!$this->accessControl->validateAccess($request)) {
73
+        if (!$this->accessControl->validateAccess($request)) {
74 74
             throw new AccessDeniedException("API key does not have the required permissions to access requested resource");
75 75
         }
76 76
 
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
      * @param Request $request
86 86
      * @throws InvalidAPIKeyException
87 87
      */
88
-    protected function validateKey(Request $request){
89
-        if(!$this->accessControl->validateKey($request->getApiKey())){
88
+    protected function validateKey(Request $request) {
89
+        if (!$this->accessControl->validateKey($request->getApiKey())) {
90 90
             throw new InvalidAPIKeyException('Invalid API key');
91 91
         }
92 92
     }
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
      */
98 98
     protected function validateExtension(Request $request) {
99 99
         $formats = $this->responseFactory->getSupportedTypes();
100
-        if(!$formats || !in_array($request->getExtension(), $formats)){
101
-            throw new UnknownResponseTypeException('Unknown response format: ' . $request->getExtension());
100
+        if (!$formats || !in_array($request->getExtension(), $formats)) {
101
+            throw new UnknownResponseTypeException('Unknown response format: '.$request->getExtension());
102 102
         }
103 103
     }
104 104
 
Please login to merge, or discard this patch.
examples/geophone/index.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 $router = new \LunixREST\Router\Router($accessControl, $throttle, $responseFactory, $endpointFactory);
11 11
 
12 12
 try {
13
-	$request = \LunixREST\Request\Request::createFromURL("GET", [], [], '127.0.0.1',  "/1/123456/phonenumbers/6517855237.json");// \LunixREST\Request\Request::createFromURL($_SERVER['REQUEST_METHOD'], getallheaders(), $_REQUEST, $_SERVER['REMOTE_ADDR'], $_SERVER['REQUEST_URI']);
13
+    $request = \LunixREST\Request\Request::createFromURL("GET", [], [], '127.0.0.1',  "/1/123456/phonenumbers/6517855237.json");// \LunixREST\Request\Request::createFromURL($_SERVER['REQUEST_METHOD'], getallheaders(), $_REQUEST, $_SERVER['REMOTE_ADDR'], $_SERVER['REQUEST_URI']);
14 14
 
15 15
     try {
16 16
         $response = $router->route($request);
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
         header('500 Internal Server Error', true, 500);
30 30
     }
31 31
 } catch(\LunixREST\Exceptions\InvalidRequestFormatException $e){
32
-	header('400 Bad Request', 400);
32
+    header('400 Bad Request', 400);
33 33
 } catch(Exception|Error $e){
34
-	header('500 Internal Server Error', true, 500);
34
+    header('500 Internal Server Error', true, 500);
35 35
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -10,26 +10,26 @@
 block discarded – undo
10 10
 $router = new \LunixREST\Router\Router($accessControl, $throttle, $responseFactory, $endpointFactory);
11 11
 
12 12
 try {
13
-	$request = \LunixREST\Request\Request::createFromURL("GET", [], [], '127.0.0.1',  "/1/123456/phonenumbers/6517855237.json");// \LunixREST\Request\Request::createFromURL($_SERVER['REQUEST_METHOD'], getallheaders(), $_REQUEST, $_SERVER['REMOTE_ADDR'], $_SERVER['REQUEST_URI']);
13
+	$request = \LunixREST\Request\Request::createFromURL("GET", [], [], '127.0.0.1', "/1/123456/phonenumbers/6517855237.json"); // \LunixREST\Request\Request::createFromURL($_SERVER['REQUEST_METHOD'], getallheaders(), $_REQUEST, $_SERVER['REMOTE_ADDR'], $_SERVER['REQUEST_URI']);
14 14
 
15 15
     try {
16 16
         $response = $router->route($request);
17 17
         echo $response->getAsString();
18
-    } catch(\LunixREST\Exceptions\InvalidAPIKeyException $e){
18
+    } catch (\LunixREST\Exceptions\InvalidAPIKeyException $e) {
19 19
         header('400 Bad Request', true, 400);
20
-    } catch(\LunixREST\Endpoint\Exceptions\UnknownEndpointException $e){
20
+    } catch (\LunixREST\Endpoint\Exceptions\UnknownEndpointException $e) {
21 21
         header('404 Not Found', true, 404);
22
-    } catch(\LunixREST\Response\Exceptions\UnknownResponseTypeException $e){
22
+    } catch (\LunixREST\Response\Exceptions\UnknownResponseTypeException $e) {
23 23
         header('404 Not Found', true, 404);
24
-    } catch(\LunixREST\Exceptions\AccessDeniedException $e){
24
+    } catch (\LunixREST\Exceptions\AccessDeniedException $e) {
25 25
         header('403 Access Denied', true, 403);
26
-    }  catch(\LunixREST\Exceptions\ThrottleLimitExceededException $e){
26
+    } catch (\LunixREST\Exceptions\ThrottleLimitExceededException $e) {
27 27
         header('429 Too Many Requests', true, 429);
28
-    } catch(Exception|Error $e){
28
+    } catch (Exception | Error $e) {
29 29
         header('500 Internal Server Error', true, 500);
30 30
     }
31
-} catch(\LunixREST\Exceptions\InvalidRequestFormatException $e){
31
+} catch (\LunixREST\Exceptions\InvalidRequestFormatException $e) {
32 32
 	header('400 Bad Request', 400);
33
-} catch(Exception|Error $e){
33
+} catch (Exception | Error $e) {
34 34
 	header('500 Internal Server Error', true, 500);
35 35
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
         header('404 Not Found', true, 404);
24 24
     } catch(\LunixREST\Exceptions\AccessDeniedException $e){
25 25
         header('403 Access Denied', true, 403);
26
-    }  catch(\LunixREST\Exceptions\ThrottleLimitExceededException $e){
26
+    } catch(\LunixREST\Exceptions\ThrottleLimitExceededException $e){
27 27
         header('429 Too Many Requests', true, 429);
28 28
     } catch(Exception|Error $e){
29 29
         header('500 Internal Server Error', true, 500);
Please login to merge, or discard this patch.
examples/helloworld/index.php 2 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -11,26 +11,26 @@
 block discarded – undo
11 11
 $router = new \LunixREST\Router\Router($accessControl, $throttle, $responseFactory, $endpointFactory);
12 12
 
13 13
 try {
14
-	$request =  \LunixREST\Request\Request::createFromURL("GET", [], [], '127.0.0.1', "/1.0/public/helloworld.json");// \LunixREST\Request\Request::createFromURL($_SERVER['REQUEST_METHOD'], getallheaders(), $_REQUEST, $_SERVER['REMOTE_ADDR'], $_SERVER['REQUEST_URI']);
14
+    $request =  \LunixREST\Request\Request::createFromURL("GET", [], [], '127.0.0.1', "/1.0/public/helloworld.json");// \LunixREST\Request\Request::createFromURL($_SERVER['REQUEST_METHOD'], getallheaders(), $_REQUEST, $_SERVER['REMOTE_ADDR'], $_SERVER['REQUEST_URI']);
15 15
 
16
-	try {
17
-		$response = $router->route($request);
18
-		echo $response->getAsString();
19
-	} catch(\LunixREST\Exceptions\InvalidAPIKeyException $e){
20
-		header('400 Bad Request', true, 400);
21
-	} catch(\LunixREST\Endpoint\Exceptions\UnknownEndpointException $e){
22
-		header('404 Not Found', true, 404);
23
-	} catch(\LunixREST\Response\Exceptions\UnknownResponseTypeException $e){
24
-		header('404 Not Found', true, 404);
25
-	} catch(\LunixREST\Exceptions\AccessDeniedException $e){
26
-		header('403 Access Denied', true, 403);
27
-	}  catch(\LunixREST\Exceptions\ThrottleLimitExceededException $e){
28
-		header('429 Too Many Requests', true, 429);
29
-	} catch(Exception $e){
30
-		header('500 Internal Server Error', true, 500);
31
-	}
16
+    try {
17
+        $response = $router->route($request);
18
+        echo $response->getAsString();
19
+    } catch(\LunixREST\Exceptions\InvalidAPIKeyException $e){
20
+        header('400 Bad Request', true, 400);
21
+    } catch(\LunixREST\Endpoint\Exceptions\UnknownEndpointException $e){
22
+        header('404 Not Found', true, 404);
23
+    } catch(\LunixREST\Response\Exceptions\UnknownResponseTypeException $e){
24
+        header('404 Not Found', true, 404);
25
+    } catch(\LunixREST\Exceptions\AccessDeniedException $e){
26
+        header('403 Access Denied', true, 403);
27
+    }  catch(\LunixREST\Exceptions\ThrottleLimitExceededException $e){
28
+        header('429 Too Many Requests', true, 429);
29
+    } catch(Exception $e){
30
+        header('500 Internal Server Error', true, 500);
31
+    }
32 32
 } catch(\LunixREST\Exceptions\InvalidRequestFormatException $e){
33
-	header('400 Bad Request', true, 400);
33
+    header('400 Bad Request', true, 400);
34 34
 } catch(Exception $e){
35
-	header('500 Internal Server Error', true, 500);
35
+    header('500 Internal Server Error', true, 500);
36 36
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -11,26 +11,26 @@
 block discarded – undo
11 11
 $router = new \LunixREST\Router\Router($accessControl, $throttle, $responseFactory, $endpointFactory);
12 12
 
13 13
 try {
14
-	$request =  \LunixREST\Request\Request::createFromURL("GET", [], [], '127.0.0.1', "/1.0/public/helloworld.json");// \LunixREST\Request\Request::createFromURL($_SERVER['REQUEST_METHOD'], getallheaders(), $_REQUEST, $_SERVER['REMOTE_ADDR'], $_SERVER['REQUEST_URI']);
14
+	$request = \LunixREST\Request\Request::createFromURL("GET", [], [], '127.0.0.1', "/1.0/public/helloworld.json"); // \LunixREST\Request\Request::createFromURL($_SERVER['REQUEST_METHOD'], getallheaders(), $_REQUEST, $_SERVER['REMOTE_ADDR'], $_SERVER['REQUEST_URI']);
15 15
 
16 16
 	try {
17 17
 		$response = $router->route($request);
18 18
 		echo $response->getAsString();
19
-	} catch(\LunixREST\Exceptions\InvalidAPIKeyException $e){
19
+	} catch (\LunixREST\Exceptions\InvalidAPIKeyException $e) {
20 20
 		header('400 Bad Request', true, 400);
21
-	} catch(\LunixREST\Endpoint\Exceptions\UnknownEndpointException $e){
21
+	} catch (\LunixREST\Endpoint\Exceptions\UnknownEndpointException $e) {
22 22
 		header('404 Not Found', true, 404);
23
-	} catch(\LunixREST\Response\Exceptions\UnknownResponseTypeException $e){
23
+	} catch (\LunixREST\Response\Exceptions\UnknownResponseTypeException $e) {
24 24
 		header('404 Not Found', true, 404);
25
-	} catch(\LunixREST\Exceptions\AccessDeniedException $e){
25
+	} catch (\LunixREST\Exceptions\AccessDeniedException $e) {
26 26
 		header('403 Access Denied', true, 403);
27
-	}  catch(\LunixREST\Exceptions\ThrottleLimitExceededException $e){
27
+	} catch (\LunixREST\Exceptions\ThrottleLimitExceededException $e) {
28 28
 		header('429 Too Many Requests', true, 429);
29
-	} catch(Exception $e){
29
+	} catch (Exception $e) {
30 30
 		header('500 Internal Server Error', true, 500);
31 31
 	}
32
-} catch(\LunixREST\Exceptions\InvalidRequestFormatException $e){
32
+} catch (\LunixREST\Exceptions\InvalidRequestFormatException $e) {
33 33
 	header('400 Bad Request', true, 400);
34
-} catch(Exception $e){
34
+} catch (Exception $e) {
35 35
 	header('500 Internal Server Error', true, 500);
36 36
 }
Please login to merge, or discard this patch.