diff --git a/src/Storage.php b/src/Storage.php index 3028fdd..675d7a4 100644 --- a/src/Storage.php +++ b/src/Storage.php @@ -1,7 +1,7 @@ items = $items; + $this->items = (array)$items; return $this; } /** - * @param string|array $items item or items, that will be merged to items - * @return static + * @inheritdoc */ - public function append($items) + public function appendItems($items) { $items = (array)$items; $this->items = array_merge($this->items, $items); diff --git a/src/StorageInterface.php b/src/StorageInterface.php new file mode 100644 index 0000000..54052f2 --- /dev/null +++ b/src/StorageInterface.php @@ -0,0 +1,22 @@ +primaryStorage = $primaryStorage; $this->secondaryStorage = $secondaryStorage; @@ -62,7 +63,7 @@ class TempMailBuster } /** - * @return Storage + * @return StorageInterface */ public function getPrimaryStorage() { @@ -70,17 +71,17 @@ class TempMailBuster } /** - * @param Storage $primaryStorage + * @param StorageInterface $primaryStorage * @return static */ - public function setPrimaryStorage(Storage $primaryStorage) + public function setPrimaryStorage(StorageInterface $primaryStorage) { $this->primaryStorage = $primaryStorage; return $this; } /** - * @return Storage|null + * @return StorageInterface|null */ public function getSecondaryStorage() { @@ -88,10 +89,10 @@ class TempMailBuster } /** - * @param Storage|null $secondaryStorage + * @param StorageInterface|null $secondaryStorage * @return static */ - public function setSecondaryStorage(Storage $secondaryStorage = null) + public function setSecondaryStorage(StorageInterface $secondaryStorage = null) { $this->secondaryStorage = $secondaryStorage; return $this; diff --git a/tests/StorageTest.php b/tests/StorageTest.php index eea4466..9f7bf12 100644 --- a/tests/StorageTest.php +++ b/tests/StorageTest.php @@ -9,21 +9,21 @@ class StorageTest extends \PHPUnit_Framework_TestCase $this->assertEquals(['item'], $storage->getItems()); } - public function testAppend() - { - $storage = new Storage(['item1']); - $this->assertEquals($storage, $storage->append(['item2'])); - $this->assertEquals(['item1', 'item2'], $storage->getItems()); - - $storage = new Storage(['item1']); - $this->assertEquals($storage, $storage->append('item2')); - $this->assertEquals(['item1', 'item2'], $storage->getItems()); - } - public function testSetItems() { $storage = new Storage(['item1']); $this->assertEquals($storage, $storage->setItems(['item2'])); $this->assertEquals(['item2'], $storage->getItems()); } + + public function testAppendItems() + { + $storage = new Storage(['item1']); + $this->assertEquals($storage, $storage->appendItems(['item2'])); + $this->assertEquals(['item1', 'item2'], $storage->getItems()); + + $storage = new Storage(['item1']); + $this->assertEquals($storage, $storage->appendItems('item2')); + $this->assertEquals(['item1', 'item2'], $storage->getItems()); + } }