Passed
Push — master ( f0080c...24771a )
by Pouya
01:18
created
src/RemovePathWithPointPointSlash.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
         }
31 31
         if ($this->getStarterPath() === ($this->getScheme() . '://')) {
32 32
             $this->setStarterPath($this->getStarterPath() . $this->getDomain());
33
-        } elseif ($this->getStarterPath() === ($this->getScheme(). ':/')) {
33
+        } elseif ($this->getStarterPath() === ($this->getScheme() . ':/')) {
34 34
             $this->setStarterPath($this->getStarterPath() . '/' . $this->getDomain());
35 35
         }
36 36
         return $this->getStarterPath() . $this->getPath();
Please login to merge, or discard this patch.
src/ConvertToAbsolutePath.php 2 patches
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
     /** @var string|null */
38 38
     private $baseTag = null;
39 39
     /** @var string|null  */
40
-    private $starterPath=null;
40
+    private $starterPath = null;
41 41
     /**
42 42
      * @var array|false|int|string|null
43 43
      */
@@ -56,9 +56,9 @@  discard block
 block discarded – undo
56 56
      * ConvertToAbsolutePath constructor.
57 57
      * @param $pagePath
58 58
      */
59
-    public function __construct($pagePath=NULL)
59
+    public function __construct($pagePath = NULL)
60 60
     {
61
-        if(isset($pagePath)) {
61
+        if (isset($pagePath)) {
62 62
             $this->setPagePath($pagePath);
63 63
         }
64 64
     }
@@ -77,24 +77,24 @@  discard block
 block discarded – undo
77 77
             return '';
78 78
         }
79 79
         // Convert //www.google.com to http://www.google.com
80
-        if($this->isPathWithoutScheme($path)) {
80
+        if ($this->isPathWithoutScheme($path)) {
81 81
             return 'http:' . $path;
82 82
         }
83 83
         // If the path is a fragment or query string,
84 84
         // it will be appended to the base url
85
-        if($this->isHaveQueryOrFragment($path)) {
85
+        if ($this->isHaveQueryOrFragment($path)) {
86 86
             return $this->getStarterPath() . $path;
87 87
         }
88 88
         // Treat paths with doc root, i.e, /about
89
-        if($this->isPathStartWithSlash($path)) {
89
+        if ($this->isPathStartWithSlash($path)) {
90 90
             return $this->onlySitePath($this->getStarterPath()) . $path;
91 91
         }
92 92
         // For paths like ./foo, it will be appended to the furthest directory
93
-        if($this->isPathStartWithPointSlash($path)) {
93
+        if ($this->isPathStartWithPointSlash($path)) {
94 94
             return $this->uptoLastDir($this->getStarterPath()) . substr($path, 2);
95 95
         }
96 96
         // Convert paths like ../foo or ../../bar
97
-        if($this->isPathStartWithTwoPointSlash($path)) {
97
+        if ($this->isPathStartWithTwoPointSlash($path)) {
98 98
             $removeTwoPointSlash = new RemovePathWithPointPointSlash($this, $path);
99 99
             return $removeTwoPointSlash->compute();
100 100
         }
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
         $parseUrl = parse_url($url);
112 112
         if ($this->isCorrectUrl($parseUrl)) {
113 113
             return '';
114
-        } elseif(isset($parseUrl['scheme'])){
114
+        } elseif (isset($parseUrl['scheme'])) {
115 115
             return $parseUrl['scheme'] . '://' . $parseUrl['host'];
116
-        } else {
116
+        }else {
117 117
             return $parseUrl['host'];
118 118
         }
119 119
     }
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
     public function upToLastDir($url) {
124 124
         $parseUrl = parse_url($url);
125 125
         $path = '';
126
-        if(isset($parseUrl['path'])) {
126
+        if (isset($parseUrl['path'])) {
127 127
                     $path = preg_replace('/\/([^\/]+)$/i', '', $parseUrl['path']);
128 128
         }
129 129
         return rtrim($parseUrl['scheme'] . '://' . $parseUrl['host'] . $path, '/') . '/';
@@ -162,12 +162,12 @@  discard block
 block discarded – undo
162 162
      */
163 163
     public function getStarterPath(): string
164 164
     {
165
-        if($this->starterPath===null){
166
-            if($this->getBaseTag() === null) {
167
-                $this->starterPath =$this->getPagePath();
168
-            } elseif(array_key_exists('scheme', $this->getBaseTagParsing())){
169
-                $this->starterPath = $this->getBaseTag() ;
170
-            } else{
165
+        if ($this->starterPath === null) {
166
+            if ($this->getBaseTag() === null) {
167
+                $this->starterPath = $this->getPagePath();
168
+            } elseif (array_key_exists('scheme', $this->getBaseTagParsing())) {
169
+                $this->starterPath = $this->getBaseTag();
170
+            }else {
171 171
                 $this->starterPath = $this->getPagePathParsing()['scheme'] . '://' . $this->getPagePathParsing()['host'] . $this->getBaseTag();
172 172
             }
173 173
         }
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
     public function getDomain()
178 178
     {
179 179
         if ($this->domain === null) {
180
-            if($this->getBaseTag() === null) {
180
+            if ($this->getBaseTag() === null) {
181 181
                 $this->domain = $this->getPagePathParsing()['host'] . '/';
182
-            }elseif(array_key_exists('scheme', $this->getBaseTagParsing())){
182
+            }elseif (array_key_exists('scheme', $this->getBaseTagParsing())) {
183 183
                 $this->domain = $this->getBaseTagParsing()['host'] . '/';
184
-            }else{
184
+            }else {
185 185
                 $this->domain = $this->getPagePathParsing()['host'] . '/';
186 186
             }
187 187
         }
@@ -191,11 +191,11 @@  discard block
 block discarded – undo
191 191
     public function getScheme()
192 192
     {
193 193
         if ($this->scheme === null) {
194
-            if($this->getBaseTag() === null) {
194
+            if ($this->getBaseTag() === null) {
195 195
                 $this->scheme = $this->getPagePathParsing()['scheme'];
196
-            } elseif(array_key_exists('scheme', $this->getBaseTagParsing())){
196
+            } elseif (array_key_exists('scheme', $this->getBaseTagParsing())) {
197 197
                 $this->scheme = $this->getBaseTagParsing()['scheme'];
198
-            } else{
198
+            }else {
199 199
                 $this->scheme = $this->getPagePathParsing()['scheme'];
200 200
             }
201 201
         }
@@ -204,10 +204,10 @@  discard block
 block discarded – undo
204 204
 
205 205
     public function getBaseTagParsing()
206 206
     {
207
-        if($this->baseTagParsing == null) {
208
-            if(is_string($this->getBaseTag())) {
207
+        if ($this->baseTagParsing == null) {
208
+            if (is_string($this->getBaseTag())) {
209 209
                 $this->baseTagParsing = parse_url($this->getBaseTag());
210
-            } else {
210
+            }else {
211 211
                 $this->baseTagParsing = [];
212 212
             }
213 213
         }
@@ -216,10 +216,10 @@  discard block
 block discarded – undo
216 216
 
217 217
     public function getPagePathParsing()
218 218
     {
219
-        if($this->pagePathParsing == null) {
220
-            if(is_string($this->getPagePath())) {
219
+        if ($this->pagePathParsing == null) {
220
+            if (is_string($this->getPagePath())) {
221 221
                 $this->pagePathParsing = parse_url($this->getPagePath());
222
-            }else{
222
+            }else {
223 223
                 $this->pagePathParsing = [];
224 224
             }
225 225
         }
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -179,9 +179,9 @@  discard block
 block discarded – undo
179 179
         if ($this->domain === null) {
180 180
             if($this->getBaseTag() === null) {
181 181
                 $this->domain = $this->getPagePathParsing()['host'] . '/';
182
-            }elseif(array_key_exists('scheme', $this->getBaseTagParsing())){
182
+            } elseif(array_key_exists('scheme', $this->getBaseTagParsing())){
183 183
                 $this->domain = $this->getBaseTagParsing()['host'] . '/';
184
-            }else{
184
+            } else{
185 185
                 $this->domain = $this->getPagePathParsing()['host'] . '/';
186 186
             }
187 187
         }
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
         if($this->pagePathParsing == null) {
220 220
             if(is_string($this->getPagePath())) {
221 221
                 $this->pagePathParsing = parse_url($this->getPagePath());
222
-            }else{
222
+            } else{
223 223
                 $this->pagePathParsing = [];
224 224
             }
225 225
         }
Please login to merge, or discard this patch.