Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

PHPCS

  • Loading branch information...
commit 88f55357faa411cb1a120acd2231af94fa9281d0 1 parent b59d938
@CloCkWeRX CloCkWeRX authored
Showing with 59 additions and 43 deletions.
  1. +55 −41 HTTP/Download2.php
  2. +4 −2 package.xml
View
96 HTTP/Download2.php
@@ -220,8 +220,7 @@ class HTTP_Download2
*
* Set supplied parameters.
*
- * @access public
- * @param array $params associative array of parameters
+ * @param array $params associative array of parameters
* <strong>one of:</strong>
* <ul>
* <li>'file' => path to file for download</li>
@@ -248,7 +247,7 @@ class HTTP_Download2
*
* @see HTTP_Download2::setContentDisposition()
*/
- function __construct($params = array())
+ public function __construct($params = array())
{
$this->HTTP = new HTTP_Header;
$this->_error = $this->setParams($params);
@@ -261,15 +260,15 @@ function __construct($params = array())
*
* Set supplied parameters through its accessor methods.
*
+ * @param array $params associative array of parameters
+ *
* @access public
* @return mixed Returns true on success or PEAR_Error on failure.
- * @param array $params associative array of parameters
- *
* @see HTTP_Download2::HTTP_Download2()
*/
function setParams($params)
{
- foreach((array) $params as $param => $value){
+ foreach ((array) $params as $param => $value) {
$method = 'set'. $param;
if (!method_exists($this, $method)) {
@@ -291,11 +290,12 @@ function setParams($params)
* Returns PEAR_Error (HTTP_DOWNLOAD2_E_INVALID_FILE) if file doesn't exist.
* Sends HTTP 404 or 403 status if $send_error is set to true.
*
+ * @param string $file path to file for download
+ * @param bool $send_error whether to send HTTP/404 or 403 if
+ * the file wasn't found or is not readable
+ *
* @access public
* @return mixed Returns true on success or PEAR_Error on failure.
- * @param string $file path to file for download
- * @param bool $send_error whether to send HTTP/404 or 403 if
- * the file wasn't found or is not readable
*/
function setFile($file, $send_error = true)
{
@@ -329,9 +329,10 @@ function setFile($file, $send_error = true)
*
* Set $data to null if you want to unset this.
*
+ * @param string $data raw data to send
+ *
* @access public
* @return void
- * @param $data raw data to send
*/
function setData($data = null)
{
@@ -346,9 +347,10 @@ function setData($data = null)
* Returns a PEAR_Error (HTTP_DOWNLOAD2_E_INVALID_RESOURCE) if $handle
* is no valid resource. Set $handle to null if you want to unset this.
*
+ * @param int $handle resource handle
+ *
* @access public
* @return mixed Returns true on success or PEAR_Error on failure.
- * @param int $handle resource handle
*/
function setResource($handle = null)
{
@@ -378,9 +380,10 @@ function setResource($handle = null)
* Returns a PEAR_Error (HTTP_DOWNLOAD2_E_NO_EXT_ZLIB)
* if ext/zlib is not available/loadable.
*
+ * @param bool $gzip whether to gzip the download
+ *
* @access public
* @return mixed Returns true on success or PEAR_Error on failure.
- * @param bool $gzip whether to gzip the download
*/
function setGzip($gzip = false)
{
@@ -403,9 +406,10 @@ function setGzip($gzip = false)
* If caching is disabled, we'll send the download no matter if it
* would actually be cached at the client side.
*
+ * @param bool $cache whether to allow caching
+ *
* @access public
* @return void
- * @param bool $cache whether to allow caching
*/
function setCache($cache = true)
{
@@ -418,20 +422,21 @@ function setCache($cache = true)
* If set to 'private' proxies shouldn't cache the response.
* This setting defaults to 'public' and affects only cached responses.
*
+ * @param string $cache private or public
+ * @param int $maxage maximum age of the client cache entry
+ *
* @access public
* @return bool
- * @param string $cache private or public
- * @param int $maxage maximum age of the client cache entry
*/
function setCacheControl($cache = 'public', $maxage = 0)
{
switch ($cache = strToLower($cache))
{
- case 'private':
- case 'public':
- $this->headers['Cache-Control'] =
- $cache .', must-revalidate, max-age='. abs($maxage);
- return true;
+ case 'private':
+ case 'public':
+ $this->headers['Cache-Control']
+ = $cache . ', must-revalidate, max-age='. abs($maxage);
+ return true;
break;
}
return false;
@@ -443,9 +448,10 @@ function setCacheControl($cache = 'public', $maxage = 0)
* Sets a user-defined ETag for cache-validation. The ETag is usually
* generated by HTTP_Download2 through its payload information.
*
+ * @param string $etag Entity tag used for strong cache validation.
+ *
* @access public
* @return void
- * @param string $etag Entity tag used for strong cache validation.
*/
function setETag($etag = null)
{
@@ -464,16 +470,18 @@ function setETag($etag = null)
* Returns PEAR_Error (HTTP_DOWNLOAD2_E_INVALID_PARAM) if $size is not
* greater than 0 bytes.
*
+ * @param int $bytes Amount of bytes to use as buffer.
+ *
* @access public
* @return mixed Returns true on success or PEAR_Error on failure.
- * @param int $bytes Amount of bytes to use as buffer.
*/
function setBufferSize($bytes = 2097152)
{
if (0 >= $bytes) {
throw new HTTP_Download2_Exception(
'Buffer size must be greater than 0 bytes ('. $bytes .' given)',
- HTTP_DOWNLOAD2_E_INVALID_PARAM);
+ HTTP_DOWNLOAD2_E_INVALID_PARAM
+ );
}
$this->bufferSize = abs($bytes);
return true;
@@ -498,10 +506,11 @@ function setBufferSize($bytes = 2097152)
* too much leads to proportionally increased network traffic due to added
* gzip header and bottom bytes around each chunk.
*
+ * @param float $seconds Amount of seconds to sleep after each
+ * chunk that has been sent.
+ *
* @access public
* @return void
- * @param float $seconds Amount of seconds to sleep after each
- * chunk that has been sent.
*/
function setThrottleDelay($seconds = 0)
{
@@ -516,9 +525,10 @@ function setThrottleDelay($seconds = 0)
* want do send an appropiate "Last-Modified" header, you should call this
* method.
*
+ * @param int $last_modified unix timestamp
+ *
* @access public
* @return void
- * @param int unix timestamp
*/
function setLastModified($last_modified)
{
@@ -528,15 +538,6 @@ function setLastModified($last_modified)
/**
* Set Content-Disposition header
*
- * @see HTTP_Download2::HTTP_Download2
- *
- * @access public
- * @return void
- * @param string $disposition whether to send the download
- * inline or as attachment
- * @param string $file_name the filename to display in
- * the browser's download window
- *
* <b>Example:</b>
* <code>
* $HTTP_Download2->setContentDisposition(
@@ -544,10 +545,20 @@ function setLastModified($last_modified)
* 'download.tgz'
* );
* </code>
+ *
+ * @param string $disposition whether to send the download
+ * inline or as attachment
+ * @param string $file_name the filename to display in
+ * the browser's download window
+ *
+ * @access public
+ * @see HTTP_Download2::HTTP_Download2
+ * @return void
*/
- function setContentDisposition( $disposition = HTTP_DOWNLOAD2_ATTACHMENT,
- $file_name = null)
- {
+ function setContentDisposition(
+ $disposition = HTTP_DOWNLOAD2_ATTACHMENT,
+ $file_name = null
+ ) {
$cd = $disposition;
if (isset($file_name)) {
$cd .= '; filename="' . $file_name . '"';
@@ -564,9 +575,10 @@ function setContentDisposition( $disposition = HTTP_DOWNLOAD2_ATTACHMENT,
* Returns PEAR_Error (HTTP_DOWNLOAD2_E_INVALID_CONTENT_TYPE) if
* $content_type doesn't seem to be valid.
*
+ * @param string $content_type content type of file for download
+ *
* @access public
* @return mixed Returns true on success or PEAR_Error on failure.
- * @param string $content_type content type of file for download
*/
function setContentType($content_type = 'application/x-octetstream')
{
@@ -602,8 +614,10 @@ function guessContentType()
{
if (class_exists('MIME_Type') || @include_once 'MIME/Type.php') {
if (PEAR::isError($mime_type = MIME_Type::autoDetect($this->file))) {
- throw new HTTP_Download2_Exception($mime_type->getMessage(),
- HTTP_DOWNLOAD2_E_INVALID_CONTENT_TYPE);
+ throw new HTTP_Download2_Exception(
+ $mime_type->getMessage(),
+ HTTP_DOWNLOAD2_E_INVALID_CONTENT_TYPE
+ );
}
return $this->setContentType($mime_type);
}
View
6 package.xml
@@ -27,7 +27,7 @@ It features:
<active>no</active>
</lead>
<date>2012-01-15</date>
- <time>00:36:33</time>
+ <time>01:05:20</time>
<version>
<release>0.1.0</release>
<api>0.1.0</api>
@@ -50,7 +50,7 @@ Avoid HTTP_Request for HTTP_Request2
</notes>
<contents>
<dir baseinstalldir="/" name="/">
- <file baseinstalldir="/" md5sum="4ef135aa813123afbe7cdb8c0f25f09d" name="HTTP/Download2.php" role="php" />
+ <file baseinstalldir="/" md5sum="d44aa5be8f6a184aa61832dda1621ee1" name="HTTP/Download2.php" role="php" />
<file baseinstalldir="/" md5sum="ffc234f271e0cc0bdc09695c0cbd2bd3" name="HTTP/Download2/Archive.php" role="php" />
<file baseinstalldir="/" md5sum="e5ec70c55cd5b2209591b4479d663911" name="HTTP/Download2/Exception.php" role="php" />
<file baseinstalldir="/" md5sum="38a6eaad8cdaaf21ead80c1035239800" name="HTTP/Download2/PgLOB.php" role="php" />
@@ -58,7 +58,9 @@ Avoid HTTP_Request for HTTP_Request2
<file baseinstalldir="/" md5sum="17a9344ab96a49384badd3fffcd8578e" name="tests/helper.inc" role="test" />
<file baseinstalldir="/" md5sum="0d46b0cfbadc621e69b010203277c9e0" name="tests/HTTP_Download2Test.php" role="test" />
<file baseinstalldir="/" md5sum="389304e2b994c9cfdb1468c3f0696106" name="tests/send.php" role="test" />
+ <file baseinstalldir="/" md5sum="300bcd9a71f78a0dfe82deb2cbb47289" name="build.xml" role="data" />
<file baseinstalldir="HTTP" md5sum="8f678fe06ab84642adc04a7c7bd3e34b" name="LICENSE" role="doc" />
+ <file baseinstalldir="/" md5sum="05d716cbeed7a3cd66f3268df3e8dc74" name="phpunit.xml" role="data" />
<file baseinstalldir="/" md5sum="8fbe49658d0fc380e28c59f458b61aa1" name="README" role="data" />
</dir>
</contents>
Please sign in to comment.
Something went wrong with that request. Please try again.