Completed
Pull Request — master (#30)
by John
02:51
created
src/APIRequest/URLParser/RegexURLParser/RegexURLParser.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
      * @param MIMEProvider|null $MIMEProvider
33 33
      * @throws InvalidRegexPatternException
34 34
      */
35
-    public function __construct(string $pattern, ?MIMEProvider $MIMEProvider = null)
35
+    public function __construct(string $pattern, ? MIMEProvider $MIMEProvider = null)
36 36
     {
37 37
         $this->pattern = $pattern;
38 38
 
39
-        if(@preg_match($pattern, null) === false) {
39
+        if (@preg_match($pattern, null) === false) {
40 40
             throw new InvalidRegexPatternException("Unable to parse regex pattern", preg_last_error());
41 41
         }
42 42
         $this->MIMEProvider = $MIMEProvider;
@@ -51,10 +51,10 @@  discard block
 block discarded – undo
51 51
     public function parse(UriInterface $uri): ParsedURL
52 52
     {
53 53
         $matches = [];
54
-        if(preg_match($this->pattern, $uri->getPath(), $matches) === 0) {
54
+        if (preg_match($this->pattern, $uri->getPath(), $matches) === 0) {
55 55
             throw new InvalidRequestURLException("Unable to parse request path: did not match regex");
56 56
         }
57
-        if(!($endpoint = $matches["endpoint"] ?? null)) {
57
+        if (!($endpoint = $matches["endpoint"] ?? null)) {
58 58
             throw new InvalidRequestURLException("Unable to match endpoint in url");
59 59
         }
60 60
         $element = $matches["element"] ?? null;
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
         $apiKey = $matches["apiKey"] ?? null;
63 63
 
64 64
         $acceptableMimeTypes = [];
65
-        if(($acceptableExtension = $matches["acceptableExtension"] ?? null)) {
66
-            if(!$this->MIMEProvider) {
65
+        if (($acceptableExtension = $matches["acceptableExtension"] ?? null)) {
66
+            if (!$this->MIMEProvider) {
67 67
                 throw new InvalidRequestURLException("Unable to accept acceptable extensions");
68 68
             } else {
69 69
                 try {
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,8 +15,7 @@  discard block
 block discarded – undo
15 15
  * Class RegexURLParser
16 16
  * @package LunixREST\APIRequest\URLParser\RegexURLParser
17 17
  */
18
-class RegexURLParser implements URLParser
19
-{
18
+class RegexURLParser implements URLParser {
20 19
     /**
21 20
      * @var string
22 21
      */
@@ -32,8 +31,7 @@  discard block
 block discarded – undo
32 31
      * @param MIMEProvider|null $MIMEProvider
33 32
      * @throws InvalidRegexPatternException
34 33
      */
35
-    public function __construct(string $pattern, ?MIMEProvider $MIMEProvider = null)
36
-    {
34
+    public function __construct(string $pattern, ?MIMEProvider $MIMEProvider = null) {
37 35
         $this->pattern = $pattern;
38 36
 
39 37
         if(@preg_match($pattern, null) === false) {
Please login to merge, or discard this patch.
URLParser/RegexURLParser/Exceptions/InvalidRegexPatternException.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,7 +6,6 @@
 block discarded – undo
6 6
  * Class InvalidRequestURLException
7 7
  * @package LunixREST\APIRequest\URLParser\RegexURLParser\Exceptions
8 8
  */
9
-class InvalidRegexPatternException extends \Exception
10
-{
9
+class InvalidRegexPatternException extends \Exception {
11 10
 
12 11
 }
Please login to merge, or discard this patch.
src/APIRequest/URLParser/Exceptions/UnableToProvideMIMEException.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\APIRequest\URLParser\Exceptions;
3 3
 
4
-class UnableToProvideMIMEException extends \Exception
5
-{
4
+class UnableToProvideMIMEException extends \Exception {
6 5
 
7 6
 }
Please login to merge, or discard this patch.
src/APIRequest/URLParser/MIMEProvider.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,8 +8,7 @@
 block discarded – undo
8 8
  * Interface MIMEProvider
9 9
  * @package LunixREST\APIRequest\URLParser
10 10
  */
11
-interface MIMEProvider
12
-{
11
+interface MIMEProvider {
13 12
     /**
14 13
      * @param string $fileExtension
15 14
      * @return string
Please login to merge, or discard this patch.