Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Removed PluginCollection class

I got rid of the need to have your plugins contained in the
PluginCollection class - a simple array works just as well. Let's not
over-complicate things.
  • Loading branch information...
commit a244952d5b1a7b39e09340897c56ec66304df2b7 1 parent 8ae4b00
Jarrod Nettles authored
View
2  src/PHPThumb/GD.php
@@ -93,7 +93,7 @@ class GD extends PHPThumb
* @param array $options
* @param bool $isDataStream
*/
- public function __construct($fileName, $options = array(), PluginCollection $plugins = null)
+ public function __construct($fileName, $options = array(), array $plugins = array())
{
parent::__construct($fileName, $options, $plugins);
View
8 src/PHPThumb/PHPThumb.php
@@ -62,7 +62,7 @@
/**
* An array of attached plugins to execute in order.
- * @var PluginCollection
+ * @var array
*/
protected $plugins;
@@ -72,7 +72,7 @@
* @param array $options
* @param array $plugins
*/
- public function __construct($fileName, array $options = array(), PluginCollection $plugins = null)
+ public function __construct($fileName, array $options = array(), array $plugins = array())
{
$this->fileName = $fileName;
$this->remoteImage = false;
@@ -80,10 +80,6 @@ public function __construct($fileName, array $options = array(), PluginCollectio
$this->fileExistsAndReadable();
$this->setOptions($options);
- if (is_null($plugins)) {
- $plugins = new PluginCollection();
- }
-
$this->plugins = $plugins;
}
View
31 src/PHPThumb/PluginCollection.php
@@ -1,31 +0,0 @@
-<?php
-
-namespace PHPThumb;
-
-class PluginCollection implements \IteratorAggregate
-{
- protected $collection = array();
-
- public function __construct(array $plugins = array())
- {
- $this->collection = $plugins;
- }
-
- public function addPlugin(ThumbPluginInterface $plugin)
- {
- $this->collection[] = $plugin;
- }
-
- /**
- * @return ThumbPluginInterface[]
- */
- public function getPlugins()
- {
- return $this->collection;
- }
-
- public function getIterator()
- {
- return new \ArrayIterator($this->collection);
- }
-}
View
39 tests/PHPThumb/PluginCollectionTest.php
@@ -1,39 +0,0 @@
-<?php
-
-namespace PHPThumb\Tests;
-
-use PHPThumb\ThumbPluginInterface;
-use PHPThumb\PluginCollection;
-
-class PluginCollectionTest extends \PHPUnit_Framework_TestCase
-{
- /**
- * @var PluginCollection
- */
- protected $pluginCollection;
-
- protected function setUp()
- {
- $this->pluginCollection = new PluginCollection();
- }
-
- public function testState()
- {
- self::assertSame(array(), $this->pluginCollection->getPlugins());
- }
-
- public function testAddPlugin()
- {
- $mockPlugin = $this->getMock('\PHPThumb\ThumbPluginInterface');
- $this->pluginCollection->addPlugin($mockPlugin);
-
- self::assertSame(1, count($this->pluginCollection->getPlugins()));
- }
-
- public function testIterator()
- {
- foreach ($this->pluginCollection as $plugin) {
- self::assertInstanceOf('\PHPThumb\ThumbPluginInterface', $plugin);
- }
- }
-}
Please sign in to comment.
Something went wrong with that request. Please try again.