Skip to content

Commit

Permalink
Improve components interface
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Sep 22, 2015
1 parent 59a0298 commit 5a6e225
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/Components/Fragment.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function getUriComponent()
{
$component = $this->__toString();
if (!empty($component)) {
$component = '#'.$component;
$component = FragmentInterface::DELIMITER.$component;
}

return $component;
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Port.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected function validate($port)
*/
public function getUriComponent()
{
return null === $this->data ? '' : ':'.$this->data;
return null === $this->data ? '' : PortInterface::DELIMITER.$this->data;
}

/**
Expand Down
9 changes: 1 addition & 8 deletions src/Components/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@ class Query implements QueryInterface
*/
protected static $separator = '&';

/**
* string delimiter
*
* @var string
*/
protected static $delimiter = '?';

/**
* a new instance
*
Expand Down Expand Up @@ -125,7 +118,7 @@ public function getUriComponent()
{
$query = $this->__toString();
if (!empty($query)) {
$query = static::$delimiter.$query;
$query = QueryInterface::DELIMITER.$query;
}

return $query;
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Scheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function getUriComponent()
{
$component = $this->__toString();
if (!empty($component)) {
$component .= ':';
$component .= SchemeInterface::DELIMITER;
}

return $component;
Expand Down
4 changes: 2 additions & 2 deletions src/Components/UserInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function __toString()

$pass = $this->pass->__toString();
if (!empty($pass)) {
$userInfo .= ':'.$pass;
$userInfo .= UserInfoInterface::SEPARATOR.$pass;
}

return $userInfo;
Expand All @@ -97,7 +97,7 @@ public function getUriComponent()
{
$component = $this->__toString();
if (!empty($component)) {
$component .= '@';
$component .= UserInfoInterface::DELIMITER;
}

return $component;
Expand Down
6 changes: 6 additions & 0 deletions src/Interfaces/Fragment.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@
*/
interface Fragment extends Component
{
/**
* URI component delimiter.
*
* @var string
*/
const DELIMITER = '#';
}
7 changes: 7 additions & 0 deletions src/Interfaces/Port.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
*/
interface Port extends Component
{
/**
* URI component delimiter.
*
* @var string
*/
const DELIMITER = ':';

/**
* Maximum port number.
*
Expand Down
7 changes: 7 additions & 0 deletions src/Interfaces/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
*/
interface Query extends Collection, Component
{
/**
* URI component delimiter.
*
* @var string
*/
const DELIMITER = '?';

/**
* Retrieves a single query parameter.
*
Expand Down
6 changes: 6 additions & 0 deletions src/Interfaces/Scheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@
*/
interface Scheme extends Component
{
/**
* URI component delimiter.
*
* @var string
*/
const DELIMITER = ':';
}
14 changes: 14 additions & 0 deletions src/Interfaces/UserInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@
*/
interface UserInfo extends UriPart
{
/**
* URI component delimiter.
*
* @var string
*/
const DELIMITER = '@';

/**
* URI component separator.
*
* @var string
*/
const SEPARATOR = ':';

/**
* Retrieve the user component of the URI User Info part
*
Expand Down

0 comments on commit 5a6e225

Please sign in to comment.