Initial commit: base git repo structure, base Storage implementation and tests

This commit is contained in:
ErickSkrauch 2016-04-26 23:29:38 +03:00
commit f65846ad9b
8 changed files with 159 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
.idea
build
composer.lock
vendor

1
CHANGELOG.md Normal file
View File

@ -0,0 +1 @@
// TODO

21
LICENSE.md Normal file
View File

@ -0,0 +1,21 @@
# The MIT License (MIT)
Copyright (c) 2016 Ely.by <team@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.

1
README.md Normal file
View File

@ -0,0 +1 @@
// TODO

25
composer.json Normal file
View File

@ -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"
}
}

29
phpunit.xml.dist Normal file
View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Ely Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
<logging>
<log type="tap" target="build/report.tap"/>
<log type="junit" target="build/report.junit.xml"/>
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
</phpunit>

49
src/Storage.php Normal file
View File

@ -0,0 +1,49 @@
<?php
namespace Ely\TempMailBuster;
class Storage
{
/**
* @var array of string, which contains masks for temp mail services
*/
private $blacklist;
/**
* @return array with current blacklist
*/
public function getBlacklist()
{
return $this->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;
}
}

29
tests/StorageTest.php Normal file
View File

@ -0,0 +1,29 @@
<?php
namespace Ely\TempMailBuster;
class StorageTest extends \PHPUnit_Framework_TestCase
{
public function testGetBlackList()
{
$storage = new Storage(['item']);
$this->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());
}
}