Skip to content

Commit

Permalink
Docblocks.
Browse files Browse the repository at this point in the history
  • Loading branch information
Drak committed Nov 2, 2011
1 parent d3a1993 commit b7732da
Show file tree
Hide file tree
Showing 9 changed files with 268 additions and 3 deletions.
5 changes: 5 additions & 0 deletions ParameterBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
*/
class ParameterBag
{
/**
* Paremeter storage.
*
* @var array
*/
protected $parameters;

/**
Expand Down
83 changes: 83 additions & 0 deletions Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,74 @@ class Request
*/
public $headers;

/**
* @var string
*/
protected $content;

/**
* @var string
*/
protected $languages;

/**
* @var string
*/
protected $charsets;

/**
* @var string
*/
protected $acceptableContentTypes;

/**
* @var string
*/
protected $pathInfo;

/**
* @var string
*/
protected $requestUri;

/**
* @var string
*/
protected $baseUrl;

/**
* @var string
*/
protected $basePath;

/**
* @var string
*/
protected $method;

/**
* @var string
*/
protected $format;

/**
* @var \Symfony\Component\HttpFoundation\Session
*/
protected $session;

/**
* @var string
*/
protected $locale;

/**
* @var string
*/
protected $defaultLocale = 'en';

/**
* @var string
*/
static protected $formats;

/**
Expand Down Expand Up @@ -894,16 +948,35 @@ public function setRequestFormat($format)
$this->format = $format;
}

/**
* Set defaul locale.
*
* @param string $locale
*
* @api
*/
public function setDefaultLocale($locale)
{
$this->setPhpDefaultLocale($this->defaultLocale = $locale);
}

/**
* Set locale.
*
* @param string $locale
*
* @api
*/
public function setLocale($locale)
{
$this->setPhpDefaultLocale($this->locale = $locale);
}

/**
* Get locale.
*
* @return string
*/
public function getLocale()
{
return null === $this->locale ? $this->defaultLocale : $this->locale;
Expand Down Expand Up @@ -1145,6 +1218,11 @@ protected function prepareRequestUri()
return $requestUri;
}

/**
* Prepare base URL.
*
* @return string
*/
protected function prepareBaseUrl()
{
$filename = basename($this->server->get('SCRIPT_FILENAME'));
Expand Down Expand Up @@ -1280,6 +1358,11 @@ static protected function initializeFormats()
);
}

/**
* Set PHP default locale.
*
* @param string $locale
*/
private function setPhpDefaultLocale($locale)
{
// if either the class Locale doesn't exist, or an exception is thrown when
Expand Down
46 changes: 45 additions & 1 deletion RequestMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,31 @@
*/
class RequestMatcher implements RequestMatcherInterface
{
/**
* @var string
*/
private $path;

/**
* @var string
*/
private $host;

/**
* @var string
*/
private $methods;

/**
* @var string
*/
private $ip;

/**
* Attributes.
*
* @var array
*/
private $attributes;

public function __construct($path = null, $host = null, $methods = null, $ip = null, array $attributes = array())
Expand Down Expand Up @@ -122,6 +143,14 @@ public function matches(Request $request)
return true;
}

/**
* Validates and IP address.
*
* @param string $requestIp
* @param string $ip
*
* @return boolean True valid, false if not.
*/
protected function checkIp($requestIp, $ip)
{
// IPv6 address
Expand All @@ -132,6 +161,14 @@ protected function checkIp($requestIp, $ip)
}
}

/**
* Validates an IPv4 address.
*
* @param string $requestIp
* @param string $ip
*
* @return boolean True valid, false if not.
*/
protected function checkIp4($requestIp, $ip)
{
if (false !== strpos($ip, '/')) {
Expand All @@ -149,8 +186,15 @@ protected function checkIp4($requestIp, $ip)
}

/**
* Validates an IPv6 address.
*
* @author David Soria Parra <dsp at php dot net>
* @see https://github.com/dsp/v6tools
*
* @param string $requestIp
* @param string $ip
*
* @return boolean True valid, false if not.
*/
protected function checkIp6($requestIp, $ip)
{
Expand All @@ -174,4 +218,4 @@ protected function checkIp6($requestIp, $ip)

return true;
}
}
}
70 changes: 69 additions & 1 deletion Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,36 @@ class Response
*/
public $headers;

/**
* @var string
*/
protected $content;

/**
* @var string
*/
protected $version;

/**
* @var integer
*/
protected $statusCode;

/**
* @var string
*/
protected $statusText;

/**
* @var string
*/
protected $charset;

/**
* Status codes translation table.
*
* @var array
*/
static public $statusTexts = array(
100 => 'Continue',
101 => 'Switching Protocols',
Expand Down Expand Up @@ -826,6 +850,10 @@ public function isNotModified(Request $request)

// http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
/**
* Is response valid?
*
* @return boolean
*
* @api
*/
public function isInvalid()
Expand All @@ -834,6 +862,10 @@ public function isInvalid()
}

/**
* Is response informative?
*
* @return boolean
*
* @api
*/
public function isInformational()
Expand All @@ -842,6 +874,10 @@ public function isInformational()
}

/**
* Is response successful?
*
* @return boolean
*
* @api
*/
public function isSuccessful()
Expand All @@ -850,6 +886,10 @@ public function isSuccessful()
}

/**
* Is the response a redirect?
*
* @return boolean
*
* @api
*/
public function isRedirection()
Expand All @@ -858,6 +898,10 @@ public function isRedirection()
}

/**
* Is there a client error?
*
* @return boolean
*
* @api
*/
public function isClientError()
Expand All @@ -866,6 +910,10 @@ public function isClientError()
}

/**
* Was there a server side error?
*
* @return boolean
*
* @api
*/
public function isServerError()
Expand All @@ -874,6 +922,10 @@ public function isServerError()
}

/**
* Is the response OK?
*
* @return boolean
*
* @api
*/
public function isOk()
Expand All @@ -882,6 +934,10 @@ public function isOk()
}

/**
* Is the reponse forbidden?
*
* @return boolean
*
* @api
*/
public function isForbidden()
Expand All @@ -890,6 +946,10 @@ public function isForbidden()
}

/**
* Is the response a not found error?
*
* @return boolean
*
* @api
*/
public function isNotFound()
Expand All @@ -898,6 +958,10 @@ public function isNotFound()
}

/**
* Is the response a redirect of some form?
*
* @return boolean
*
* @api
*/
public function isRedirect($location = null)
Expand All @@ -906,10 +970,14 @@ public function isRedirect($location = null)
}

/**
* Is the response empty?
*
* @return boolean
*
* @api
*/
public function isEmpty()
{
return in_array($this->statusCode, array(201, 204, 304));
}
}
}
Loading

0 comments on commit b7732da

Please sign in to comment.