Skip to content

Commit

Permalink
rename uri_get_meta_data to uri_getinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Jul 9, 2016
1 parent d793b2b commit 4b4337f
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 35 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -14,6 +14,7 @@ All Notable changes to `League\Uri` will be documented in this file
- `Host::createFromLabels` to replace `Host::createFromArray`
- `Query::createFromPairs` to replace `Query::createFromArray`
- `UserInfo::createFromString` to create a UserInfo object from a given string
- `League\Uri\uri_getinfo` function to return URI reference state.

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion src/Modifiers/Normalize.php
Expand Up @@ -38,7 +38,7 @@ public function __invoke($uri)
]);

$path = $uri->getPath();
if (!\League\Uri\uri_get_meta_data($uri)['relative_path']) {
if (!\League\Uri\uri_getinfo($uri)['relative_path']) {
$modifier = $modifier->pipe(new RemoveDotSegments());
}

Expand Down
2 changes: 1 addition & 1 deletion src/Modifiers/Relativize.php
Expand Up @@ -39,7 +39,7 @@ class Relativize extends AbstractUriModifier
*/
public function __construct($uri)
{
if (!\League\Uri\uri_get_meta_data($uri)['absolute_uri']) {
if (!\League\Uri\uri_getinfo($uri)['absolute_uri']) {
throw new InvalidArgumentException('The Base URI must be an Absolute URI');
}

Expand Down
2 changes: 1 addition & 1 deletion src/Modifiers/Resolve.php
Expand Up @@ -48,7 +48,7 @@ public function __construct($uri)
*/
public function __invoke($payload)
{
$meta = \League\Uri\uri_get_meta_data($payload);
$meta = \League\Uri\uri_getinfo($payload);
$path = $payload->getPath();
if ($meta['absolute_uri']) {
return $payload
Expand Down
6 changes: 3 additions & 3 deletions src/functions.php
Expand Up @@ -29,8 +29,8 @@
* <li>relative_path: Tell whether the URI is a relative_path relative reference
* </ul>
*
* @link https://tools.ietf.org/html/rfc3986#section_4.2
* @link https://tools.ietf.org/html/rfc3986#section_4.3
* @link https://tools.ietf.org/html/rfc3986#section-4.2
* @link https://tools.ietf.org/html/rfc3986#section-4.3
* @since 4.2.0
*
* @param Uri|UriInterface $uri
Expand All @@ -39,7 +39,7 @@
*
* @return array
*/
function uri_get_meta_data($uri)
function uri_getinfo($uri)
{
if (!$uri instanceof Uri && !$uri instanceof UriInterface) {
throw new InvalidArgumentException(
Expand Down
2 changes: 1 addition & 1 deletion src/functions_include.php
@@ -1,6 +1,6 @@
<?php

// Don't redefine the functions if included multiple times.
if (!function_exists('League\Uri\uri_get_meta_data')) {
if (!function_exists('League\Uri\uri_getinfo')) {
require __DIR__.'/functions.php';
}
61 changes: 33 additions & 28 deletions test/FunctionsTest.php
Expand Up @@ -14,53 +14,58 @@ class FunctionsTest extends PHPUnit_Framework_TestCase
/**
* @dataProvider uriProvider
*/
public function testStat($uri, $absolute_uri, $network_path, $absolute_path, $relative_path)
public function testStat($uri, $infos)
{
$stats = Uri\uri_get_meta_data($uri);
$this->assertInternalType('array', $stats);
$this->assertSame($absolute_uri, $stats['absolute_uri']);
$this->assertSame($network_path, $stats['network_path']);
$this->assertSame($absolute_path, $stats['absolute_path']);
$this->assertSame($relative_path, $stats['relative_path']);
$this->assertSame($infos, Uri\uri_getinfo($uri));
}

public function uriProvider()
{
return [
'absolute uri' => [
'uri' => HttpUri::createFromString('http://a/p?q#f'),
'absolute_uri' => true,
'network_path' => false,
'absolute_path' => false,
'relative_path' => false,
'infos' => [
'absolute_uri' => true,
'network_path' => false,
'absolute_path' => false,
'relative_path' => false,
],
],
'network relative uri' => [
'uri' => HttpUri::createFromString('//a/p?q#f'),
'absolute_uri' => false,
'network_path' => true,
'absolute_path' => false,
'relative_path' => false,
'infos' => [
'absolute_uri' => false,
'network_path' => true,
'absolute_path' => false,
'relative_path' => false,
],
],
'path absolute uri' => [
'uri' => HttpUri::createFromString('/p?q#f'),
'absolute_uri' => false,
'network_path' => false,
'absolute_path' => true,
'relative_path' => false,
'infos' => [
'absolute_uri' => false,
'network_path' => false,
'absolute_path' => true,
'relative_path' => false,
],
],
'path relative uri with non empty path' => [
'uri' => HttpUri::createFromString('p?q#f'),
'absolute_uri' => false,
'network_path' => false,
'absolute_path' => false,
'relative_path' => true,
'infos' => [
'absolute_uri' => false,
'network_path' => false,
'absolute_path' => false,
'relative_path' => true,
]
],
'path relative uri with empty' => [
'uri' => HttpUri::createFromString('?q#f'),
'absolute_uri' => false,
'network_path' => false,
'absolute_path' => false,
'relative_path' => true,
'infos' => [
'absolute_uri' => false,
'network_path' => false,
'absolute_path' => false,
'relative_path' => true,
],
],
];
}
Expand All @@ -70,6 +75,6 @@ public function uriProvider()
*/
public function testStatThrowsInvalidArgumentException()
{
Uri\uri_get_meta_data('http://example.com');
Uri\uri_getinfo('http://example.com');
}
}

0 comments on commit 4b4337f

Please sign in to comment.