Skip to content
This repository has been archived by the owner on Mar 28, 2021. It is now read-only.

Commit

Permalink
prepare 1.0.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Jan 17, 2017
1 parent 387211c commit 83ec1e8
Show file tree
Hide file tree
Showing 50 changed files with 245 additions and 209 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

All Notable changes to `uri-manipulations` will be documented in this file

## Next
## 1.0.0 - 2017-01-17

### Added

- `League\Uri\Modifier\UriMiddlewareInterface`
- `League\Uri\Modifier\Exception`
- `League\Uri\Modifier\CallableAdapter`
- `League\Uri\Modifier\Pipeline::createFromCallable`
- `League\Uri\Modifier\Basename` uri middleware to update the URI dirname path
- `League\Uri\Modifier\Dirname` uri middleware to update the URI basename path
- `League\Uri\Modifier\AddRootLabel` uri middleware to update the URI dirname path
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"php" : ">=7.0",
"psr/http-message": "^1.0",
"league/uri-interfaces": "^1.0",
"league/uri-components": "1.*@beta"
"league/uri-components": "^1.0"
},
"require-dev": {
"league/uri-schemes": "^1.0",
Expand Down
9 changes: 5 additions & 4 deletions src/AddBasePath.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@
/**
* Add a base path the URI path
*
* @package League.uri
* @author Ignace Nyamagana Butera <[email protected]>
* @since 1.0.0
* @package League\Uri
* @subpackage League\Uri\Modifiers
* @author Ignace Nyamagana Butera <[email protected]>
* @since 1.0.0
*/
class AddBasePath implements UriMiddlewareInterface
{
use PathMiddlewareTrait;
use UriMiddlewareTrait;

/**
* A HierarchicalPath object
*
Expand Down
9 changes: 5 additions & 4 deletions src/AddLeadingSlash.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@
/**
* Add a leading slash to the URI path
*
* @package League.uri
* @author Ignace Nyamagana Butera <[email protected]>
* @since 1.0.0
* @package League\Uri
* @subpackage League\Uri\Modifiers
* @author Ignace Nyamagana Butera <[email protected]>
* @since 1.0.0
*/
class AddLeadingSlash implements UriMiddlewareInterface
{
use PathMiddlewareTrait;
use UriMiddlewareTrait;

/**
* Modify a URI part
*
Expand Down
7 changes: 4 additions & 3 deletions src/AddRootLabel.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
/**
* Add the root Label to the Host
*
* @package League.uri
* @author Ignace Nyamagana Butera <[email protected]>
* @since 1.0.0
* @package League\Uri
* @subpackage League\Uri\Modifiers
* @author Ignace Nyamagana Butera <[email protected]>
* @since 1.0.0
*/
class AddRootLabel implements UriMiddlewareInterface
{
Expand Down
9 changes: 5 additions & 4 deletions src/AddTrailingSlash.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@
/**
* Add a trailing slash to the URI path
*
* @package League.uri
* @author Ignace Nyamagana Butera <[email protected]>
* @since 1.0.0
* @package League\Uri
* @subpackage League\Uri\Modifiers
* @author Ignace Nyamagana Butera <[email protected]>
* @since 1.0.0
*/
class AddTrailingSlash implements UriMiddlewareInterface
{
use PathMiddlewareTrait;
use UriMiddlewareTrait;

/**
* Modify a URI part
*
Expand Down
7 changes: 4 additions & 3 deletions src/AppendLabel.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
/**
* Append a label to the URI host
*
* @package League.uri
* @author Ignace Nyamagana Butera <[email protected]>
* @since 1.0.0
* @package League\Uri
* @subpackage League\Uri\Modifiers
* @author Ignace Nyamagana Butera <[email protected]>
* @since 1.0.0
*/
class AppendLabel implements UriMiddlewareInterface
{
Expand Down
7 changes: 4 additions & 3 deletions src/AppendQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
/**
* Append a quey string to the URI query
*
* @package League.uri
* @author Ignace Nyamagana Butera <[email protected]>
* @since 1.0.0
* @package League\Uri
* @subpackage League\Uri\Modifiers
* @author Ignace Nyamagana Butera <[email protected]>
* @since 1.0.0
*/
class AppendQuery implements UriMiddlewareInterface
{
Expand Down
9 changes: 5 additions & 4 deletions src/AppendSegment.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@
/**
* Append a segment to the URI path
*
* @package League.uri
* @author Ignace Nyamagana Butera <[email protected]>
* @since 1.0.0
* @package League\Uri
* @subpackage League\Uri\Modifiers
* @author Ignace Nyamagana Butera <[email protected]>
* @since 1.0.0
*/
class AppendSegment implements UriMiddlewareInterface
{
use PathMiddlewareTrait;
use UriMiddlewareTrait;

/**
* The path to append
*
Expand Down
9 changes: 5 additions & 4 deletions src/Basename.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@
/**
* Path component extension modifier
*
* @package League.uri
* @author Ignace Nyamagana Butera <[email protected]>
* @since 1.0.0
* @package League\Uri
* @subpackage League\Uri\Modifiers
* @author Ignace Nyamagana Butera <[email protected]>
* @since 1.0.0
*/
class Basename implements UriMiddlewareInterface
{
use PathMiddlewareTrait;
use UriMiddlewareTrait;

/**
* The basename to use for URI modification
*
Expand Down
12 changes: 6 additions & 6 deletions src/CallableAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
namespace League\Uri\Modifiers;

/**
* A class to ease applying multiple modification
* on a URI object based on the pipeline pattern
* This class is based on league.pipeline
* An Adapter Class to convert a callable into
* an UriMiddlewareInterface implementing object
*
* @package League.uri
* @author Ignace Nyamagana Butera <[email protected]>
* @since 1.0.0
* @package League\Uri
* @subpackage League\Uri\Modifiers
* @author Ignace Nyamagana Butera <[email protected]>
* @since 1.0.0
*/
class CallableAdapter implements UriMiddlewareInterface
{
Expand Down
9 changes: 5 additions & 4 deletions src/DataUriParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@
/**
* Data Uri Paramaters Manipulator
*
* @package League.uri
* @author Ignace Nyamagana Butera <[email protected]>
* @since 1.0.0
* @package League\Uri
* @subpackage League\Uri\Modifiers
* @author Ignace Nyamagana Butera <[email protected]>
* @since 1.0.0
*/
class DataUriParameters implements UriMiddlewareInterface
{
use PathMiddlewareTrait;
use UriMiddlewareTrait;

/**
* The parameters to add
*
Expand Down
9 changes: 5 additions & 4 deletions src/DataUriToAscii.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@
/**
* Convert the Data URI to its ascii version
*
* @package League.uri
* @author Ignace Nyamagana Butera <[email protected]>
* @since 1.0.0
* @package League\Uri
* @subpackage League\Uri\Modifiers
* @author Ignace Nyamagana Butera <[email protected]>
* @since 1.0.0
*/
class DataUriToAscii implements UriMiddlewareInterface
{
use PathMiddlewareTrait;
use UriMiddlewareTrait;

/**
* Modify a URI part
*
Expand Down
9 changes: 5 additions & 4 deletions src/DataUriToBinary.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@
/**
* Convert the Data URI to its binary version
*
* @package League.uri
* @author Ignace Nyamagana Butera <[email protected]>
* @since 1.0.0
* @package League\Uri
* @subpackage League\Uri\Modifiers
* @author Ignace Nyamagana Butera <[email protected]>
* @since 1.0.0
*/
class DataUriToBinary implements UriMiddlewareInterface
{
use PathMiddlewareTrait;
use UriMiddlewareTrait;

/**
* Modify a URI part
*
Expand Down
2 changes: 1 addition & 1 deletion src/DecodeUnreservedCharacters.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* A class to Decode URI parts unreserved characters
*
* @package League.uri
* @package League\Uri
* @author Ignace Nyamagana Butera <[email protected]>
* @since 4.2.0
*/
Expand Down
9 changes: 5 additions & 4 deletions src/Dirname.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@
/**
* Path component extension modifier
*
* @package League.uri
* @author Ignace Nyamagana Butera <[email protected]>
* @since 1.0.0
* @package League\Uri
* @subpackage League\Uri\Modifiers
* @author Ignace Nyamagana Butera <[email protected]>
* @since 1.0.0
*/
class Dirname implements UriMiddlewareInterface
{
use PathMiddlewareTrait;
use UriMiddlewareTrait;

/**
* The dirname to use for URI modification
*
Expand Down
9 changes: 5 additions & 4 deletions src/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@
/**
* Path component extension modifier
*
* @package League.uri
* @author Ignace Nyamagana Butera <[email protected]>
* @since 1.0.0
* @package League\Uri
* @subpackage League\Uri\Modifiers
* @author Ignace Nyamagana Butera <[email protected]>
* @since 1.0.0
*/
class Extension implements UriMiddlewareInterface
{
use PathMiddlewareTrait;
use UriMiddlewareTrait;

/**
* The extension to use for URI modification
*
Expand Down
51 changes: 28 additions & 23 deletions src/Formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
/**
* A class to manipulate URI and URI components output
*
* @package League.uri
* @author Ignace Nyamagana Butera <[email protected]>
* @since 1.0.0
* @package League\Uri
* @subpackage League\Uri\Modifiers
* @author Ignace Nyamagana Butera <[email protected]>
* @since 1.0.0
*/
class Formatter implements EncodingInterface
{
Expand Down Expand Up @@ -72,10 +73,10 @@ public function setEncoding(int $enc_type)
static $enc_type_list;
if (null === $enc_type_list) {
$enc_type_list = [
EncodingInterface::RFC1738_ENCODING => 1,
EncodingInterface::RFC3986_ENCODING => 1,
EncodingInterface::RFC3987_ENCODING => 1,
EncodingInterface::NO_ENCODING => 1,
self::RFC1738_ENCODING => 1,
self::RFC3986_ENCODING => 1,
self::RFC3987_ENCODING => 1,
self::NO_ENCODING => 1,
];
}

Expand Down Expand Up @@ -167,25 +168,29 @@ public function __invoke($input)
*/
protected function formatUri($uri): string
{
$authority = null;

$scheme = $uri->getScheme();
if ('' !== $scheme) {
$scheme .= ':';
if ('' != $scheme) {
$scheme = $scheme.':';
}

$user_info = (new UserInfo())->withContent($uri->getUserInfo())->getContent($this->enc_type);
if ('' !== $user_info) {
$user_info .= '@';
$user_info = $uri->getUserInfo();
if ('' != $user_info) {
$authority .= (new UserInfo())->withContent($user_info)->getContent($this->enc_type).'@';
}

$host = (new Host($uri->getHost()))->getContent($this->enc_type);
$host = $uri->getHost();
if ('' != $host) {
$authority .= (new Host($host))->getContent($this->enc_type);
}

$port = $uri->getPort();
if ('' != $port) {
$port = ':'.$port;
if (null !== $port) {
$authority .= ':'.$port;
}

$authority = $user_info.$host.$port;
if ('' != $authority) {
if (null !== $authority) {
$authority = '//'.$authority;
}

Expand All @@ -194,14 +199,14 @@ protected function formatUri($uri): string
$path = '/'.$path;
}

$query = Query::build(Query::parse($uri->getQuery()), $this->query_separator, $this->enc_type);
if ($this->preserve_query || '' != $query) {
$query = '?'.$query;
$query = $uri->getQuery();
if ('' != $query || $this->preserve_query) {
$query = '?'.Query::build(Query::parse((string) $query), $this->query_separator, $this->enc_type);
}

$fragment = (new Fragment($uri->getFragment()))->getContent($this->enc_type);
if ($this->preserve_fragment || '' != $fragment) {
$fragment = '#'.$fragment;
$fragment = $uri->getFragment();
if ('' != $fragment || $this->preserve_fragment) {
$fragment = '#'.(new Fragment($fragment))->getContent($this->enc_type);
}

return $scheme.$authority.$path.$query.$fragment;
Expand Down
Loading

0 comments on commit 83ec1e8

Please sign in to comment.