aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2015-05-20 10:18:53 +0200
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2015-05-20 10:18:53 +0200
commit256b059799953b75619a0d3a8dd9db0cfeb8c2e9 (patch)
tree613671d86f27e5dea1ec203f0419db3d9ae01a77
parentfa8586e669c9540ef95504ccb4a5241a56dec343 (diff)
downloadStream-256b059799953b75619a0d3a8dd9db0cfeb8c2e9.zip
Stream-256b059799953b75619a0d3a8dd9db0cfeb8c2e9.tar.gz
Stream-256b059799953b75619a0d3a8dd9db0cfeb8c2e9.tar.bz2
Move to PSR-1 and PSR-2.
-rw-r--r--Bucket.php95
-rw-r--r--Composite.php34
-rw-r--r--Context.php70
-rw-r--r--Exception.php10
-rw-r--r--Filter/Basic.php53
-rw-r--r--Filter/Exception.php10
-rw-r--r--Filter/Filter.php107
-rw-r--r--Filter/LateComputed.php29
-rw-r--r--IStream/Bufferable.php25
-rw-r--r--IStream/In.php43
-rw-r--r--IStream/Lockable.php13
-rw-r--r--IStream/Out.php40
-rw-r--r--IStream/Pathable.php16
-rw-r--r--IStream/Pointable.php19
-rw-r--r--IStream/Statable.php49
-rw-r--r--IStream/Structural.php37
-rw-r--r--IStream/Touchable.php39
-rw-r--r--Stream.php262
-rw-r--r--Wrapper/Exception.php10
-rw-r--r--Wrapper/IWrapper/File.php37
-rw-r--r--Wrapper/IWrapper/IWrapper.php13
-rw-r--r--Wrapper/IWrapper/Stream.php52
-rw-r--r--Wrapper/Wrapper.php52
23 files changed, 480 insertions, 635 deletions
diff --git a/Bucket.php b/Bucket.php
index 00d366a..9b07082 100644
--- a/Bucket.php
+++ b/Bucket.php
@@ -8,7 +8,7 @@
*
* New BSD License
*
- * Copyright © 2007-2015, Ivan Enderlin. All rights reserved.
+ * Copyright © 2007-2015, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -41,13 +41,11 @@ namespace Hoa\Stream;
*
* Manipulate stream buckets through brigades.
*
- * @author Ivan Enderlin <ivan.enderlin@hoa-project.net>
- * @copyright Copyright © 2007-2015 Ivan Enderlin.
+ * @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
-
-class Bucket {
-
+class Bucket
+{
/**
* Whether the stream is already a brigade.
*
@@ -65,21 +63,21 @@ class Bucket {
/**
* Type of the bucket.
*
- * @var \Hoa\Stream\Bucket bool
+ * @var bool
*/
protected $_type = null;
/**
* Brigade.
*
- * @var \Hoa\Stream\Bucket resource
+ * @var resource
*/
protected $_brigade = null;
/**
* Bucket.
*
- * @var \Hoa\Stream\Bucket object
+ * @var \Hoa\Stream\Bucket
*/
protected $_bucket = null;
@@ -90,21 +88,19 @@ class Bucket {
* If a stream is given (with the constant self::IS_A_STREAM), it will
* create a brigade automatically.
*
- * @access public
* @param resource &$brigade A stream or a brigade.
* @param bool $is Specify if $brigade is a stream or a
* brigade, given by self::IS_A_* constant.
* @param string $buffer Stream buffer.
* @return void
*/
- public function __construct ( &$brigade, $is = self::IS_A_BRIGADE, $buffer = '' ) {
-
+ public function __construct(&$brigade, $is = self::IS_A_BRIGADE, $buffer = '')
+ {
$this->setType($is);
- if(self::IS_A_BRIGADE === $this->getType())
+ if (self::IS_A_BRIGADE === $this->getType()) {
$this->setBrigade($brigade);
- else {
-
+ } else {
$this->setBucket(stream_bucket_new($brigade, $buffer));
$bucket = $this->getBucket();
$this->setBrigade($bucket);
@@ -117,11 +113,10 @@ class Bucket {
* Test the end-of-bucket.
* When testing, set the new bucket object.
*
- * @access public
* @return bool
*/
- public function eob ( ) {
-
+ public function eob()
+ {
$this->_bucket = null;
return false == $this->getBucket();
@@ -130,12 +125,11 @@ class Bucket {
/**
* Append bucket to the brigade.
*
- * @access public
* @param \Hoa\Stream\Bucket $bucket Bucket to add.
* @return void
*/
- public function append ( Bucket $bucket ) {
-
+ public function append(Bucket $bucket)
+ {
stream_bucket_append($this->getBrigade(), $bucket->getBucket());
return;
@@ -144,12 +138,11 @@ class Bucket {
/**
* Prepend bucket to the brigade.
*
- * @access public
* @param \Hoa\Stream\Bucket $bucket Bucket to add.
* @return void
*/
- public function prepend ( Bucket $bucket ) {
-
+ public function prepend(Bucket $bucket)
+ {
stream_bucket_prepend($this->getBrigade(), $bucket->getBucket());
return;
@@ -158,12 +151,11 @@ class Bucket {
/**
* Set type.
*
- * @access protected
* @param bool $type Type. Please, see self::IS_A_* constants.
* @return bool
*/
- protected function setType ( $type ) {
-
+ protected function setType($type)
+ {
$old = $this->_type;
$this->_type = $type;
@@ -173,23 +165,21 @@ class Bucket {
/**
* Get type.
*
- * @access public
* @return bool
*/
- public function getType ( ) {
-
+ public function getType()
+ {
return $this->_type;
}
/**
* Set bucket data.
*
- * @access public
* @param string $data Data to set.
* @retun string
*/
- public function setData ( $data ) {
-
+ public function setData($data)
+ {
$old = $this->getBucket()->data;
$this->getBucket()->data = $data;
$this->getBucket()->datalen = strlen($this->getBucket()->data);
@@ -200,13 +190,13 @@ class Bucket {
/**
* Get bucket data.
*
- * @access public
* @return string
*/
- public function getData ( ) {
-
- if(null === $this->getBucket())
+ public function getData()
+ {
+ if (null === $this->getBucket()) {
return null;
+ }
return $this->getBucket()->data;
}
@@ -214,13 +204,13 @@ class Bucket {
/**
* Get bucket length.
*
- * @access public
* @return int
*/
- public function getLength ( ) {
-
- if(null === $this->getBucket())
+ public function getLength()
+ {
+ if (null === $this->getBucket()) {
return 0;
+ }
return $this->getBucket()->datalen;
}
@@ -228,12 +218,11 @@ class Bucket {
/**
* Set the brigade.
*
- * @access protected
* @param resource &$brigade Brigade to add.
* @return resource
*/
- protected function setBrigade ( &$brigade ) {
-
+ protected function setBrigade(&$brigade)
+ {
$old = $this->_brigade;
$this->_brigade = $brigade;
@@ -243,23 +232,21 @@ class Bucket {
/**
* Get the brigade.
*
- * @access public
* @return resource
*/
- public function getBrigade ( ) {
-
+ public function getBrigade()
+ {
return $this->_brigade;
}
/**
* Set bucket.
*
- * @access protected
* @param resource $bucket Bucket.
* @return resource
*/
- protected function setBucket ( $bucket ) {
-
+ protected function setBucket($bucket)
+ {
$old = $this->_bucket;
$this->_bucket = $bucket;
@@ -269,13 +256,13 @@ class Bucket {
/**
* Get the current bucket.
*
- * @access protected
* @return mixed
*/
- protected function getBucket ( ) {
-
- if(null === $this->_bucket && self::IS_A_BRIGADE === $this->getType())
+ protected function getBucket()
+ {
+ if (null === $this->_bucket && self::IS_A_BRIGADE === $this->getType()) {
$this->_bucket = stream_bucket_make_writeable($this->getBrigade());
+ }
return $this->_bucket;
}
diff --git a/Composite.php b/Composite.php
index 9d6d87d..d8c1aca 100644
--- a/Composite.php
+++ b/Composite.php
@@ -8,7 +8,7 @@
*
* New BSD License
*
- * Copyright © 2007-2015, Ivan Enderlin. All rights reserved.
+ * Copyright © 2007-2015, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -41,24 +41,22 @@ namespace Hoa\Stream;
*
* Declare a composite stream, i.e. a stream that use stream.
*
- * @author Ivan Enderlin <ivan.enderlin@hoa-project.net>
- * @copyright Copyright © 2007-2015 Ivan Enderlin.
+ * @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
-
-abstract class Composite {
-
+abstract class Composite
+{
/**
* Current stream.
*
- * @var mixed object
+ * @var mixed
*/
protected $_stream = null;
/**
* Inner stream.
*
- * @var \Hoa\Stream object
+ * @var \Hoa\Stream
*/
protected $_innerStream = null;
@@ -67,12 +65,11 @@ abstract class Composite {
/**
* Set current stream.
*
- * @access protected
* @param object $stream Current stream.
* @return object
*/
- protected function setStream ( $stream ) {
-
+ protected function setStream($stream)
+ {
$old = $this->_stream;
$this->_stream = $stream;
@@ -82,23 +79,21 @@ abstract class Composite {
/**
* Get current stream.
*
- * @access protected
* @return object
*/
- protected function getStream ( ) {
-
+ protected function getStream()
+ {
return $this->_stream;
}
/**
* Set inner stream.
*
- * @access protected
* @param \Hoa\Stream $innerStream Inner stream.
* @return \Hoa\Stream
*/
- protected function setInnerStream ( Stream $innerStream ) {
-
+ protected function setInnerStream(Stream $innerStream)
+ {
$old = $this->_innerStream;
$this->_innerStream = $innerStream;
@@ -108,11 +103,10 @@ abstract class Composite {
/**
* Get inner stream.
*
- * @access public
* @return \Hoa\Stream
*/
- public function getInnerStream ( ) {
-
+ public function getInnerStream()
+ {
return $this->_innerStream;
}
}
diff --git a/Context.php b/Context.php
index bbf93cd..5a006e8 100644
--- a/Context.php
+++ b/Context.php
@@ -8,7 +8,7 @@
*
* New BSD License
*
- * Copyright © 2007-2015, Ivan Enderlin. All rights reserved.
+ * Copyright © 2007-2015, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -41,24 +41,22 @@ namespace Hoa\Stream;
*
* Make a multiton of stream contexts.
*
- * @author Ivan Enderlin <ivan.enderlin@hoa-project.net>
- * @copyright Copyright © 2007-2015 Ivan Enderlin.
+ * @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
-
-class Context {
-
+class Context
+{
/**
* Context ID.
*
- * @var \Hoa\Stream\Context string
+ * @var string
*/
protected $_id = null;
/**
* Multiton.
*
- * @var \Hoa\Stream\Context array
+ * @var array
*/
protected static $_instances = [];
@@ -67,11 +65,10 @@ class Context {
/**
* Construct a context.
*
- * @access public
* @return void
*/
- protected function __construct ( $id ) {
-
+ protected function __construct($id)
+ {
$this->_id = $id;
$this->_context = stream_context_create();
@@ -81,19 +78,19 @@ class Context {
/**
* Multiton.
*
- * @access public
* @param string $id ID.
* @return \Hoa\Stream\Context
- * @throw \Hoa\Stream\Exception
+ * @throws \Hoa\Stream\Exception
*/
- public static function getInstance ( $id ) {
+ public static function getInstance($id)
+ {
+ if (empty($id)) {
+ throw new Exception('Context ID must not be null.', 0);
+ }
- if(empty($id))
- throw new Exception(
- 'Context ID must not be null.', 0);
-
- if(false === static::contextExists($id))
+ if (false === static::contextExists($id)) {
static::$_instances[$id] = new static($id);
+ }
return static::$_instances[$id];
}
@@ -101,23 +98,21 @@ class Context {
/**
* Get context ID.
*
- * @access public
* @return string
*/
- public function getId ( ) {
-
+ public function getId()
+ {
return $this->_id;
}
/**
* Check if a context exists.
*
- * @access public
* @param string $id ID.
* @return bool
*/
- public static function contextExists ( $id ) {
-
+ public static function contextExists($id)
+ {
return array_key_exists($id, static::$_instances);
}
@@ -125,12 +120,11 @@ class Context {
* Set options.
* Please, see http://php.net/context.
*
- * @access public
* @param array $options Options.
* @return bool
*/
- public function setOptions ( Array $options ) {
-
+ public function setOptions(Array $options)
+ {
return stream_context_set_option($this->getContext(), $options);
}
@@ -138,45 +132,41 @@ class Context {
* Set parameters.
* Please, see http://php.net/context.params.
*
- * @access public
* @param array $parameters Parameters.
* @return bool
*/
- public function setParameters ( Array $parameters ) {
-
+ public function setParameters(Array $parameters)
+ {
return stream_context_set_params($this->getContext(), $parameters);
}
/**
* Get options.
*
- * @access public
* @return array
*/
- public function getOptions ( ) {
-
+ public function getOptions()
+ {
return stream_context_get_options($this->getContext());
}
/**
* Get parameters.
* .
- * @access public
* @return array
*/
- public function getParameters ( ) {
-
+ public function getParameters()
+ {
return stream_context_get_params($this->getContext());
}
/**
* Get context as a resource.
*
- * @access public
* @return resource
*/
- public function getContext ( ) {
-
+ public function getContext()
+ {
return $this->_context;
}
}
diff --git a/Exception.php b/Exception.php
index 99607da..1ac0a85 100644
--- a/Exception.php
+++ b/Exception.php
@@ -8,7 +8,7 @@
*
* New BSD License
*
- * Copyright © 2007-2015, Ivan Enderlin. All rights reserved.
+ * Copyright © 2007-2015, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -43,9 +43,9 @@ use Hoa\Core;
*
* Extending the \Hoa\Core\Exception class.
*
- * @author Ivan Enderlin <ivan.enderlin@hoa-project.net>
- * @copyright Copyright © 2007-2015 Ivan Enderlin.
+ * @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
-
-class Exception extends Core\Exception { }
+class Exception extends Core\Exception
+{
+}
diff --git a/Filter/Basic.php b/Filter/Basic.php
index 6412801..b2bdf4d 100644
--- a/Filter/Basic.php
+++ b/Filter/Basic.php
@@ -8,7 +8,7 @@
*
* New BSD License
*
- * Copyright © 2007-2015, Ivan Enderlin. All rights reserved.
+ * Copyright © 2007-2015, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -44,13 +44,11 @@ use Hoa\Stream;
* Basic filter. Force to implement some methods.
* Actually, it extends the php_user_filter class.
*
- * @author Ivan Enderlin <ivan.enderlin@hoa-project.net>
- * @copyright Copyright © 2007-2015 Ivan Enderlin.
+ * @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
-
-abstract class Basic extends \php_user_filter {
-
+abstract class Basic extends \php_user_filter
+{
/**
* Filter processed successfully with data available in the out bucket
* brigade.
@@ -102,7 +100,6 @@ abstract class Basic extends \php_user_filter {
* This method is called whenever data is read from or written to the attach
* stream.
*
- * @access public
* @param resource $in A resource pointing to a bucket brigade
* which contains one or more bucket
* objects containing data to be filtered.
@@ -119,13 +116,12 @@ abstract class Basic extends \php_user_filter {
* closing parameter will be set to true.
* @return int
*/
- public function filter ( $in, $out, &$consumed, $closing ) {
-
+ public function filter($in, $out, &$consumed, $closing)
+ {
$iBucket = new Stream\Bucket($in);
$oBucket = new Stream\Bucket($out);
- while(false === $iBucket->eob()) {
-
+ while (false === $iBucket->eob()) {
$consumed += $iBucket->getLength();
$oBucket->append($iBucket);
}
@@ -139,11 +135,10 @@ abstract class Basic extends \php_user_filter {
/**
* Called during instanciation of the filter class object.
*
- * @access public
* @return bool
*/
- public function onCreate ( ) {
-
+ public function onCreate()
+ {
return true;
}
@@ -151,23 +146,21 @@ abstract class Basic extends \php_user_filter {
* Called upon filter shutdown (typically, this is also during stream
* shutdown), and is executed after the flush method is called.
*
- * @access public
* @return void
*/
- public function onClose ( ) {
-
+ public function onClose()
+ {
return;
}
/**
* Set the filter name.
*
- * @access public
* @param string $name Filter name.
* @return string
*/
- public function setName ( $name ) {
-
+ public function setName($name)
+ {
$old = $this->filtername;
$this->filtername = $name;
@@ -177,12 +170,11 @@ abstract class Basic extends \php_user_filter {
/**
* Set the filter parameters.
*
- * @access public
* @param mixed $parameters Filter parameters.
* @return mixed
*/
- public function setParameters ( $parameters ) {
-
+ public function setParameters($parameters)
+ {
$old = $this->params;
$this->params = $parameters;
@@ -192,22 +184,20 @@ abstract class Basic extends \php_user_filter {
/**
* Get the filter name.
*
- * @access public
* @return string
*/
- public function getName ( ) {
-
+ public function getName()
+ {
return $this->filtername;
}
/**
* Get the filter parameters.
*
- * @access public
* @return mixed
*/
- public function getParameters ( ) {
-
+ public function getParameters()
+ {
return $this->params;
}
@@ -216,11 +206,10 @@ abstract class Basic extends \php_user_filter {
* Maybe available only during filter calls when the closing parameter is
* set to false.
*
- * @access public
* @return resource
*/
- public function getStream ( ) {
-
+ public function getStream()
+ {
return $this->stream;
}
}
diff --git a/Filter/Exception.php b/Filter/Exception.php
index 346f37f..36f78dd 100644
--- a/Filter/Exception.php
+++ b/Filter/Exception.php
@@ -8,7 +8,7 @@
*
* New BSD License
*
- * Copyright © 2007-2015, Ivan Enderlin. All rights reserved.
+ * Copyright © 2007-2015, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -43,9 +43,9 @@ use Hoa\Stream;
*
* Extending the \Hoa\Stream\Exception class.
*
- * @author Ivan Enderlin <ivan.enderlin@hoa-project.net>
- * @copyright Copyright © 2007-2015 Ivan Enderlin.
+ * @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
-
-class Exception extends Stream\Exception { }
+class Exception extends Stream\Exception
+{
+}
diff --git a/Filter/Filter.php b/Filter/Filter.php
index 3bfb943..b5de924 100644
--- a/Filter/Filter.php
+++ b/Filter/Filter.php
@@ -8,7 +8,7 @@
*
* New BSD License
*
- * Copyright © 2007-2015, Ivan Enderlin. All rights reserved.
+ * Copyright © 2007-2015, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -44,13 +44,11 @@ use Hoa\Stream;
*
* Proposes some methods to handle filter.
*
- * @author Ivan Enderlin <ivan.enderlin@hoa-project.net>
- * @copyright Copyright © 2007-2015 Ivan Enderlin.
+ * @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
-
-abstract class Filter extends Stream {
-
+abstract class Filter extends Stream
+{
/**
* Overwrite filter if already exists.
*
@@ -89,7 +87,7 @@ abstract class Filter extends Stream {
/**
* Filters resources register.
*
- * @var \Hoa\Stream\Filter array
+ * @var array
*/
protected static $_resources = [];
@@ -98,29 +96,30 @@ abstract class Filter extends Stream {
/**
* Register a stream filter.
*
- * @access public
* @param string $name Filter name.
* @param mixed $class Class name or instance.
* @param bool $overwrite Overwrite filter if already exists or
* not. Given by self::*OVERWRITE constants.
* @return bool
- * @throw \Hoa\Stream\Filter\Exception
+ * @throws \Hoa\Stream\Filter\Exception
*/
- public static function register ( $name,
- $class,
- $overwrite = self::DO_NOT_OVERWRITE ) {
-
- if( $overwrite === self::DO_NOT_OVERWRITE
- && true === self::isRegistered($name))
- throw new Exception(
- 'Filter %s is already registered.', 0, $name);
-
- if(empty($name))
- throw new Exception(
- 'Filter name cannot be empty.', 1);
-
- if(is_object($class))
+ public static function register(
+ $name,
+ $class,
+ $overwrite = self::DO_NOT_OVERWRITE
+ ) {
+ if ($overwrite === self::DO_NOT_OVERWRITE &&
+ true === self::isRegistered($name)) {
+ throw new Exception('Filter %s is already registered.', 0, $name);
+ }
+
+ if (empty($name)) {
+ throw new Exception('Filter name cannot be empty.', 1);
+ }
+
+ if (is_object($class)) {
$class = get_class($class);
+ }
return stream_filter_register($name, $class);
}
@@ -128,7 +127,6 @@ abstract class Filter extends Stream {
/**
* Append a filter to the list of filters.
*
- * @access public
* @param mixed $stream Stream which received the filter.
* Should be resource or an object
* \Hoa\Stream.
@@ -138,18 +136,22 @@ abstract class Filter extends Stream {
* @param mixed $parameters Parameters.
* @return resource
*/
- public static function append ( $stream, $name,
- $mode = self::READ, $parameters = null ) {
-
- if($stream instanceof Stream)
+ public static function append(
+ $stream,
+ $name,
+ $mode = self::READ, $parameters = null
+ ) {
+ if ($stream instanceof Stream) {
$stream = $stream->getStream();
+ }
- if(null === $parameters)
+ if (null === $parameters) {
return self::$_resources[$name] = stream_filter_append(
$stream,
$name,
$mode
);
+ }
return self::$_resources[$name] = stream_filter_append(
$stream,
@@ -162,7 +164,6 @@ abstract class Filter extends Stream {
/**
* Prepend a filter to the list of filters.
*
- * @access public
* @param mixed $stream Stream which received the filter.
* Should be resource or an object
* \Hoa\Stream.
@@ -172,18 +173,22 @@ abstract class Filter extends Stream {
* @param mixed $parameters Parameters.
* @return resource
*/
- public static function prepend ( $stream, $name,
- $mode = self::READ, $parameters = null ) {
-
- if($stream instanceof Stream)
+ public static function prepend(
+ $stream,
+ $name,
+ $mode = self::READ, $parameters = null
+ ) {
+ if ($stream instanceof Stream) {
$stream = $stream->getStream();
+ }
- if(null === $parameters)
+ if (null === $parameters) {
return self::$_resources[$name] = stream_filter_prepend(
$stream,
$name,
$mode
);
+ }
return self::$_resources[$name] = stream_filter_prepend(
$stream,
@@ -196,20 +201,24 @@ abstract class Filter extends Stream {
/**
* Delete a filter.
*
- * @access public
* @param mixed $streamFilter Stream filter resource or name.
* @return bool
- * @throw \Hoa\Stream\Filter\Exception
+ * @throws \Hoa\Stream\Filter\Exception
*/
- public static function remove ( $streamFilter ) {
-
- if(!is_resource($streamFilter))
- if(isset(self::$_resources[$streamFilter]))
+ public static function remove($streamFilter)
+ {
+ if (!is_resource($streamFilter)) {
+ if (isset(self::$_resources[$streamFilter])) {
$streamFilter = self::$_resources[$streamFilter];
- else
+ } else {
throw new Exception(
- 'Cannot remove the stream filter %s because no resource was ' .
- 'found with this name.', 2, $streamFilter);
+ 'Cannot remove the stream filter %s because no resource was ' .
+ 'found with this name.',
+ 2,
+ $streamFilter
+ );
+ }
+ }
return stream_filter_remove($streamFilter);
}
@@ -217,23 +226,21 @@ abstract class Filter extends Stream {
/**
* Check if a filter is already registered or not.
*
- * @access public
* @param string $name Filter name.
* @return bool
*/
- public static function isRegistered ( $name ) {
-
+ public static function isRegistered($name)
+ {
return in_array($name, self::getRegistered());
}
/**
* Get all registered filer names.
*
- * @access public
* @return array
*/
- public static function getRegistered ( ) {
-
+ public static function getRegistered()
+ {
return stream_get_filters();
}
}
diff --git a/Filter/LateComputed.php b/Filter/LateComputed.php
index 0b9bf79..42558b3 100644
--- a/Filter/LateComputed.php
+++ b/Filter/LateComputed.php
@@ -8,7 +8,7 @@
*
* New BSD License
*
- * Copyright © 2007-2015, Ivan Enderlin. All rights reserved.
+ * Copyright © 2007-2015, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -43,17 +43,15 @@ use Hoa\Stream;
*
* A late computed filter computes the data when closing the filtering.
*
- * @author Ivan Enderlin <ivan.enderlin@hoa-project.net>
- * @copyright Copyright © 2007-2015 Ivan Enderlin.
+ * @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
-
-abstract class LateComputed extends Basic {
-
+abstract class LateComputed extends Basic
+{
/**
* Buffer.
*
- * @var \Hoa\Stream\Filter\LateComputed string
+ * @var string
*/
protected $_buffer = null;
@@ -64,7 +62,6 @@ abstract class LateComputed extends Basic {
* This method is called whenever data is read from or written to the attach
* stream.
*
- * @access public
* @param resource $in A resource pointing to a bucket brigade
* which contains one or more bucket
* objects containing data to be filtered.
@@ -81,22 +78,21 @@ abstract class LateComputed extends Basic {
* closing parameter will be set to true.
* @return int
*/
- public function filter ( $in, $out, &$consumed, $closing ) {
-
+ public function filter($in, $out, &$consumed, $closing)
+ {
$return = self::FEED_ME;
$iBucket = new Stream\Bucket($in);
- while(false === $iBucket->eob()) {
-
+ while (false === $iBucket->eob()) {
$this->_buffer .= $iBucket->getData();
$consumed += $iBucket->getLength();
}
- if(null !== $consumed)
+ if (null !== $consumed) {
$return = self::PASS_ON;
+ }
- if(true === $closing) {
-
+ if (true === $closing) {
$stream = $this->getStream();
$this->compute();
$bucket = new Stream\Bucket(
@@ -117,8 +113,7 @@ abstract class LateComputed extends Basic {
/**
* Compute the whole data (stored in $this->_buffer).
*
- * @access protected
* @return string
*/
- abstract protected function compute ( );
+ abstract protected function compute();
}
diff --git a/IStream/Bufferable.php b/IStream/Bufferable.php
index 3732022..9660aac 100644
--- a/IStream/Bufferable.php
+++ b/IStream/Bufferable.php
@@ -8,7 +8,7 @@
*
* New BSD License
*
- * Copyright © 2007-2015, Ivan Enderlin. All rights reserved.
+ * Copyright © 2007-2015, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -43,53 +43,46 @@ namespace Hoa\Stream\IStream;
* of Hoa\Stream (please, see *StreamBuffer*() methods). Classes implementing
* this interface are able to create nested buffers, flush them etc.
*
- * @author Ivan Enderlin <ivan.enderlin@hoa-project.net>
- * @copyright Copyright © 2007-2015 Ivan Enderlin.
+ * @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
-
-interface Bufferable {
-
+interface Bufferable
+{
/**
* Start a new buffer.
* The callable acts like a light filter.
*
- * @access public
* @param mixed $callable Callable.
* @param int $size Size.
* @return int
*/
- public function newBuffer ( $callable = null, $size = null );
+ public function newBuffer($callable = null, $size = null);
/**
* Flush the buffer.
*
- * @access public
* @return void
*/
- public function flush ( );
+ public function flush();
/**
* Delete buffer.
*
- * @access public
* @return bool
*/
- public function deleteBuffer ( );
+ public function deleteBuffer();
/**
* Get bufffer level.
*
- * @access public
* @return int
*/
- public function getBufferLevel ( );
+ public function getBufferLevel();
/**
* Get buffer size.
*
- * @access public
* @return int
*/
- public function getBufferSize ( );
+ public function getBufferSize();
}
diff --git a/IStream/In.php b/IStream/In.php
index 21ce3a7..2b526f9 100644
--- a/IStream/In.php
+++ b/IStream/In.php
@@ -8,7 +8,7 @@
*
* New BSD License
*
- * Copyright © 2007-2015, Ivan Enderlin. All rights reserved.
+ * Copyright © 2007-2015, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -41,108 +41,95 @@ namespace Hoa\Stream\IStream;
*
* Interface for input.
*
- * @author Ivan Enderlin <ivan.enderlin@hoa-project.net>
- * @copyright Copyright © 2007-2015 Ivan Enderlin.
+ * @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
-
-interface In {
-
+interface In
+{
/**
* Test for end-of-stream.
*
- * @access public
* @return bool
*/
- public function eof ( );
+ public function eof();
/**
* Read n characters.
*
- * @access public
* @param int $length Length.
* @return string
*/
- public function read ( $length );
+ public function read($length);
/**
* Alias of $this->read().
*
- * @access public
* @param int $length Length.
* @return string
*/
- public function readString ( $length );
+ public function readString($length);
/**
* Read a character.
* It could be equivalent to $this->read(1).
*
- * @access public
* @return string
*/
- public function readCharacter ( );
+ public function readCharacter();
/**
* Read a boolean.
*
- * @access public
* @return bool
*/
- public function readBoolean ( );
+ public function readBoolean();
/**
* Read an integer.
*
- * @access public
* @param int $length Length.
* @return int
*/
- public function readInteger ( $length = 1 );
+ public function readInteger($length = 1);
/**
* Read a float.
*
- * @access public
* @param int $length Length.
* @return float
*/
- public function readFloat ( $length = 1 );
+ public function readFloat($length = 1);
/**
* Read an array.
* In most cases, it could be an alias to the $this->scanf() method.
*
- * @access public
* @param mixed $argument Argument (because the behavior is very
* different according to the implementation).
* @return array
*/
- public function readArray ( $argument = null );
+ public function readArray($argument = null);
/**
* Read a line.
*
- * @access public
* @return string
*/
- public function readLine ( );
+ public function readLine();
/**
* Read all, i.e. read as much as possible.
*
- * @access public
* @param int $offset Offset.
* @return string
*/
- public function readAll ( $offset = 0 );
+ public function readAll($offset = 0);
/**
* Parse input from a stream according to a format.
*
- * @access public
* @param string $format Format (see printf's formats).
* @return array
*/
- public function scanf ( $format );
+ public function scanf($format);
}
diff --git a/IStream/Lockable.php b/IStream/Lockable.php
index 4e2e2d3..c7f0990 100644
--- a/IStream/Lockable.php
+++ b/IStream/Lockable.php
@@ -8,7 +8,7 @@
*
* New BSD License
*
- * Copyright © 2007-2015, Ivan Enderlin. All rights reserved.
+ * Copyright © 2007-2015, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -41,13 +41,11 @@ namespace Hoa\Stream\IStream;
*
* Interface for lockable input/output.
*
- * @author Ivan Enderlin <ivan.enderlin@hoa-project.net>
- * @copyright Copyright © 2007-2015 Ivan Enderlin.
+ * @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
-
-interface Lockable {
-
+interface Lockable
+{
/**
* Acquire a shared lock (reader).
*
@@ -82,9 +80,8 @@ interface Lockable {
* Portable advisory locking.
* Should take a look at stream_supports_lock().
*
- * @access public
* @param int $operation Operation, use the self::LOCK_* constants.
* @return bool
*/
- public function lock ( $operation );
+ public function lock($operation);
}
diff --git a/IStream/Out.php b/IStream/Out.php
index 380a27f..952030a 100644
--- a/IStream/Out.php
+++ b/IStream/Out.php
@@ -8,7 +8,7 @@
*
* New BSD License
*
- * Copyright © 2007-2015, Ivan Enderlin. All rights reserved.
+ * Copyright © 2007-2015, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -41,101 +41,89 @@ namespace Hoa\Stream\IStream;
*
* Interface for output.
*
- * @author Ivan Enderlin <ivan.enderlin@hoa-project.net>
- * @copyright Copyright © 2007-2015 Ivan Enderlin.
+ * @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
-
-interface Out {
-
+interface Out
+{
/**
* Write n characters.
*
- * @access public
* @param string $string String.
* @param int $length Length.
* @return mixed
*/
- public function write ( $string, $length );
+ public function write($string, $length);
/**
* Write a string.
*
- * @access public
* @param string $string String.
* @return mixed
*/
- public function writeString ( $string );
+ public function writeString($string);
/**
* Write a character.
*
- * @access public
* @param string $character Character.
* @return mixed
*/
- public function writeCharacter ( $character );
+ public function writeCharacter($character);
/**
* Write a boolean.
*
- * @access public
* @param bool $boolean Boolean.
* @return mixed
*/
- public function writeBoolean ( $boolean );
+ public function writeBoolean($boolean);
/**
* Write an integer.
*
- * @access public
* @param int $integer Integer.
* @return mixed
*/
- public function writeInteger ( $integer );
+ public function writeInteger($integer);
/**
* Write a float.
*
- * @access public
* @param float $float Float.
* @return mixed
*/
- public function writeFloat ( $float );
+ public function writeFloat($float);
/**
* Write an array.
*
- * @access public
* @param array $array Array.
* @return mixed
*/
- public function writeArray ( Array $array );
+ public function writeArray(Array $array);
/**
* Write a line.
*
- * @access public
* @param string $line Line.
* @return mixed
*/
- public function writeLine ( $line );
+ public function writeLine($line);
/**
* Write all, i.e. as much as possible.
*
- * @access public
* @param string $string String.
* @return mixed
*/
- public function writeAll ( $string );
+ public function writeAll($string);
/**
* Truncate a stream to a given length.
*
- * @access public
* @param int $size Size.
* @return bool
*/
- public function truncate ( $size );
+ public function truncate($size);
}
diff --git a/IStream/Pathable.php b/IStream/Pathable.php
index f638683..d319b13 100644
--- a/IStream/Pathable.php
+++ b/IStream/Pathable.php
@@ -8,7 +8,7 @@
*
* New BSD License
*
- * Copyright © 2007-2015, Ivan Enderlin. All rights reserved.
+ * Copyright © 2007-2015, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -41,26 +41,22 @@ namespace Hoa\Stream\IStream;
*
* Interface for pathable input/output.
*
- * @author Ivan Enderlin <ivan.enderlin@hoa-project.net>
- * @copyright Copyright © 2007-2015 Ivan Enderlin.
+ * @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
-
-interface Pathable {
-
+interface Pathable
+{
/**
* Get filename component of path.
*
- * @access public
* @return string
*/
- public function getBasename ( );
+ public function getBasename();
/**
* Get directory name component of path.
*
- * @access public
* @return string
*/
- public function getDirname ( );
+ public function getDirname();
}
diff --git a/IStream/Pointable.php b/IStream/Pointable.php
index b2a7e90..6c6effb 100644
--- a/IStream/Pointable.php
+++ b/IStream/Pointable.php
@@ -8,7 +8,7 @@
*
* New BSD License
*
- * Copyright © 2007-2015, Ivan Enderlin. All rights reserved.
+ * Copyright © 2007-2015, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -41,13 +41,11 @@ namespace Hoa\Stream\IStream;
*
* Interface for pointable input/output.
*
- * @author Ivan Enderlin <ivan.enderlin@hoa-project.net>
- * @copyright Copyright © 2007-2015 Ivan Enderlin.
+ * @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
-
-interface Pointable {
-
+interface Pointable
+{
/**
* Set position equal to $offset bytes.
*
@@ -74,26 +72,23 @@ interface Pointable {
/**
* Rewind the position of a stream pointer.
*
- * @access public
* @return bool
*/
- public function rewind ( );
+ public function rewind();
/**
* Seek on a stream pointer.
*
- * @access public
* @param int $offset Offset (negative value should be supported).
* @param int $whence Whence, use the self::SEEK_* constants.
* @return int
*/
- public function seek ( $offset, $whence = self::SEEK_SET );
+ public function seek($offset, $whence = self::SEEK_SET);
/**
* Get the current position of the stream pointer.
*
- * @access public
* @return int
*/
- public function tell ( );
+ public function tell();
}
diff --git a/IStream/Statable.php b/IStream/Statable.php
index bac6299..3bb1dff 100644
--- a/IStream/Statable.php
+++ b/IStream/Statable.php
@@ -8,7 +8,7 @@
*
* New BSD License
*
- * Copyright © 2007-2015, Ivan Enderlin. All rights reserved.
+ * Copyright © 2007-2015, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -41,13 +41,11 @@ namespace Hoa\Stream\IStream;
*
* Interface for statable input/output.
*
- * @author Ivan Enderlin <ivan.enderlin@hoa-project.net>
- * @copyright Copyright © 2007-2015 Ivan Enderlin.
+ * @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
-
-interface Statable {
-
+interface Statable
+{
/**
* Size is undefined.
*
@@ -58,104 +56,91 @@ interface Statable {
/**
* Get size.
*
- * @access public
* @return int
*/
- public function getSize ( );
+ public function getSize();
/**
* Get informations about a file.
*
- * @access public
* @return array
*/
- public function getStatistic ( );
+ public function getStatistic();
/**
* Get last access time of file.
*
- * @access public
* @return int
*/
- public function getATime ( );
+ public function getATime();
/**
* Get inode change time of file.
*
- * @access public
* @return int
*/
- public function getCTime ( );
+ public function getCTime();
/**
* Get file modification time.
*
- * @access public
* @return int
*/
- public function getMTime ( );
+ public function getMTime();
/**
* Get file group.
*
- * @access public
* @return int
*/
- public function getGroup ( );
+ public function getGroup();
/**
* Get file owner.
*
- * @access public
* @return int
*/
- public function getOwner ( );
+ public function getOwner();
/**
* Get file permissions.
*
- * @access public
* @return int
*/
- public function getPermissions ( );
+ public function getPermissions();
/**
* Check if the file is readable.
*
- * @access public
* @return bool
*/
- public function isReadable ( );
+ public function isReadable();
/**
* Check if the file is writable.
*
- * @access public
* @return bool
*/
- public function isWritable ( );
+ public function isWritable();
/**
* Check if the file is executable.
*
- * @access public
* @return bool
*/
- public function isExecutable ( );
+ public function isExecutable();
/**
* Clear file status cache.
*
- * @access public
* @return void
*/
- public function clearStatisticCache ( );
+ public function clearStatisticCache();
/**
* Clear all files status cache.
*
- * @access public
* @return void
*/
- public static function clearAllStatisticCaches ( );
+ public static function clearAllStatisticCaches();
}
diff --git a/IStream/Structural.php b/IStream/Structural.php
index f2d0a92..1be14b5 100644
--- a/IStream/Structural.php
+++ b/IStream/Structural.php
@@ -8,7 +8,7 @@
*
* New BSD License
*
- * Copyright © 2007-2015, Ivan Enderlin. All rights reserved.
+ * Copyright © 2007-2015, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -41,89 +41,78 @@ namespace Hoa\Stream\IStream;
*
* Interface for structural input/output.
*
- * @author Ivan Enderlin <ivan.enderlin@hoa-project.net>
- * @copyright Copyright © 2007-2015 Ivan Enderlin.
+ * @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
-
-interface Structural {
-
+interface Structural
+{
/**
* Select root of the document: :root.
*
- * @access public
* @return \Hoa\Stream\IStream\Structural
*/
- public function selectRoot ( );
+ public function selectRoot();
/**
* Select any elements: *.
*
- * @access public
* @return array
*/
- public function selectAnyElements ( );
+ public function selectAnyElements();
/**
* Select elements of type E: E.
*
- * @access public
* @param string $E Element E.
* @return array
*/
- public function selectElements ( $E = null );
+ public function selectElements($E = null);
/**
* Select F elements descendant of an E element: E F.
*
- * @access public
* @param string $F Element F.
* @return array
*/
- public function selectDescendantElements ( $F = null );
+ public function selectDescendantElements($F = null);
/**
* Select F elements children of an E element: E > F.
*
- * @access public
* @param string $F Element F.
* @return array
*/
- public function selectChildElements ( $F = null );
+ public function selectChildElements($F = null);
/**
* Select an F element immediately preceded by an E element: E + F.
*
- * @access public
* @param string $F Element F.
* @return \Hoa\Stream\IStream\Structural
*/
- public function selectAdjacentSiblingElement ( $F );
+ public function selectAdjacentSiblingElement($F);
/**
* Select F elements preceded by an E element: E ~ F.
*
- * @access public
* @param string $F Element F.
* @return array
*/
- public function selectSiblingElements ( $F = null );
+ public function selectSiblingElements($F = null);
/**
* Execute a query selector and return the first result.
*
- * @access public
* @param string $query Query.
* @return \Hoa\Stream\IStream\Structural
*/
- public function querySelector ( $query );
+ public function querySelector($query);
/**
* Execute a query selector and return one or many results.
*
- * @access public
* @param string $query Query.
* @return array
*/
- public function querySelectorAll ( $query );
+ public function querySelectorAll($query);
}
diff --git a/IStream/Touchable.php b/IStream/Touchable.php
index f3bf869..d101375 100644
--- a/IStream/Touchable.php
+++ b/IStream/Touchable.php
@@ -8,7 +8,7 @@
*
* New BSD License
*
- * Copyright © 2007-2015, Ivan Enderlin. All rights reserved.
+ * Copyright © 2007-2015, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -41,13 +41,11 @@ namespace Hoa\Stream\IStream;
*
* Interface for touchable input/output.
*
- * @author Ivan Enderlin <ivan.enderlin@hoa-project.net>
- * @copyright Copyright © 2007-2015 Ivan Enderlin.
+ * @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
-
-interface Touchable {
-
+interface Touchable
+{
/**
* Overwrite file if already exists.
*
@@ -81,30 +79,27 @@ interface Touchable {
/**
* Set access and modification time of file.
*
- * @access public
* @param int $time Time. If equals to -1, time() should be used.
* @param int $atime Access time. If equals to -1, $time should be
* used.
* @return bool
*/
- public function touch ( $time = -1, $atime = -1 );
+ public function touch($time = -1, $atime = -1);
/**
* Copy file.
* Return the destination file path if succeed, false otherwise.
*
- * @access public
* @param string $to Destination path.
* @param bool $force Force to copy if the file $to already exists.
* Use the self::*OVERWRITE constants.
* @return bool
*/
- public function copy ( $to, $force = self::DO_NOT_OVERWRITE );
+ public function copy($to, $force = self::DO_NOT_OVERWRITE);
/**
* Move a file.
*
- * @access public
* @param string $name New name.
* @param bool $force Force to move if the file $name already
* exists.
@@ -113,51 +108,49 @@ interface Touchable {
* Use the self::*DIRECTORY constants.
* @return bool
*/
- public function move ( $name, $force = self::DO_NOT_OVERWRITE,
- $mkdir = self::DO_NOT_MAKE_DIRECTORY );
+ public function move(
+ $name,
+ $force = self::DO_NOT_OVERWRITE,
+ $mkdir = self::DO_NOT_MAKE_DIRECTORY
+ );
/**
* Delete a file.
*
- * @access public
* @return bool
*/
- public function delete ( );
+ public function delete();
/**
* Change file group.
*
- * @access public
* @param mixed $group Group name or number.
* @return bool
*/
- public function changeGroup ( $group );
+ public function changeGroup($group);
/**
* Change file mode.
*
- * @access public
* @param int $mode Mode (in octal!).
* @return bool
*/
- public function changeMode ( $mode );
+ public function changeMode($mode);
/**
* Change file owner.
*
- * @access public
* @param mixed $user User.
* @return bool
*/
- public function changeOwner ( $user );
+ public function changeOwner($user);
/**
* Change the current umask.
*
- * @access public
* @param int $umask Umask (in octal!). If null, given the current
* umask value.
* @return int
*/
- public static function umask ( $umask = null );
+ public static function umask($umask = null);
}
diff --git a/Stream.php b/Stream.php
index 0a97202..2ffebf3 100644
--- a/Stream.php
+++ b/Stream.php
@@ -8,7 +8,7 @@
*
* New BSD License
*
- * Copyright © 2007-2015, Ivan Enderlin. All rights reserved.
+ * Copyright © 2007-2015, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -43,13 +43,11 @@ use Hoa\Core;
*
* Static register for all streams (files, sockets etc.).
*
- * @author Ivan Enderlin <ivan.enderlin@hoa-project.net>
- * @copyright Copyright © 2007-2015 Ivan Enderlin.
+ * @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
-
-abstract class Stream implements Core\Event\Listenable {
-
+abstract class Stream implements Core\Event\Listenable
+{
/**
* Name index in the stream bucket.
*
@@ -81,56 +79,56 @@ abstract class Stream implements Core\Event\Listenable {
/**
* Current stream bucket.
*
- * @var \Hoa\Stream array
+ * @var array
*/
protected $_bucket = [];
/**
* Static stream register.
*
- * @var \Hoa\Stream array
+ * @var array
*/
private static $_register = [];
/**
* Buffer size (default is 8Ko).
*
- * @var \Hoa\Stream bool
+ * @var bool
*/
protected $_bufferSize = 8192;
/**
* Original stream name, given to the stream constructor.
*
- * @var \Hoa\Stream string
+ * @var string
*/
protected $_streamName = null;
/**
* Context name.
*
- * @var \Hoa\Stream string
+ * @var string
*/
protected $_context = null;
/**
* Whether the opening has been differed.
*
- * @var \Hoa\Stream bool
+ * @var bool
*/
protected $_hasBeenDiffered = false;
/**
* Listeners.
*
- * @var \Hoa\Core\Event\Listener object
+ * @var \Hoa\Core\Event\Listener
*/
protected $_on = null;
/**
* Whether this stream is already opened by another handler.
*
- * @var \Hoa\Stream bool
+ * @var bool
*/
protected $_borrowed = false;
@@ -141,15 +139,14 @@ abstract class Stream implements Core\Event\Listenable {
* If not exists in the register, try to call the
* $this->_open() method. Please, see the self::_getStream() method.
*
- * @access public
* @param string $streamName Stream name (e.g. path or URL).
* @param string $context Context ID (please, see the
* \Hoa\Stream\Context class).
* @param bool $wait Differ opening or not.
* @return void
*/
- public function __construct ( $streamName, $context = null, $wait = false ) {
-
+ public function __construct($streamName, $context = null, $wait = false)
+ {
$this->_streamName = $streamName;
$this->_context = $context;
$this->_hasBeenDiffered = $wait;
@@ -166,8 +163,9 @@ abstract class Stream implements Core\Event\Listenable {
'size'
]);
- if(true === $wait)
+ if (true === $wait) {
return;
+ }
$this->open();
@@ -179,32 +177,34 @@ abstract class Stream implements Core\Event\Listenable {
* If the stream does not exist, try to open it by calling the
* $handler->_open() method.
*
- * @access private
* @param string $streamName Stream name.
* @param \Hoa\Stream $handler Stream handler.
* @param string $context Context ID (please, see the
* \Hoa\Stream\Context class).
* @return array
- * @throw \Hoa\Stream\Exception
+ * @throws \Hoa\Stream\Exception
*/
- final private static function &_getStream ( $streamName,
- Stream $handler,
- $context = null ) {
-
+ final private static function &_getStream(
+ $streamName,
+ Stream $handler,
+ $context = null
+ ) {
$name = md5($streamName);
- if(null !== $context) {
-
- if(false === Context::contextExists($context))
+ if (null !== $context) {
+ if (false === Context::contextExists($context)) {
throw new Exception(
'Context %s was not previously declared, cannot retrieve ' .
- 'this context.', 0, $context);
+ 'this context.',
+ 0,
+ $context
+ );
+ }
$context = Context::getInstance($context);
}
- if(!isset(self::$_register[$name])) {
-
+ if (!isset(self::$_register[$name])) {
self::$_register[$name] = [
self::NAME => $streamName,
self::HANDLER => $handler,
@@ -220,13 +220,14 @@ abstract class Stream implements Core\Event\Listenable {
'hoa://Event/Stream/' . $streamName . ':close-before',
$handler
);
- }
- else
+ } else {
$handler->_borrowed = true;
+ }
- if(null === self::$_register[$name][self::RESOURCE])
- self::$_register[$name][self::RESOURCE] =
- $handler->_open($streamName, $context);
+ if (null === self::$_register[$name][self::RESOURCE]) {
+ self::$_register[$name][self::RESOURCE]
+ = $handler->_open($streamName, $context);
+ }
return self::$_register[$name];
}
@@ -236,54 +237,48 @@ abstract class Stream implements Core\Event\Listenable {
* Note: this method is protected, but do not forget that it could be
* overloaded into a public context.
*
- * @access protected
* @param string $streamName Stream name (e.g. path or URL).
* @param \Hoa\Stream\Context $context Context.
* @return resource
- * @throw \Hoa\Core\Exception
+ * @throws \Hoa\Core\Exception
*/
- abstract protected function &_open ( $streamName, Context $context = null );
+ abstract protected function &_open($streamName, Context $context = null);
/**
* Close the current stream.
* Note: this method is protected, but do not forget that it could be
* overloaded into a public context.
*
- * @access protected
* @return bool
*/
- abstract protected function _close ( );
+ abstract protected function _close();
/**
* Open the stream.
*
- * @access public
* @return \Hoa\Stream
- * @throw \Hoa\Stream\Exception
+ * @throws \Hoa\Stream\Exception
*/
- final public function open ( ) {
-
+ final public function open()
+ {
$context = $this->_context;
- if(true === $this->_hasBeenDiffered) {
-
- if(null === $context) {
-
+ if (true === $this->_hasBeenDiffered) {
+ if (null === $context) {
$handle = Context::getInstance(uniqid());
$handle->setParameters([
'notification' => [$this, '_notify']
]);
$context = $handle->getId();
- }
- elseif(true === Context::contextExists($context)) {
-
+ } elseif (true === Context::contextExists($context)) {
$handle = Context::getInstance($context);
$parameters = $handle->getParameters();
- if(!isset($parameters['notification']))
+ if (!isset($parameters['notification'])) {
$handle->setParameters([
'notification' => [$this, '_notify']
]);
+ }
}
}
@@ -299,16 +294,16 @@ abstract class Stream implements Core\Event\Listenable {
/**
* Close the current stream.
*
- * @access public
* @return void
*/
- final public function close ( ) {
-
+ final public function close()
+ {
$streamName = $this->getStreamName();
$name = md5($streamName);
- if(!isset(self::$_register[$name]))
+ if (!isset(self::$_register[$name])) {
return;
+ }
Core\Event::notify(
'hoa://Event/Stream/' . $streamName . ':close-before',
@@ -316,8 +311,9 @@ abstract class Stream implements Core\Event\Listenable {
new Core\Event\Bucket()
);
- if(false === $this->_close())
+ if (false === $this->_close()) {
return;
+ }
unset(self::$_register[$name]);
$this->_bucket[self::HANDLER] = null;
@@ -335,13 +331,13 @@ abstract class Stream implements Core\Event\Listenable {
/**
* Get the current stream name.
*
- * @access public
* @return string
*/
- public function getStreamName ( ) {
-
- if(empty($this->_bucket))
+ public function getStreamName()
+ {
+ if (empty($this->_bucket)) {
return null;
+ }
return $this->_bucket[self::NAME];
}
@@ -349,13 +345,13 @@ abstract class Stream implements Core\Event\Listenable {
/**
* Get the current stream.
*
- * @access protected
* @return resource
*/
- protected function getStream ( ) {
-
- if(empty($this->_bucket))
+ protected function getStream()
+ {
+ if (empty($this->_bucket)) {
return null;
+ }
return $this->_bucket[self::RESOURCE];
}
@@ -363,13 +359,13 @@ abstract class Stream implements Core\Event\Listenable {
/**
* Get the current stream context.
*
- * @access protected
* @return \Hoa\Stream\Context
*/
- public function getStreamContext ( ) {
-
- if(empty($this->_bucket))
+ public function getStreamContext()
+ {
+ if (empty($this->_bucket)) {
return null;
+ }
return $this->_bucket[self::CONTEXT];
}
@@ -377,16 +373,16 @@ abstract class Stream implements Core\Event\Listenable {
/**
* Get stream handler according to its name.
*
- * @access public
* @param string $streamName Stream name.
* @return \Hoa\Stream
*/
- public static function getStreamHandler ( $streamName ) {
-
+ public static function getStreamHandler($streamName)
+ {
$name = md5($streamName);
- if(!isset(self::$_register[$name]))
+ if (!isset(self::$_register[$name])) {
return null;
+ }
return self::$_register[$name][self::HANDLER];
}
@@ -397,18 +393,21 @@ abstract class Stream implements Core\Event\Listenable {
* taking time to think about it two minutes. Resource of type “Unknown” is
* considered as valid.
*
- * @access public
* @return resource
- * @throw \Hoa\Stream\Exception
+ * @throws \Hoa\Stream\Exception
*/
- public function _setStream ( $stream ) {
-
- if( false === is_resource($stream)
- && ( 'resource' === gettype($stream)
- && 'Unknown' !== get_resource_type($stream)))
+ public function _setStream($stream)
+ {
+ if (false === is_resource($stream) &&
+ ('resource' === gettype($stream) &&
+ 'Unknown' !== get_resource_type($stream))) {
throw new Exception(
'Try to change the stream resource with an invalid one; ' .
- 'given %s.', 1, gettype($stream));
+ 'given %s.',
+ 1,
+ gettype($stream)
+ );
+ }
$old = $this->_bucket[self::RESOURCE];
$this->_bucket[self::RESOURCE] = $stream;
@@ -419,36 +418,33 @@ abstract class Stream implements Core\Event\Listenable {
/**
* Check if the stream is opened.
*
- * @access public
* @return bool
*/
- public function isOpened ( ) {
-
+ public function isOpened()
+ {
return is_resource($this->getStream());
}
/**
* Set the timeout period.
*
- * @access public
* @param int $second Timeout period in seconds.
* @param int $micro Timeout period in microseconds.
* @return bool
*/
- public function setStreamTimeout ( $seconds, $microseconds = 0 ) {
-
+ public function setStreamTimeout($seconds, $microseconds = 0)
+ {
return stream_set_timeout($this->getStream(), $seconds, $microseconds);
}
/**
* Set blocking/non-blocking mode.
*
- * @access public
* @param bool $mode Blocking mode.
* @return bool
*/
- public function setStreamBlocking ( $mode ) {
-
+ public function setStreamBlocking($mode)
+ {
return stream_set_blocking($this->getStream(), (int) $mode);
}
@@ -459,7 +455,6 @@ abstract class Stream implements Core\Event\Listenable {
* output stream, each is paused after 8 Ko of data to allow the other to
* write.
*
- * @access public
* @param int $buffer Number of bytes to buffer. If zero, write
* operations are unbuffered. This ensures that
* all writes are completed before other
@@ -467,13 +462,14 @@ abstract class Stream implements Core\Event\Listenable {
* stream.
* @return bool
*/
- public function setStreamBuffer ( $buffer ) {
-
+ public function setStreamBuffer($buffer)
+ {
// Zero means success.
$out = 0 === stream_set_write_buffer($this->getStream(), $buffer);
- if(true === $out)
+ if (true === $out) {
$this->_bufferSize = $buffer;
+ }
return $out;
}
@@ -482,35 +478,33 @@ abstract class Stream implements Core\Event\Listenable {
* Disable stream buffering.
* Alias of $this->setBuffer(0).
*
- * @access public
* @return bool
*/
- public function disableStreamBuffer ( ) {
-
+ public function disableStreamBuffer()
+ {
return $this->setStreamBuffer(0);
}
/**
* Get stream buffer size.
*
- * @access public
* @return int
*/
- public function getStreamBufferSize ( ) {
-
+ public function getStreamBufferSize()
+ {
return $this->_bufferSize;
}
/**
* Get stream wrapper name.
*
- * @access public
* @return string
*/
- public function getStreamWrapperName ( ) {
-
- if(false === $pos = strpos($this->getStreamName(), '://'))
+ public function getStreamWrapperName()
+ {
+ if (false === $pos = strpos($this->getStreamName(), '://')) {
return 'file';
+ }
return substr($this->getStreamName(), 0, $pos);
}
@@ -518,36 +512,33 @@ abstract class Stream implements Core\Event\Listenable {
/**
* Get stream meta data.
*
- * @access public
* @return array
*/
- public function getStreamMetaData ( ) {
-
+ public function getStreamMetaData()
+ {
return stream_get_meta_data($this->getStream());
}
/**
* Whether this stream is already opened by another handler.
*
- * @access public
* @return bool
*/
- public function isBorrowing ( ) {
-
+ public function isBorrowing()
+ {
return $this->_borrowed;
}
/**
* Attach a callable to this listenable object.
*
- * @access public
* @param string $listenerId Listener ID.
* @param mixed $callable Callable.
* @return \Hoa\Stream
* @return \Hoa\Core\Exception
*/
- public function on ( $listenerId, $callable ) {
-
+ public function on($listenerId, $callable)
+ {
$this->_on->attach($listenerId, $callable);
return $this;
@@ -556,7 +547,6 @@ abstract class Stream implements Core\Event\Listenable {
/**
* Notification callback.
*
- * @access public
* @param int $ncode Notification code. Please, see
* STREAM_NOTIFY_* constants.
* @param int $severity Severity. Please, see
@@ -568,9 +558,14 @@ abstract class Stream implements Core\Event\Listenable {
* @param int $max If applicable, the number of max bytes.
* @return void
*/
- public function _notify ( $ncode, $severity, $message, $code, $transferred,
- $max ) {
-
+ public function _notify(
+ $ncode,
+ $severity,
+ $message,
+ $code,
+ $transferred,
+ $max
+ ) {
static $_map = [
STREAM_NOTIFY_AUTH_REQUIRED => 'authrequire',
STREAM_NOTIFY_AUTH_RESULT => 'authresult',
@@ -603,13 +598,13 @@ abstract class Stream implements Core\Event\Listenable {
* if a stream is persistent, the $handler->close() should do anything. It
* is a very generic method.
*
- * @access public
* @return void
*/
- final public static function _Hoa_Stream ( ) {
-
- foreach(self::$_register as $entry)
+ final public static function _Hoa_Stream()
+ {
+ foreach (self::$_register as $entry) {
$entry[self::HANDLER]->close();
+ }
return;
}
@@ -617,22 +612,20 @@ abstract class Stream implements Core\Event\Listenable {
/**
* Transform object to string.
*
- * @access public
* @return string
*/
- public function __toString ( ) {
-
+ public function __toString()
+ {
return $this->getStreamName();
}
/**
* Close the stream when destructing.
*
- * @access public
* @return void
*/
- public function __destruct ( ) {
-
+ public function __destruct()
+ {
$this->close();
return;
@@ -644,17 +637,15 @@ abstract class Stream implements Core\Event\Listenable {
*
* hoa://Library/Stream component.
*
- * @author Ivan Enderlin <ivan.enderlin@hoa-project.net>
- * @copyright Copyright © 2007-2015 Ivan Enderlin.
+ * @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
-
-class _Protocol extends Core\Protocol {
-
+class _Protocol extends Core\Protocol
+{
/**
* Component's name.
*
- * @var \Hoa\Core\Protocol string
+ * @var string
*/
protected $_name = 'Stream';
@@ -663,12 +654,11 @@ class _Protocol extends Core\Protocol {
/**
* ID of the component.
*
- * @access public
* @param string $id ID of the component.
* @return mixed
*/
- public function reachId ( $id ) {
-
+ public function reachId($id)
+ {
return Stream::getStreamHandler($id);
}
}
diff --git a/Wrapper/Exception.php b/Wrapper/Exception.php
index 8e09dd9..d400dc0 100644
--- a/Wrapper/Exception.php
+++ b/Wrapper/Exception.php
@@ -8,7 +8,7 @@
*
* New BSD License
*
- * Copyright © 2007-2015, Ivan Enderlin. All rights reserved.
+ * Copyright © 2007-2015, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -43,9 +43,9 @@ use Hoa\Stream;
*
* Extending the \Hoa\Stream\Exception class.
*
- * @author Ivan Enderlin <ivan.enderlin@hoa-project.net>
- * @copyright Copyright © 2007-2015 Ivan Enderlin.
+ * @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
-
-class Exception extends Stream\Exception { }
+class Exception extends Stream\Exception
+{
+}
diff --git a/Wrapper/IWrapper/File.php b/Wrapper/IWrapper/File.php
index ddbb585..73a271a 100644
--- a/Wrapper/IWrapper/File.php
+++ b/Wrapper/IWrapper/File.php
@@ -8,7 +8,7 @@
*
* New BSD License
*
- * Copyright © 2007-2015, Ivan Enderlin. All rights reserved.
+ * Copyright © 2007-2015, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -41,43 +41,38 @@ namespace Hoa\Stream\Wrapper\IWrapper;
*
* Interface for “file stream wrapper” class.
*
- * @author Ivan Enderlin <ivan.enderlin@hoa-project.net>
- * @copyright Copyright © 2007-2015 Ivan Enderlin.
+ * @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
-
-interface File {
-
+interface File
+{
/**
* Close directory handle.
* This method is called in to closedir().
* Any resources which were locked, or allocated, during opening and use of
* the directory stream should be released.
*
- * @access public
* @return bool
*/
- public function dir_closedir ( );
+ public function dir_closedir();
/**
* Open directory handle.
* This method is called in response to opendir().
*
- * @access public
* @param string $path Specifies the URL that was passed to opendir().
* @param int $options Whether or not to enforce safe_mode (0x04).
* @return bool
*/
- public function dir_opendir ( $path, $options );
+ public function dir_opendir($path, $options);
/**
* Read entry from directory handle.
* This method is called in response to readdir().
*
- * @access public
* @return mixed
*/
- public function dir_readdir ( );
+ public function dir_readdir();
/**
* Rewind directory handle.
@@ -86,61 +81,55 @@ interface File {
* call to self::dir_readdir should return the first entry in the location
* returned by self::dir_opendir.
*
- * @access public
* @return bool
*/
- public function dir_rewinddir ( );
+ public function dir_rewinddir();
/**
* Create a directory.
* This method is called in response to mkdir().
*
- * @access public
* @param string $path Directory which should be created.
* @param int $mode The value passed to mkdir().
* @param int $options A bitwise mask of values.
* @return bool
*/
- public function mkdir ( $path, $mode, $options );
+ public function mkdir($path, $mode, $options);
/**
* Rename a file or directory.
* This method is called in response to rename().
* Should attempt to rename $from to $to.
*
- * @access public
* @param string $from The URL to current file.
* @param string $to The URL which $from should be renamed to.
* @return bool
*/
- public function rename ( $from, $to );
+ public function rename($from, $to);
/**
* Remove a directory.
* This method is called in response to rmdir().
*
- * @access public
* @param string $path The directory URL which should be removed.
* @param int $options A bitwise mask of values.
* @return bool
*/
- public function rmdir ( $path, $options );
+ public function rmdir($path, $options);
/**
* Delete a file.
* This method is called in response to unlink().
*
- * @access public
* @param string $path The file URL which should be deleted.
* @return bool
*/
- public function unlink ( $path );
+ public function unlink($path);
/**
* Retrieve information about a file.
* This method is called in response to all stat() related functions.
*
- * @access public
* @param string $path The file URL which should be retrieve
* information about.
* @param int $flags Holds additional flags set by the streams API.
@@ -161,5 +150,5 @@ interface File {
* function during stating of the path.
* @return array
*/
- public function url_stat ( $path, $flags );
+ public function url_stat($path, $flags);
}
diff --git a/Wrapper/IWrapper/IWrapper.php b/Wrapper/IWrapper/IWrapper.php
index e97476e..be19504 100644
--- a/Wrapper/IWrapper/IWrapper.php
+++ b/Wrapper/IWrapper/IWrapper.php
@@ -8,7 +8,7 @@
*
* New BSD License
*
- * Copyright © 2007-2015, Ivan Enderlin. All rights reserved.
+ * Copyright © 2007-2015, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -43,21 +43,18 @@ use Hoa\Core;
*
* Interface for stream wrapper class.
*
- * @author Ivan Enderlin <ivan.enderlin@hoa-project.net>
- * @copyright Copyright © 2007-2015 Ivan Enderlin.
+ * @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
-
-interface IWrapper extends File, Stream {
-
+interface IWrapper extends File, Stream
+{
/**
* Constructs a new stream wrapper.
* Called when opening the stream wrapper, right before self::stream_open().
*
- * @access public
* @return void
*/
- public function __construct ( );
+ public function __construct();
}
/**
diff --git a/Wrapper/IWrapper/Stream.php b/Wrapper/IWrapper/Stream.php
index e270dc3..029a6b1 100644
--- a/Wrapper/IWrapper/Stream.php
+++ b/Wrapper/IWrapper/Stream.php
@@ -8,7 +8,7 @@
*
* New BSD License
*
- * Copyright © 2007-2015, Ivan Enderlin. All rights reserved.
+ * Copyright © 2007-2015, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -41,24 +41,21 @@ namespace Hoa\Stream\Wrapper\IWrapper;
*
* Interface for “stream stream wrapper” class.
*
- * @author Ivan Enderlin <ivan.enderlin@hoa-project.net>
- * @copyright Copyright © 2007-2015 Ivan Enderlin.
+ * @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
-
-interface Stream {
-
+interface Stream
+{
/**
* Retrieve the underlaying resource.
*
- * @access public
* @param int $castAs Can be STREAM_CAST_FOR_SELECT when
* stream_select() is calling stream_cast() or
* STREAM_CAST_AS_STREAM when stream_cast() is
* called for other uses.
* @return resource
*/
- public function stream_cast ( $castAs );
+ public function stream_cast($castAs);
/**
* Close a resource.
@@ -66,19 +63,17 @@ interface Stream {
* All resources that were locked, or allocated, by the wrapper should be
* released.
*
- * @access public
* @return void
*/
- public function stream_close ( );
+ public function stream_close();
/**
* Tests for end-of-file on a file pointer.
* This method is called in response to feof().
*
- * @access public
* @return bool
*/
- public function stream_eof ( );
+ public function stream_eof();
/**
* Flush the output.
@@ -86,10 +81,9 @@ interface Stream {
* If we have cached data in our stream but not yet stored it into the
* underlying storage, we should do so now.
*
- * @access public
* @return bool
*/
- public function stream_flush ( );
+ public function stream_flush();
/**
* Advisory file locking.
@@ -97,7 +91,6 @@ interface Stream {
* (when flags contains LOCK_EX), stream_set_blocking() and when closing the
* stream (LOCK_UN).
*
- * @access public
* @param int $operation Operation is one the following:
* * LOCK_SH to acquire a shared lock (reader) ;
* * LOCK_EX to acquire an exclusive lock (writer) ;
@@ -107,7 +100,7 @@ interface Stream {
* Windows).
* @return bool
*/
- public function stream_lock ( $operation );
+ public function stream_lock($operation);
/**
* Change stream options.
@@ -115,7 +108,6 @@ interface Stream {
* one of the following functions is called one a stream URL: touch, chmod,
* chown or chgrp.
*
- * @access public
* @param string $path The file path or URL to set metadata.
* @param int $option One of the following:
* * STREAM_META_TOUCH,
@@ -127,14 +119,13 @@ interface Stream {
* @param mixed $value An array or a scalar depending of the option.
* @return bool
*/
- public function stream_metadata ( $path, $option, $value );
+ public function stream_metadata($path, $option, $value);
/**
* Open file or URL.
* This method is called immediately after the wrapper is initialized (f.e.
* by fopen() and file_get_contents()).
*
- * @access public
* @param string $path Specifies the URL that was passed to the
* original function.
* @param string $mode The mode used to open the file, as
@@ -157,18 +148,17 @@ interface Stream {
* actually opened.
* @return bool
*/
- public function stream_open ( $path, $mode, $options, &$openedPath );
+ public function stream_open($path, $mode, $options, &$openedPath);
/**
* Read from stream.
* This method is called in response to fread() and fgets().
*
- * @access public
* @param int $count How many bytes of data from the current
* position should be returned.
* @return string
*/
- public function stream_read ( $count );
+ public function stream_read($count);
/**
* Seek to specific location in a stream.
@@ -176,7 +166,6 @@ interface Stream {
* The read/write position of the stream should be updated according to the
* $offset and $whence.
*
- * @access public
* @param int $offset The stream offset to seek to.
* @param int $whence Possible values:
* * SEEK_SET to set position equal to $offset
@@ -187,13 +176,12 @@ interface Stream {
* plus $offset.
* @return bool
*/
- public function stream_seek ( $offset, $whence = SEEK_SET );
+ public function stream_seek($offset, $whence = SEEK_SET);
/**
* Change stream options.
* This method is called to set options on the stream.
*
- * @access public
* @param int $option One of:
* * STREAM_OPTION_BLOCKING, the method was
* called in response to
@@ -221,42 +209,38 @@ interface Stream {
* buffer size.
* @return bool
*/
- public function stream_set_option ( $option, $arg1, $arg2 );
+ public function stream_set_option($option, $arg1, $arg2);
/**
* Retrieve information about a file resource.
* This method is called in response to fstat().
*
- * @access public
* @return array
*/
- public function stream_stat ( );
+ public function stream_stat();
/**
* Retrieve the current position of a stream.
* This method is called in response to ftell().
*
- * @access public
* @return int
*/
- public function stream_tell ( );
+ public function stream_tell();
/**
* Truncate a stream to a given length.
*
- * @access public
* @param int $size Size.
* @return bool
*/
- public function stream_truncate ( $size );
+ public function stream_truncate($size);
/**
* Write to stream.
* This method is called in response to fwrite().
*
- * @access public
* @param string $data Should be stored into the underlying stream.
* @return int
*/
- public function stream_write ( $data );
+ public function stream_write($data);
}
diff --git a/Wrapper/Wrapper.php b/Wrapper/Wrapper.php
index 4980c29..ad41f90 100644
--- a/Wrapper/Wrapper.php
+++ b/Wrapper/Wrapper.php
@@ -8,7 +8,7 @@
*
* New BSD License
*
- * Copyright © 2007-2015, Ivan Enderlin. All rights reserved.
+ * Copyright © 2007-2015, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -43,35 +43,39 @@ use Hoa\Core;
*
* Manipulate wrappers.
*
- * @author Ivan Enderlin <ivan.enderlin@hoa-project.net>
- * @copyright Copyright © 2007-2015 Ivan Enderlin.
+ * @copyright Copyright © 2007-2015 Hoa community
* @license New BSD License
*/
-
-class Wrapper {
-
+class Wrapper
+{
/**
* Register a wrapper.
*
- * @access public
* @param string $protocol The wrapper name to be registered.
* @param string $classname Classname which implements the $protocol.
* @param int $flags Should be set to STREAM_IS_URL if
* $protocol is a URL protocol. Default is 0,
* local stream.
* @return bool
- * @throw \Hoa\Stream\Wrapper\Exception
+ * @throws \Hoa\Stream\Wrapper\Exception
*/
- public static function register ( $protocol, $classname, $flags = 0 ) {
-
- if(true === self::isRegistered($protocol))
+ public static function register($protocol, $classname, $flags = 0)
+ {
+ if (true === self::isRegistered($protocol)) {
throw new Exception(
- 'The protocol %s is already registered.', 0, $protocol);
+ 'The protocol %s is already registered.',
+ 0,
+ $protocol
+ );
+ }
- if(false === class_exists($classname))
+ if (false === class_exists($classname)) {
throw new Exception(
'Cannot register the %s class because it is not found.',
- 1, $classname);
+ 1,
+ $classname
+ );
+ }
return stream_wrapper_register($protocol, $classname, $flags);
}
@@ -79,46 +83,42 @@ class Wrapper {
/**
* Unregister a wrapper.
*
- * @access public
* @param string $protocol The wrapper name to be unregistered.
* @return bool
*/
- public static function unregister ( $protocol ) {
-
+ public static function unregister($protocol)
+ {
return stream_wrapper_unregister($protocol);
}
/**
* Restore a previously unregistered build-in wrapper.
*
- * @access public
* @param string $protocol The wrapper name to be restored.
* @return bool
*/
- public static function restore ( $protocol ) {
-
+ public static function restore($protocol)
+ {
return stream_wrapper_restore($protocol);
}
/**
* Check if a protocol is registered or not.
*
- * @access public
* @param string $protocol Protocol name.
*/
- public static function isRegistered ( $protocol ) {
-
+ public static function isRegistered($protocol)
+ {
return in_array($protocol, self::getRegistered());
}
/**
* Get all registered wrapper.
*
- * @access public
* @return array
*/
- public static function getRegistered ( ) {
-
+ public static function getRegistered()
+ {
return stream_get_wrappers();
}
}