From f65846ad9bbf95052fa4cc3f29f30a83adb3e3a6 Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Tue, 26 Apr 2016 23:29:38 +0300 Subject: [PATCH] Initial commit: base git repo structure, base Storage implementation and tests --- .gitignore | 4 ++++ CHANGELOG.md | 1 + LICENSE.md | 21 +++++++++++++++++++ README.md | 1 + composer.json | 25 ++++++++++++++++++++++ phpunit.xml.dist | 29 +++++++++++++++++++++++++ src/Storage.php | 49 +++++++++++++++++++++++++++++++++++++++++++ tests/StorageTest.php | 29 +++++++++++++++++++++++++ 8 files changed, 159 insertions(+) create mode 100644 .gitignore create mode 100644 CHANGELOG.md create mode 100644 LICENSE.md create mode 100644 README.md create mode 100644 composer.json create mode 100644 phpunit.xml.dist create mode 100644 src/Storage.php create mode 100644 tests/StorageTest.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5440847 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.idea +build +composer.lock +vendor diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..70b786d --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1 @@ +// TODO diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..21c2611 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +# The MIT License (MIT) + +Copyright (c) 2016 Ely.by + +> Permission is hereby granted, free of charge, to any person obtaining a copy +> of this software and associated documentation files (the "Software"), to deal +> in the Software without restriction, including without limitation the rights +> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +> copies of the Software, and to permit persons to whom the Software is +> furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in +> all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +> THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..70b786d --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +// TODO diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..0c0285b --- /dev/null +++ b/composer.json @@ -0,0 +1,25 @@ +{ + "name": "ely/php-tempmailbuster", + "license": "MIT", + "authors": [ + { + "name": "ErickSkrauch", + "email": "erickskrauch@ely.by" + } + ], + "require": { + "php" : "~5.4|~7.0", + "lib-curl" : "*" + }, + "require-dev": { + "phpunit/phpunit": "~4.8 || ~5.0" + }, + "autoload": { + "psr-4": { + "Ely\\TempMailBuster\\": "src" + } + }, + "scripts": { + "test": "phpunit" + } +} diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..89366cb --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,29 @@ + + + + + tests + + + + + src/ + + + + + + + + + + diff --git a/src/Storage.php b/src/Storage.php new file mode 100644 index 0000000..818c46b --- /dev/null +++ b/src/Storage.php @@ -0,0 +1,49 @@ +blacklist; + } + + /** + * @param string|array $items item or items, that will be merged to blacklist + * @return static + */ + public function appendToBlacklist($items) + { + $items = (array)$items; + $this->blacklist = array_merge($this->blacklist, $items); + + return $this; + } + + /** + * @param array $items override current blacklist with passed values + * @return static + */ + public function setBlacklist(array $items) + { + $this->blacklist = $items; + + return $this; + } + + /** + * @param array $blacklist + */ + public function __construct(array $blacklist = []) + { + $this->blacklist = $blacklist; + } +} diff --git a/tests/StorageTest.php b/tests/StorageTest.php new file mode 100644 index 0000000..f38dc27 --- /dev/null +++ b/tests/StorageTest.php @@ -0,0 +1,29 @@ +assertEquals(['item'], $storage->getBlacklist()); + } + + public function testAppendToBlacklist() + { + $storage = new Storage(['item1']); + $storage->appendToBlacklist(['item2']); + $this->assertEquals(['item1', 'item2'], $storage->getBlacklist()); + + $storage = new Storage(['item1']); + $storage->appendToBlacklist('item2'); + $this->assertEquals(['item1', 'item2'], $storage->getBlacklist()); + } + + public function testSetBlacklist() + { + $storage = new Storage(['item1']); + $storage->setBlacklist(['item2']); + $this->assertEquals(['item2'], $storage->getBlacklist()); + } +}