Skip to content

Commit 7c0a70e

Browse files
committed
Initial upload
Signed-off-by: Josantonius <[email protected]>
1 parent 33b27fc commit 7c0a70e

File tree

6 files changed

+34
-17
lines changed

6 files changed

+34
-17
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Added `Josantonius\Url\Url::isSSL()` method.
88
* Added `Josantonius\Url\Url::getDomain()` method.
99
* Added `Josantonius\Url\Url::getUri()` method.
10+
* Added `Josantonius\Url\Url::getUriMethods()` method.
1011
* Added `Josantonius\Url\Url::getPort()` method.
1112
* Added `Josantonius\Url\Url::addBackslash()` method.
1213
* Added `Josantonius\Url\Url::previous()` method.

README-ES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Url::getProtocol();
5353
Url::isSSL();
5454
Url::getDomain();
5555
Url::getUri();
56+
Url::getUriMethods();
5657
Url::getPort();
5758
Url::addBackslash();
5859
Url::previous();
@@ -143,6 +144,7 @@ UrlTest::testGetProtocol();
143144
UrlTest::testIsSSL();
144145
UrlTest::getDomain();
145146
UrlTest::testGetUri();
147+
UrlTest::testGetUriMethods();
146148
UrlTest::testGetPort();
147149
UrlTest::testAddBackslash();
148150
UrlTest::testPrevious();

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Url::getProtocol();
5353
Url::isSSL();
5454
Url::getDomain();
5555
Url::getUri();
56+
Url::getUriMethods();
5657
Url::getPort();
5758
Url::addBackslash();
5859
Url::previous();
@@ -144,6 +145,7 @@ UrlTest::testGetProtocol();
144145
UrlTest::testIsSSL();
145146
UrlTest::getDomain();
146147
UrlTest::testGetUri();
148+
UrlTest::testGetUriMethods();
147149
UrlTest::testGetPort();
148150
UrlTest::testAddBackslash();
149151
UrlTest::testPrevious();

src/Exception/UrlException.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,11 @@
22
/**
33
* Library for urls manipulation.
44
*
5-
* @category JST
6-
* @package Url
7-
* @subpackage UrlException
85
* @author Josantonius - [email protected]
96
* @copyright Copyright (c) 2017 JST PHP Framework
107
* @license https://opensource.org/licenses/MIT - The MIT License (MIT)
11-
* @version 1.0.0
128
* @link https://github.com/Josantonius/PHP-Url
13-
* @since File available since 1.0.0 - Update: 2017-02-02
9+
* @since File available since 1.0.0 - Update: 2017-02-14
1410
*/
1511

1612
namespace Josantonius\Url\Exception;

src/Url.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@
22
/**
33
* Library for urls manipulation.
44
*
5-
* @category JST
6-
* @package Url
7-
* @subpackage Url
85
* @author Josantonius - [email protected]
96
* @author David Carr - [email protected]
107
* @copyright Copyright (c) 2017 JST PHP Framework
118
* @license https://opensource.org/licenses/MIT - The MIT License (MIT)
12-
* @version 1.0.0
139
* @link https://github.com/Josantonius/PHP-Url
14-
* @since File available since 1.0.0 - Update: 2017-02-02
10+
* @since File available since 1.0.0 - Update: 2017-02-14
1511
*/
1612

1713
namespace Josantonius\Url;
@@ -90,7 +86,7 @@ public static function getDomain() {
9086
}
9187

9288
/**
93-
* Get path of the url.
89+
* Get uri.
9490
*
9591
* @since 1.0.0
9692
*
@@ -101,6 +97,20 @@ public static function getUri() {
10197
return parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
10298
}
10399

100+
/**
101+
* Remove subdirectories from uri if they exist.
102+
*
103+
* @since 1.0.0
104+
*
105+
* @return string → method1/method2/method3
106+
*/
107+
public static function getUriMethods() {
108+
109+
$subfolder = trim(str_replace($_SERVER["DOCUMENT_ROOT"], '', getcwd()), '/');
110+
111+
return trim(str_replace($subfolder, '', static::getUri()), '/');
112+
}
113+
104114
/**
105115
* Get the server port.
106116
*

tests/UrlTest.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,11 @@
22
/**
33
* Library for urls manipulation.
44
*
5-
* @category JST
6-
* @package Url
7-
* @subpackage UrlTest
85
* @author Josantonius - [email protected]
96
* @copyright Copyright (c) 2017 JST PHP Framework
107
* @license https://opensource.org/licenses/MIT - The MIT License (MIT)
11-
* @version 1.0.0
128
* @link https://github.com/Josantonius/PHP-Url
13-
* @since File available since 1.0.0 - Update: 2017-02-02
9+
* @since File available since 1.0.0 - Update: 2017-02-14
1410
*/
1511

1612
namespace Josantonius\Url\Tests;
@@ -65,7 +61,7 @@ public static function getDomain() {
6561
}
6662

6763
/**
68-
* Get path of the url.
64+
* Get uri.
6965
*
7066
* @since 1.0.0
7167
*/
@@ -74,6 +70,16 @@ public static function testGetUri() {
7470
echo '<pre>'; var_dump(Url::getUri()); echo '</pre>';
7571
}
7672

73+
/**
74+
* Remove subdirectories from uri if they exist.
75+
*
76+
* @since 1.0.0
77+
*/
78+
public static function testGetUriMethods() {
79+
80+
echo '<pre>'; var_dump(Url::getUriMethods()); echo '</pre>';
81+
}
82+
7783
/**
7884
* Get the server port.
7985
*

0 commit comments

Comments
 (0)