Completed
Pull Request — master (#18)
by John
02:39
created
src/APIRequest/BodyParser/BodyParserFactory/RegisteredBodyParserFactory.php 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -9,8 +9,7 @@  discard block
 block discarded – undo
9 9
  * Class RegisteredBodyParserFactory
10 10
  * @package LunixREST\Request\BodyParser
11 11
  */
12
-class RegisteredBodyParserFactory implements BodyParserFactory
13
-{
12
+class RegisteredBodyParserFactory implements BodyParserFactory {
14 13
 
15 14
     protected $contentTypeToParserMap;
16 15
 
@@ -18,8 +17,7 @@  discard block
 block discarded – undo
18 17
      * RegisteredBodyParserFactory constructor.
19 18
      * @param BodyParser[] $mappings keyed by content type
20 19
      */
21
-    public function __construct($mappings = [])
22
-    {
20
+    public function __construct($mappings = []) {
23 21
         foreach ($mappings as $contentType => $bodyParser) {
24 22
             $this->add($contentType, $bodyParser);
25 23
         }
@@ -29,8 +27,7 @@  discard block
 block discarded – undo
29 27
      * @param $contentType
30 28
      * @param BodyParser $bodyParser
31 29
      */
32
-    public function add($contentType, BodyParser $bodyParser)
33
-    {
30
+    public function add($contentType, BodyParser $bodyParser) {
34 31
         $this->contentTypeToParserMap[strtolower($contentType)] = $bodyParser;
35 32
     }
36 33
 
Please login to merge, or discard this patch.
src/APIRequest/BodyParser/BodyParserFactory/DefaultBodyParserFactory.php 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -10,21 +10,18 @@
 block discarded – undo
10 10
  * Class DefaultBodyParserFactory
11 11
  * @package LunixREST\Request\BodyParser
12 12
  */
13
-class DefaultBodyParserFactory implements BodyParserFactory
14
-{
13
+class DefaultBodyParserFactory implements BodyParserFactory {
15 14
 
16 15
     protected $registeredBodyParserFactory;
17 16
 
18
-    public function __construct()
19
-    {
17
+    public function __construct() {
20 18
         $this->registeredBodyParserFactory = new RegisteredBodyParserFactory([
21 19
             'application/json' => new JSONBodyParser(),
22 20
             'application/x-www-form-urlencoded' => new URLEncodedBodyParser()
23 21
         ]);
24 22
     }
25 23
 
26
-    public function add($contentType, BodyParser $bodyParser)
27
-    {
24
+    public function add($contentType, BodyParser $bodyParser) {
28 25
         $this->registeredBodyParserFactory->add($contentType, $bodyParser);
29 26
     }
30 27
 
Please login to merge, or discard this patch.
src/APIRequest/BodyParser/Exceptions/InvalidRequestDataException.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace LunixREST\Request\BodyParser\Exceptions;
3 3
 
4
-class InvalidRequestDataException extends \Exception
5
-{
4
+class InvalidRequestDataException extends \Exception {
6 5
 
7 6
 }
Please login to merge, or discard this patch.
src/APIRequest/BodyParser/JSONBodyParser.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,8 +5,7 @@
 block discarded – undo
5 5
 use LunixREST\Request\RequestData\JSONRequestData;
6 6
 use LunixREST\Request\RequestData\RequestData;
7 7
 
8
-class JSONBodyParser implements BodyParser
9
-{
8
+class JSONBodyParser implements BodyParser {
10 9
 
11 10
     /**
12 11
      * Parses API request data out of a json string
Please login to merge, or discard this patch.
src/APIRequest/BodyParser/BodyParser.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,7 @@
 block discarded – undo
4 4
 use LunixREST\Request\BodyParser\Exceptions\InvalidRequestDataException;
5 5
 use LunixREST\Request\RequestData\RequestData;
6 6
 
7
-interface BodyParser
8
-{
7
+interface BodyParser {
9 8
     /**
10 9
      * Parses API request data out of a url
11 10
      * @param $rawBody
Please login to merge, or discard this patch.
src/APIRequest/BodyParser/URLEncodedBodyParser.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,8 +5,7 @@
 block discarded – undo
5 5
 use LunixREST\Request\RequestData\RequestData;
6 6
 use LunixREST\Request\RequestData\URLEncodedQueryStringRequestData;
7 7
 
8
-class URLEncodedBodyParser implements BodyParser
9
-{
8
+class URLEncodedBodyParser implements BodyParser {
10 9
 
11 10
     /**
12 11
      * Parses API request data out of a url
Please login to merge, or discard this patch.
src/Server/GenericServer.php 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -14,8 +14,7 @@  discard block
 block discarded – undo
14 14
 use LunixREST\Server\Exceptions\MethodNotFoundException;
15 15
 use LunixREST\Throttle\Throttle;
16 16
 
17
-class GenericServer implements Server
18
-{
17
+class GenericServer implements Server {
19 18
     /**
20 19
      * @var AccessControl
21 20
      */
@@ -86,8 +85,7 @@  discard block
 block discarded – undo
86 85
      * @param APIRequest $request
87 86
      * @throws InvalidAPIKeyException
88 87
      */
89
-    protected function validateKey(APIRequest $request)
90
-    {
88
+    protected function validateKey(APIRequest $request) {
91 89
         if (!$this->accessControl->validateKey($request->getApiKey())) {
92 90
             throw new InvalidAPIKeyException('Invalid API key');
93 91
         }
@@ -98,8 +96,7 @@  discard block
 block discarded – undo
98 96
      * @throws NotAcceptableResponseTypeException
99 97
      */
100 98
     //TODO: Handle wildcards in request MIME types (*/*)
101
-    protected function validateAcceptableMIMETypes(APIRequest $request)
102
-    {
99
+    protected function validateAcceptableMIMETypes(APIRequest $request) {
103 100
         $formats = $this->responseFactory->getSupportedMIMETypes();
104 101
         if (empty($formats) || (
105 102
                 !empty($request->getAcceptableMIMETypes()) && empty(array_intersect($request->getAcceptableMIMETypes(),
Please login to merge, or discard this patch.
src/Server/Router.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,8 +10,7 @@
 block discarded – undo
10 10
  * Interface Router
11 11
  * @package LunixREST\Server
12 12
  */
13
-interface Router
14
-{
13
+interface Router {
15 14
     /**
16 15
      * @param APIRequest $request
17 16
      * @return array|null|object
Please login to merge, or discard this patch.
src/Server/GenericRouter.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -47,13 +47,13 @@
 block discarded – undo
47 47
     {
48 48
         $method = $this->mapEndpointMethod($request);
49 49
         if (!method_exists($endpoint, $method)) {
50
-            throw new MethodNotFoundException("The endpoint method " . $method . " was not found");
50
+            throw new MethodNotFoundException("The endpoint method ".$method." was not found");
51 51
         }
52 52
         return call_user_func([$endpoint, $method], $request);
53 53
     }
54 54
 
55 55
     protected function mapEndpointMethod(APIRequest $request): string
56 56
     {
57
-        return strtolower($request->getMethod()) . ($request->getElement() ? 'All': '');
57
+        return strtolower($request->getMethod()).($request->getElement() ? 'All' : '');
58 58
     }
59 59
 }
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -10,8 +10,7 @@  discard block
 block discarded – undo
10 10
  * Class DefaultRouter
11 11
  * @package LunixREST\Server
12 12
  */
13
-class GenericRouter
14
-{
13
+class GenericRouter {
15 14
     /**
16 15
      * @var EndpointFactory
17 16
      */
@@ -21,8 +20,7 @@  discard block
 block discarded – undo
21 20
      * DefaultRouter constructor.
22 21
      * @param EndpointFactory $endpointFactory
23 22
      */
24
-    public function __construct(EndpointFactory $endpointFactory)
25
-    {
23
+    public function __construct(EndpointFactory $endpointFactory) {
26 24
         $this->endpointFactory = $endpointFactory;
27 25
     }
28 26
 
@@ -31,8 +29,7 @@  discard block
 block discarded – undo
31 29
      * @return null|object|array
32 30
      * @throws MethodNotFoundException
33 31
      */
34
-    public function route(APIRequest $request)
35
-    {
32
+    public function route(APIRequest $request) {
36 33
         $endpoint = $this->endpointFactory->getEndpoint($request->getEndpoint(), $request->getVersion());
37 34
         return $this->executeEndpoint($endpoint, $request);
38 35
     }
@@ -43,8 +40,7 @@  discard block
 block discarded – undo
43 40
      * @return null|object|array
44 41
      * @throws MethodNotFoundException
45 42
      */
46
-    protected function executeEndpoint(Endpoint $endpoint, APIRequest $request)
47
-    {
43
+    protected function executeEndpoint(Endpoint $endpoint, APIRequest $request) {
48 44
         $method = $this->mapEndpointMethod($request);
49 45
         if (!method_exists($endpoint, $method)) {
50 46
             throw new MethodNotFoundException("The endpoint method " . $method . " was not found");
Please login to merge, or discard this patch.