summaryrefslogtreecommitdiffstats
path: root/src/Modifier/StreamFilter.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Modifier/StreamFilter.php')
-rw-r--r--src/Modifier/StreamFilter.php76
1 files changed, 37 insertions, 39 deletions
diff --git a/src/Modifier/StreamFilter.php b/src/Modifier/StreamFilter.php
index e07d2bc..e3f0600 100644
--- a/src/Modifier/StreamFilter.php
+++ b/src/Modifier/StreamFilter.php
@@ -30,14 +30,14 @@ trait StreamFilter
*
* @var array
*/
- protected $stream_filters = [];
+ protected $streamFilters = [];
/**
* Stream filtering mode to apply on all filters
*
* @var int
*/
- protected $stream_filter_mode = STREAM_FILTER_ALL;
+ protected $streamFilterMode = STREAM_FILTER_ALL;
/**
*the real path
@@ -45,7 +45,7 @@ trait StreamFilter
* @var string the real path to the file
*
*/
- protected $stream_uri;
+ protected $streamUri;
/**
* PHP Stream Filter Regex
@@ -70,21 +70,21 @@ trait StreamFilter
*/
protected function initStreamFilter($path)
{
- $this->stream_filters = [];
+ $this->streamFilters = [];
if (!is_string($path)) {
- $this->stream_uri = null;
+ $this->streamUri = null;
return;
}
if (!preg_match($this->stream_regex, $path, $matches)) {
- $this->stream_uri = $path;
+ $this->streamUri = $path;
return;
}
- $this->stream_uri = $matches['resource'];
- $this->stream_filters = array_map('urldecode', explode('|', $matches['filters']));
- $this->stream_filter_mode = $this->fetchStreamModeAsInt($matches['mode']);
+ $this->streamUri = $matches['resource'];
+ $this->streamFilters = array_map('urldecode', explode('|', $matches['filters']));
+ $this->streamFilterMode = $this->fetchStreamModeAsInt($matches['mode']);
}
/**
@@ -116,7 +116,7 @@ trait StreamFilter
*/
protected function assertStreamable()
{
- if (!is_string($this->stream_uri)) {
+ if (!is_string($this->streamUri)) {
throw new LogicException('The stream filter API can not be used');
}
}
@@ -128,7 +128,7 @@ trait StreamFilter
*/
public function isActiveStreamFilter()
{
- return is_string($this->stream_uri);
+ return is_string($this->streamUri);
}
/**
@@ -150,8 +150,8 @@ trait StreamFilter
throw new OutOfBoundsException('the $mode should be a valid `STREAM_FILTER_*` constant');
}
- $this->stream_filter_mode = $mode;
- $this->stream_filters = [];
+ $this->streamFilterMode = $mode;
+ $this->streamFilters = [];
return $this;
}
@@ -165,20 +165,20 @@ trait StreamFilter
{
$this->assertStreamable();
- return $this->stream_filter_mode;
+ return $this->streamFilterMode;
}
/**
* append a stream filter
*
- * @param string $filter_name a string or an object that implements the '__toString' method
+ * @param string $filterName a string or an object that implements the '__toString' method
*
* @return $this
*/
- public function appendStreamFilter($filter_name)
+ public function appendStreamFilter($filterName)
{
$this->assertStreamable();
- $this->stream_filters[] = $this->sanitizeStreamFilter($filter_name);
+ $this->streamFilters[] = $this->sanitizeStreamFilter($filterName);
return $this;
}
@@ -186,14 +186,14 @@ trait StreamFilter
/**
* prepend a stream filter
*
- * @param string $filter_name a string or an object that implements the '__toString' method
+ * @param string $filterName a string or an object that implements the '__toString' method
*
* @return $this
*/
- public function prependStreamFilter($filter_name)
+ public function prependStreamFilter($filterName)
{
$this->assertStreamable();
- array_unshift($this->stream_filters, $this->sanitizeStreamFilter($filter_name));
+ array_unshift($this->streamFilters, $this->sanitizeStreamFilter($filterName));
return $this;
}
@@ -201,15 +201,13 @@ trait StreamFilter
/**
* Sanitize the stream filter name
*
- * @param string $filter_name the stream filter name
+ * @param string $filterName the stream filter name
*
* @return string
*/
- protected function sanitizeStreamFilter($filter_name)
+ protected function sanitizeStreamFilter($filterName)
{
- $this->assertStreamable();
-
- return urldecode($this->validateString($filter_name));
+ return urldecode($this->validateString($filterName));
}
/**
@@ -220,30 +218,30 @@ trait StreamFilter
/**
* Detect if the stream filter is already present
*
- * @param string $filter_name
+ * @param string $filterName
*
* @return bool
*/
- public function hasStreamFilter($filter_name)
+ public function hasStreamFilter($filterName)
{
$this->assertStreamable();
- return false !== array_search(urldecode($filter_name), $this->stream_filters, true);
+ return false !== array_search(urldecode($filterName), $this->streamFilters, true);
}
/**
* Remove a filter from the collection
*
- * @param string $filter_name
+ * @param string $filterName
*
* @return $this
*/
- public function removeStreamFilter($filter_name)
+ public function removeStreamFilter($filterName)
{
$this->assertStreamable();
- $res = array_search(urldecode($filter_name), $this->stream_filters, true);
+ $res = array_search(urldecode($filterName), $this->streamFilters, true);
if (false !== $res) {
- unset($this->stream_filters[$res]);
+ unset($this->streamFilters[$res]);
}
return $this;
@@ -257,7 +255,7 @@ trait StreamFilter
public function clearStreamFilter()
{
$this->assertStreamable();
- $this->stream_filters = [];
+ $this->streamFilters = [];
return $this;
}
@@ -270,14 +268,14 @@ trait StreamFilter
protected function getStreamFilterPath()
{
$this->assertStreamable();
- if (!$this->stream_filters) {
- return $this->stream_uri;
+ if (!$this->streamFilters) {
+ return $this->streamUri;
}
return 'php://filter/'
.$this->getStreamFilterPrefix()
- .implode('|', array_map('urlencode', $this->stream_filters))
- .'/resource='.$this->stream_uri;
+ .implode('|', array_map('urlencode', $this->streamFilters))
+ .'/resource='.$this->streamUri;
}
/**
@@ -287,11 +285,11 @@ trait StreamFilter
*/
protected function getStreamFilterPrefix()
{
- if (STREAM_FILTER_READ == $this->stream_filter_mode) {
+ if (STREAM_FILTER_READ == $this->streamFilterMode) {
return 'read=';
}
- if (STREAM_FILTER_WRITE == $this->stream_filter_mode) {
+ if (STREAM_FILTER_WRITE == $this->streamFilterMode) {
return 'write=';
}