Completed
Push — master ( 3c7668...53fccc )
by John
01:51
created
examples/geophone/src/Endpoints/v1/PhoneNumbers.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,6 +20,6 @@
 block discarded – undo
20 20
 
21 21
 
22 22
     public function get(Request $request): ResponseData{
23
-		return $this->geoPhone->lookupNumber($request->getInstance());
24
-	}
23
+        return $this->geoPhone->lookupNumber($request->getInstance());
24
+    }
25 25
 }
Please login to merge, or discard this patch.
examples/geophone/src/Models/GeoPhone.php 3 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
     /**
15 15
      * @param string $filename
16 16
      */
17
-    public function __construct($filename = 'data.csv'){
17
+    public function __construct($filename = 'data.csv') {
18 18
         $this->fileHandle = fopen($filename, 'r');
19 19
     }
20 20
 
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
         $nextThree = substr($phoneNumber, 3, 3);
30 30
 
31 31
         while (($data = fgetcsv($this->fileHandle)) !== FALSE) {
32
-            if($areaCode == $data[0] && $nextThree == $data[1]){
32
+            if ($areaCode == $data[0] && $nextThree == $data[1]) {
33 33
                 return new LookupResponse($data[2], $data[3]);
34 34
             }
35 35
         }
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
     /**
15 15
      * @param string $filename
16 16
      */
17
-    public function __construct($filename = 'data.csv'){
17
+    public function __construct($filename = 'data.csv') {
18 18
         $this->fileHandle = fopen($filename, 'r');
19 19
     }
20 20
 
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
         $nextThree = substr($phoneNumber, 3, 3);
30 30
 
31 31
         while (($data = fgetcsv($this->fileHandle)) !== FALSE) {
32
-            if($areaCode == $data[0] && $nextThree == $data[1]){
32
+            if($areaCode == $data[0] && $nextThree == $data[1]) {
33 33
                 return new LookupResponse($data[2], $data[3]);
34 34
             }
35 35
         }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
         $areaCode = substr($phoneNumber, 0, 3);
29 29
         $nextThree = substr($phoneNumber, 3, 3);
30 30
 
31
-        while (($data = fgetcsv($this->fileHandle)) !== FALSE) {
31
+        while (($data = fgetcsv($this->fileHandle)) !== false) {
32 32
             if($areaCode == $data[0] && $nextThree == $data[1]){
33 33
                 return new LookupResponse($data[2], $data[3]);
34 34
             }
Please login to merge, or discard this patch.
src/Endpoint/NamespaceEndpointFactory.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
      * @throws UnknownEndpointException
23 23
      */
24 24
     public function getEndpoint(string $name, string $version): Endpoint {
25
-        $className = $this->buildVersionedEndpointNamespace($version) . $name;
26
-        if(!class_exists($className)){
25
+        $className = $this->buildVersionedEndpointNamespace($version).$name;
26
+        if (!class_exists($className)) {
27 27
             throw new UnknownEndpointException("Could not find $className");
28 28
         }
29 29
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
         $classesInNamespace = [];
40 40
 
41 41
         $namespace = $this->buildVersionedEndpointNamespace($version);
42
-        foreach(get_declared_classes() as $name) {
42
+        foreach (get_declared_classes() as $name) {
43 43
             if (strpos($name, $namespace) === 0) {
44 44
                 $classesInNamespace[] = $name;
45 45
             }
@@ -49,6 +49,6 @@  discard block
 block discarded – undo
49 49
     }
50 50
 
51 51
     protected function buildVersionedEndpointNamespace(string $version): string {
52
-        return $this->endpointNamespace . '\v' . str_replace('.', '_', $version) . '\\';
52
+        return $this->endpointNamespace.'\v'.str_replace('.', '_', $version).'\\';
53 53
     }
54 54
 }
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
      */
24 24
     public function getEndpoint(string $name, string $version): Endpoint {
25 25
         $className = $this->buildVersionedEndpointNamespace($version) . $name;
26
-        if(!class_exists($className)){
26
+        if(!class_exists($className)) {
27 27
             throw new UnknownEndpointException("Could not find $className");
28 28
         }
29 29
 
Please login to merge, or discard this patch.
src/Request/URLParser/BasicURLParser.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
      */
15 15
     public function parse(string $url): ParsedURL {
16 16
         $splitURL = explode('/', trim($url, '/'));
17
-        if(count($splitURL) < 3){
17
+        if (count($splitURL) < 3) {
18 18
             throw new InvalidRequestURLException();
19 19
         }
20 20
         //Find endpoint
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 
28 28
         $instance = null;
29 29
 
30
-        if(count($splitURL) == 4){
30
+        if (count($splitURL) == 4) {
31 31
             $instance = implode('.', $splitExtension);
32 32
         } else {
33 33
             $endpoint = implode('.', $splitExtension);
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
      */
29 29
     public function parse(string $url): ParsedURL {
30 30
         $splitURL = explode('/', trim($url, '/'));
31
-        if(count($splitURL) < 3){
31
+        if(count($splitURL) < 3) {
32 32
             throw new InvalidRequestURLException();
33 33
         }
34 34
         //Find endpoint
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 
42 42
         $instance = null;
43 43
 
44
-        if(count($splitURL) == 4){
44
+        if(count($splitURL) == 4) {
45 45
             $instance = implode('.', $splitExtension);
46 46
         } else {
47 47
             $endpoint = implode('.', $splitExtension);
Please login to merge, or discard this patch.
src/Server/Router.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
     /**
22 22
      * @param EndpointFactory $endpointFactory
23 23
      */
24
-    public function __construct(EndpointFactory $endpointFactory){
24
+    public function __construct(EndpointFactory $endpointFactory) {
25 25
         $this->endpointFactory = $endpointFactory;
26 26
     }
27 27
 
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
      * @throws MethodNotFoundException
44 44
      */
45 45
     protected function executeEndpoint(Endpoint $endpoint, Request $request): ResponseData {
46
-        if(!method_exists($endpoint, $request->getMethod())){
47
-            throw new MethodNotFoundException("The endpoint method " . $request->getMethod() . " was not found");
46
+        if (!method_exists($endpoint, $request->getMethod())) {
47
+            throw new MethodNotFoundException("The endpoint method ".$request->getMethod()." was not found");
48 48
         }
49 49
         return call_user_func([$endpoint, $request->getMethod()], $request);
50 50
     }
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
     /**
22 22
      * @param EndpointFactory $endpointFactory
23 23
      */
24
-    public function __construct(EndpointFactory $endpointFactory){
24
+    public function __construct(EndpointFactory $endpointFactory) {
25 25
         $this->endpointFactory = $endpointFactory;
26 26
     }
27 27
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      * @throws MethodNotFoundException
44 44
      */
45 45
     protected function executeEndpoint(Endpoint $endpoint, Request $request): ResponseData {
46
-        if(!method_exists($endpoint, $request->getMethod())){
46
+        if(!method_exists($endpoint, $request->getMethod())) {
47 47
             throw new MethodNotFoundException("The endpoint method " . $request->getMethod() . " was not found");
48 48
         }
49 49
         return call_user_func([$endpoint, $request->getMethod()], $request);
Please login to merge, or discard this patch.
src/Response/DefaultResponseFactory.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,11 +11,11 @@
 block discarded – undo
11 11
      * @throws NotAcceptableResponseTypeException
12 12
      */
13 13
     public function getResponse(ResponseData $data, array $acceptedMIMETypes): Response {
14
-        if(empty($acceptedMIMETypes)){
14
+        if (empty($acceptedMIMETypes)) {
15 15
             $acceptedMIMETypes = $this->getSupportedMIMETypes();
16 16
         }
17 17
 
18
-        foreach($acceptedMIMETypes as $acceptedMIMEType) {
18
+        foreach ($acceptedMIMETypes as $acceptedMIMEType) {
19 19
             switch (strtolower($acceptedMIMEType)) {
20 20
                 case "application/json":
21 21
                     return new JSONResponse($data);
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
      * @throws NotAcceptableResponseTypeException
12 12
      */
13 13
     public function getResponse(ResponseData $data, array $acceptedMIMETypes): Response {
14
-        if(empty($acceptedMIMETypes)){
14
+        if(empty($acceptedMIMETypes)) {
15 15
             $acceptedMIMETypes = $this->getSupportedMIMETypes();
16 16
         }
17 17
 
Please login to merge, or discard this patch.
src/Server/Server.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
      * @param ResponseFactory $responseFactory
40 40
      * @param EndpointFactory $endpointFactory
41 41
      */
42
-    public function __construct(AccessControl $accessControl, Throttle $throttle, ResponseFactory $responseFactory, EndpointFactory $endpointFactory){
42
+    public function __construct(AccessControl $accessControl, Throttle $throttle, ResponseFactory $responseFactory, EndpointFactory $endpointFactory) {
43 43
         $this->accessControl = $accessControl;
44 44
         $this->throttle = $throttle;
45 45
         $this->responseFactory = $responseFactory;
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
 
61 61
         $this->validateExtension($request);
62 62
 
63
-        if($this->throttle->shouldThrottle($request)) {
63
+        if ($this->throttle->shouldThrottle($request)) {
64 64
             throw new ThrottleLimitExceededException('Request limit exceeded');
65 65
         }
66 66
 
67
-        if(!$this->accessControl->validateAccess($request)) {
67
+        if (!$this->accessControl->validateAccess($request)) {
68 68
             throw new AccessDeniedException("API key does not have the required permissions to access requested resource");
69 69
         }
70 70
 
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
      * @param Request $request
80 80
      * @throws InvalidAPIKeyException
81 81
      */
82
-    protected function validateKey(Request $request){
83
-        if(!$this->accessControl->validateKey($request->getApiKey())){
82
+    protected function validateKey(Request $request) {
83
+        if (!$this->accessControl->validateKey($request->getApiKey())) {
84 84
             throw new InvalidAPIKeyException('Invalid API key');
85 85
         }
86 86
     }
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      */
92 92
     protected function validateExtension(Request $request) {
93 93
         $formats = $this->responseFactory->getSupportedMIMETypes();
94
-        if(empty($formats) || (
94
+        if (empty($formats) || (
95 95
             !empty($request->getAcceptableMIMETypes()) && empty(array_intersect($request->getAcceptableMIMETypes(), $formats))
96 96
             )) {
97 97
             throw new NotAcceptableResponseTypeException('None of the requests acceptable response types are valid');
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
      * @param ResponseFactory $responseFactory
41 41
      * @param EndpointFactory $endpointFactory
42 42
      */
43
-    public function __construct(AccessControl $accessControl, Throttle $throttle, ResponseFactory $responseFactory, EndpointFactory $endpointFactory){
43
+    public function __construct(AccessControl $accessControl, Throttle $throttle, ResponseFactory $responseFactory, EndpointFactory $endpointFactory) {
44 44
         $this->accessControl = $accessControl;
45 45
         $this->throttle = $throttle;
46 46
         $this->responseFactory = $responseFactory;
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
      * @param Request $request
81 81
      * @throws InvalidAPIKeyException
82 82
      */
83
-    protected function validateKey(Request $request){
84
-        if(!$this->accessControl->validateKey($request->getApiKey())){
83
+    protected function validateKey(Request $request) {
84
+        if(!$this->accessControl->validateKey($request->getApiKey())) {
85 85
             throw new InvalidAPIKeyException('Invalid API key');
86 86
         }
87 87
     }
Please login to merge, or discard this patch.
src/Request/RequestData/JSONRequestData.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
     public function __construct($body) {
18 18
         $this->jsonString = $body;
19 19
         $this->parsedData = json_decode($body, true);
20
-        if($this->parsedData === null) {
20
+        if ($this->parsedData === null) {
21 21
             throw new InvalidRequestDataException('Content not valid JSON');
22 22
         }
23 23
     }
Please login to merge, or discard this patch.
src/Request/Request.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
      * @internal param string $extension
65 65
      */
66 66
 
67
-    public function __construct($method, array $headers, RequestData $body, RequestData $urlData, $ip, $version, $apiKey, $endpoint, array $acceptableMIMETypes = [], $instance = null){
67
+    public function __construct($method, array $headers, RequestData $body, RequestData $urlData, $ip, $version, $apiKey, $endpoint, array $acceptableMIMETypes = [], $instance = null) {
68 68
         $this->method = strtolower($method);
69 69
         $this->headers = $headers;
70 70
         $this->body = $body;
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
      * @return string
89 89
      */
90 90
     public function getMethod() {
91
-        return $this->method . ($this->instance ? '' : 'All');
91
+        return $this->method.($this->instance ? '' : 'All');
92 92
     }
93 93
 
94 94
     /**
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
      * @internal param string $extension
65 65
      */
66 66
 
67
-    public function __construct($method, array $headers, RequestData $body, RequestData $urlData, $ip, $version, $apiKey, $endpoint, array $acceptableMIMETypes = [], $instance = null){
67
+    public function __construct($method, array $headers, RequestData $body, RequestData $urlData, $ip, $version, $apiKey, $endpoint, array $acceptableMIMETypes = [], $instance = null) {
68 68
         $this->method = strtolower($method);
69 69
         $this->headers = $headers;
70 70
         $this->body = $body;
Please login to merge, or discard this patch.