mirror of
https://github.com/guzzle/guzzle.git
synced 2025-02-25 10:33:18 +01:00
Formatting Inflector
This commit is contained in:
parent
482c69400b
commit
480a7f858f
@ -7,9 +7,7 @@ namespace Guzzle\Inflection;
|
||||
*/
|
||||
class Inflector implements InflectorInterface
|
||||
{
|
||||
/**
|
||||
* @var InflectorInterface
|
||||
*/
|
||||
/** @var InflectorInterface */
|
||||
protected static $default;
|
||||
|
||||
/**
|
||||
@ -28,17 +26,11 @@ class Inflector implements InflectorInterface
|
||||
return self::$default;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function snake($word)
|
||||
{
|
||||
return ctype_lower($word) ? $word : strtolower(preg_replace('/(.)([A-Z])/', "$1_$2", $word));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function camel($word)
|
||||
{
|
||||
return str_replace(' ', '', ucwords(strtr($word, '_-', ' ')));
|
||||
|
@ -7,22 +7,16 @@ namespace Guzzle\Inflection;
|
||||
*/
|
||||
class MemoizingInflector implements InflectorInterface
|
||||
{
|
||||
/**
|
||||
* @var array Array of cached inflections
|
||||
*/
|
||||
/** @var array Array of cached inflections */
|
||||
protected $cache = array(
|
||||
'snake' => array(),
|
||||
'camel' => array()
|
||||
);
|
||||
|
||||
/**
|
||||
* @var int Max entries per cache
|
||||
*/
|
||||
/** @var int Max entries per cache */
|
||||
protected $maxCacheSize;
|
||||
|
||||
/**
|
||||
* @var InflectorInterface Decorated inflector
|
||||
*/
|
||||
/** @var InflectorInterface Decorated inflector */
|
||||
protected $decoratedInflector;
|
||||
|
||||
/**
|
||||
@ -35,9 +29,6 @@ class MemoizingInflector implements InflectorInterface
|
||||
$this->maxCacheSize = $maxCacheSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function snake($word)
|
||||
{
|
||||
if (!isset($this->cache['snake'][$word])) {
|
||||
|
@ -7,22 +7,16 @@ namespace Guzzle\Inflection;
|
||||
*/
|
||||
class PreComputedInflector implements InflectorInterface
|
||||
{
|
||||
/**
|
||||
* @var array Array of pre-computed inflections
|
||||
*/
|
||||
/** @var array Array of pre-computed inflections */
|
||||
protected $mapping = array(
|
||||
'snake' => array(),
|
||||
'camel' => array()
|
||||
);
|
||||
|
||||
/**
|
||||
* @var InflectorInterface Decorated inflector
|
||||
*/
|
||||
/** @var InflectorInterface Decorated inflector */
|
||||
protected $decoratedInflector;
|
||||
|
||||
/**
|
||||
* Decorate using a pre-computed map.
|
||||
*
|
||||
* @param InflectorInterface $inflector Inflector being decorated
|
||||
* @param array $snake Hash of pre-computed camel to snake
|
||||
* @param array $camel Hash of pre-computed snake to camel
|
||||
@ -42,9 +36,6 @@ class PreComputedInflector implements InflectorInterface
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function snake($word)
|
||||
{
|
||||
return isset($this->mapping['snake'][$word])
|
||||
|
@ -7,14 +7,10 @@ namespace Guzzle\Iterator;
|
||||
*/
|
||||
class ChunkedIterator extends \IteratorIterator
|
||||
{
|
||||
/**
|
||||
* @var int Size of each chunk
|
||||
*/
|
||||
/** @var int Size of each chunk */
|
||||
protected $chunkSize;
|
||||
|
||||
/**
|
||||
* @var array Current chunk
|
||||
*/
|
||||
/** @var array Current chunk */
|
||||
protected $chunk;
|
||||
|
||||
/**
|
||||
@ -27,17 +23,11 @@ class ChunkedIterator extends \IteratorIterator
|
||||
$this->chunkSize = $chunkSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rewind()
|
||||
{
|
||||
$this->next();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function next()
|
||||
{
|
||||
$this->chunk = array();
|
||||
@ -48,17 +38,11 @@ class ChunkedIterator extends \IteratorIterator
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
return $this->chunk;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return !empty($this->chunk);
|
||||
|
@ -11,9 +11,7 @@ use Guzzle\Common\Exception\InvalidArgumentException;
|
||||
*/
|
||||
class FilterIterator extends \FilterIterator
|
||||
{
|
||||
/**
|
||||
* @var mixed Callback used for filtering
|
||||
*/
|
||||
/** @var mixed Callback used for filtering */
|
||||
protected $callback;
|
||||
|
||||
/**
|
||||
@ -31,9 +29,6 @@ class FilterIterator extends \FilterIterator
|
||||
$this->callback = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function accept()
|
||||
{
|
||||
return call_user_func($this->callback, $this->current());
|
||||
|
@ -9,9 +9,7 @@ use Guzzle\Common\Exception\InvalidArgumentException;
|
||||
*/
|
||||
class MapIterator extends \IteratorIterator
|
||||
{
|
||||
/**
|
||||
* @var mixed Callback
|
||||
*/
|
||||
/** @var mixed Callback */
|
||||
protected $callback;
|
||||
|
||||
/**
|
||||
@ -29,9 +27,6 @@ class MapIterator extends \IteratorIterator
|
||||
$this->callback = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
return call_user_func($this->callback, parent::current());
|
||||
|
Loading…
x
Reference in New Issue
Block a user