diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..9d49909 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +; This file is for unifying the coding style for different editors and IDEs. +; More information at http://editorconfig.org + +root = true + +[*] +charset = utf-8 +indent_size = 4 +indent_style = space +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false \ No newline at end of file diff --git a/README.md b/README.md index 3ca6cfb..16139f9 100644 --- a/README.md +++ b/README.md @@ -13,34 +13,37 @@ You need to have the [cURL](http://php.net/manual/en/book.curl.php)-extension in ## Usage ``` php -require_once 'src/Mailinator/Mailinator.php'; +require_once __DIR__ . '/vendor/autoload.php'; + +use Mailinator\Mailinator; + $mailinator = new Mailinator('my_token'); //Get messages in inbox// try { - print_r($mailinator->inbox('randominbox')); + print_r($mailinator->inbox('randominbox')); } catch(Exception $e) { - // Process the error - echo "Something went wrong: " . $e->getMessage(); + // Process the error + echo "Something went wrong: " . $e->getMessage(); } //Get a message// try { - print_r($mailinator->message('mail-id')); + print_r($mailinator->message('mail-id')); } catch(Exception $e) { - // Process the error - echo "Something went wrong: " . $e->getMessage(); + // Process the error + echo "Something went wrong: " . $e->getMessage(); } //Delete a message// try { - print_r($mailinator->delete('mail-id')); + print_r($mailinator->delete('mail-id')); } catch(Exception $e) { - // Process the error - echo "Something went wrong: " . $e->getMessage(); + // Process the error + echo "Something went wrong: " . $e->getMessage(); } ``` diff --git a/composer.json b/composer.json index f6effe1..29c466d 100644 --- a/composer.json +++ b/composer.json @@ -16,9 +16,15 @@ "require": { "php": ">=5.2.1" }, + "require-dev": { + "friendsofphp/php-cs-fixer": "@stable" + }, "autoload": { "psr-0": { "Mailinator": "src/" } + }, + "config": { + "optimize-autoloader": true } } diff --git a/composer.lock b/composer.lock index a103840..8ae0829 100644 --- a/composer.lock +++ b/composer.lock @@ -4,13 +4,1062 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "700f31d85c05ff0e2fe30586e7a4028f", - "content-hash": "74f159807304ab650c0de88875e7e9d3", + "hash": "ef2189c1682b45c2d96d496515f6ec2f", + "content-hash": "d5854d44b27cd1eb2452fdfb49c2291f", "packages": [], - "packages-dev": [], + "packages-dev": [ + { + "name": "doctrine/annotations", + "version": "v1.4.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/annotations.git", + "reference": "54cacc9b81758b14e3ce750f205a393d52339e97" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/54cacc9b81758b14e3ce750f205a393d52339e97", + "reference": "54cacc9b81758b14e3ce750f205a393d52339e97", + "shasum": "" + }, + "require": { + "doctrine/lexer": "1.*", + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "doctrine/cache": "1.*", + "phpunit/phpunit": "^5.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Docblock Annotations Parser", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "docblock", + "parser" + ], + "time": "2017-02-24 16:22:25" + }, + { + "name": "doctrine/lexer", + "version": "v1.0.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/lexer.git", + "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/83893c552fd2045dd78aef794c31e694c37c0b8c", + "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Common\\Lexer\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "lexer", + "parser" + ], + "time": "2014-09-09 13:34:57" + }, + { + "name": "friendsofphp/php-cs-fixer", + "version": "v2.3.2", + "source": { + "type": "git", + "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", + "reference": "597745f744bcce1aed59dfd1bb4603de2a06cda9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/597745f744bcce1aed59dfd1bb4603de2a06cda9", + "reference": "597745f744bcce1aed59dfd1bb4603de2a06cda9", + "shasum": "" + }, + "require": { + "doctrine/annotations": "^1.2", + "ext-json": "*", + "ext-tokenizer": "*", + "gecko-packages/gecko-php-unit": "^2.0", + "php": "^5.6 || >=7.0 <7.2", + "sebastian/diff": "^1.4", + "symfony/console": "^3.0", + "symfony/event-dispatcher": "^3.0", + "symfony/filesystem": "^3.0", + "symfony/finder": "^3.0", + "symfony/options-resolver": "^3.0", + "symfony/polyfill-php70": "^1.0", + "symfony/polyfill-xml": "^1.3", + "symfony/process": "^3.0", + "symfony/stopwatch": "^3.0" + }, + "conflict": { + "hhvm": "<3.18" + }, + "require-dev": { + "johnkary/phpunit-speedtrap": "^1.1", + "justinrainbow/json-schema": "^5.0", + "mi-schi/phpmd-extension": "^4.2", + "phpmd/phpmd": "^2.4.3", + "phpunit/phpunit": "^4.8.35 || ^5.4.3", + "satooshi/php-coveralls": "^1.0", + "symfony/phpunit-bridge": "^3.2.2" + }, + "suggest": { + "ext-mbstring": "For handling non-UTF8 characters in cache signature.", + "ext-xml": "For better performance.", + "symfony/polyfill-mbstring": "When enabling `ext-mbstring` is not possible." + }, + "bin": [ + "php-cs-fixer" + ], + "type": "application", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, + "autoload": { + "psr-4": { + "PhpCsFixer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Dariusz RumiƄski", + "email": "dariusz.ruminski@gmail.com" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "A tool to automatically fix PHP code style", + "time": "2017-05-24 21:59:38" + }, + { + "name": "gecko-packages/gecko-php-unit", + "version": "v2.1", + "source": { + "type": "git", + "url": "https://github.com/GeckoPackages/GeckoPHPUnit.git", + "reference": "5b9e9622c7efd3b22655270b80c03f9e52878a6e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/GeckoPackages/GeckoPHPUnit/zipball/5b9e9622c7efd3b22655270b80c03f9e52878a6e", + "reference": "5b9e9622c7efd3b22655270b80c03f9e52878a6e", + "shasum": "" + }, + "require": { + "php": "^5.3.6 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.4.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "GeckoPackages\\PHPUnit\\": "src\\PHPUnit" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Additional PHPUnit tests.", + "homepage": "https://github.com/GeckoPackages", + "keywords": [ + "extension", + "filesystem", + "phpunit" + ], + "time": "2017-06-20 11:22:48" + }, + { + "name": "paragonie/random_compat", + "version": "v2.0.10", + "source": { + "type": "git", + "url": "https://github.com/paragonie/random_compat.git", + "reference": "634bae8e911eefa89c1abfbf1b66da679ac8f54d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/634bae8e911eefa89c1abfbf1b66da679ac8f54d", + "reference": "634bae8e911eefa89c1abfbf1b66da679ac8f54d", + "shasum": "" + }, + "require": { + "php": ">=5.2.0" + }, + "require-dev": { + "phpunit/phpunit": "4.*|5.*" + }, + "suggest": { + "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." + }, + "type": "library", + "autoload": { + "files": [ + "lib/random.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com" + } + ], + "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", + "keywords": [ + "csprng", + "pseudorandom", + "random" + ], + "time": "2017-03-13 16:27:32" + }, + { + "name": "psr/log", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2016-10-10 12:19:37" + }, + { + "name": "sebastian/diff", + "version": "1.4.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/7f066a26a962dbe58ddea9f72a4e82874a3975a4", + "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff" + ], + "time": "2017-05-22 07:24:03" + }, + { + "name": "symfony/console", + "version": "v3.3.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "a97e45d98c59510f085fa05225a1acb74dfe0546" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/a97e45d98c59510f085fa05225a1acb74dfe0546", + "reference": "a97e45d98c59510f085fa05225a1acb74dfe0546", + "shasum": "" + }, + "require": { + "php": ">=5.5.9", + "symfony/debug": "~2.8|~3.0", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/dependency-injection": "<3.3" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~3.3", + "symfony/dependency-injection": "~3.3", + "symfony/event-dispatcher": "~2.8|~3.0", + "symfony/filesystem": "~2.8|~3.0", + "symfony/http-kernel": "~2.8|~3.0", + "symfony/process": "~2.8|~3.0" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/filesystem": "", + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.3-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Console Component", + "homepage": "https://symfony.com", + "time": "2017-07-03 13:19:36" + }, + { + "name": "symfony/debug", + "version": "v3.3.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/debug.git", + "reference": "bcfd02728d9b776e5c2195a4750c813fe440402f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/debug/zipball/bcfd02728d9b776e5c2195a4750c813fe440402f", + "reference": "bcfd02728d9b776e5c2195a4750c813fe440402f", + "shasum": "" + }, + "require": { + "php": ">=5.5.9", + "psr/log": "~1.0" + }, + "conflict": { + "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" + }, + "require-dev": { + "symfony/http-kernel": "~2.8|~3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.3-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Debug\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Debug Component", + "homepage": "https://symfony.com", + "time": "2017-06-06 14:51:55" + }, + { + "name": "symfony/event-dispatcher", + "version": "v3.3.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "67535f1e3fd662bdc68d7ba317c93eecd973617e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/67535f1e3fd662bdc68d7ba317c93eecd973617e", + "reference": "67535f1e3fd662bdc68d7ba317c93eecd973617e", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "conflict": { + "symfony/dependency-injection": "<3.3" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~2.8|~3.0", + "symfony/dependency-injection": "~3.3", + "symfony/expression-language": "~2.8|~3.0", + "symfony/stopwatch": "~2.8|~3.0" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.3-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\EventDispatcher\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony EventDispatcher Component", + "homepage": "https://symfony.com", + "time": "2017-06-09 14:53:08" + }, + { + "name": "symfony/filesystem", + "version": "v3.3.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "311fa718389efbd8b627c272b9324a62437018cc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/311fa718389efbd8b627c272b9324a62437018cc", + "reference": "311fa718389efbd8b627c272b9324a62437018cc", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.3-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Filesystem Component", + "homepage": "https://symfony.com", + "time": "2017-06-24 09:29:48" + }, + { + "name": "symfony/finder", + "version": "v3.3.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "baea7f66d30854ad32988c11a09d7ffd485810c4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/baea7f66d30854ad32988c11a09d7ffd485810c4", + "reference": "baea7f66d30854ad32988c11a09d7ffd485810c4", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.3-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Finder Component", + "homepage": "https://symfony.com", + "time": "2017-06-01 21:01:25" + }, + { + "name": "symfony/options-resolver", + "version": "v3.3.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/options-resolver.git", + "reference": "ff48982d295bcac1fd861f934f041ebc73ae40f0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/ff48982d295bcac1fd861f934f041ebc73ae40f0", + "reference": "ff48982d295bcac1fd861f934f041ebc73ae40f0", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.3-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\OptionsResolver\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony OptionsResolver Component", + "homepage": "https://symfony.com", + "keywords": [ + "config", + "configuration", + "options" + ], + "time": "2017-04-12 14:14:56" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "f29dca382a6485c3cbe6379f0c61230167681937" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/f29dca382a6485c3cbe6379f0c61230167681937", + "reference": "f29dca382a6485c3cbe6379f0c61230167681937", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "time": "2017-06-09 14:24:12" + }, + { + "name": "symfony/polyfill-php70", + "version": "v1.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php70.git", + "reference": "032fd647d5c11a9ceab8ee8747e13b5448e93874" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/032fd647d5c11a9ceab8ee8747e13b5448e93874", + "reference": "032fd647d5c11a9ceab8ee8747e13b5448e93874", + "shasum": "" + }, + "require": { + "paragonie/random_compat": "~1.0|~2.0", + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php70\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "time": "2017-06-09 14:24:12" + }, + { + "name": "symfony/polyfill-php72", + "version": "v1.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php72.git", + "reference": "d3a71580c1e2cab33b6d705f0ec40e9015e14d5c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/d3a71580c1e2cab33b6d705f0ec40e9015e14d5c", + "reference": "d3a71580c1e2cab33b6d705f0ec40e9015e14d5c", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php72\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "time": "2017-06-09 08:25:21" + }, + { + "name": "symfony/polyfill-xml", + "version": "v1.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-xml.git", + "reference": "89326af9d173053826ae8fe26a6f49597ba4e9f3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-xml/zipball/89326af9d173053826ae8fe26a6f49597ba4e9f3", + "reference": "89326af9d173053826ae8fe26a6f49597ba4e9f3", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "symfony/polyfill-php72": "~1.4" + }, + "type": "metapackage", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for xml's utf8_encode and utf8_decode functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "time": "2017-06-09 08:25:21" + }, + { + "name": "symfony/process", + "version": "v3.3.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/process.git", + "reference": "5ab8949b682b1bf9d4511a228b5e045c96758c30" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/process/zipball/5ab8949b682b1bf9d4511a228b5e045c96758c30", + "reference": "5ab8949b682b1bf9d4511a228b5e045c96758c30", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.3-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Process\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Process Component", + "homepage": "https://symfony.com", + "time": "2017-07-03 08:12:02" + }, + { + "name": "symfony/stopwatch", + "version": "v3.3.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/stopwatch.git", + "reference": "602a15299dc01556013b07167d4f5d3a60e90d15" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/602a15299dc01556013b07167d4f5d3a60e90d15", + "reference": "602a15299dc01556013b07167d4f5d3a60e90d15", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.3-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Stopwatch\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Stopwatch Component", + "homepage": "https://symfony.com", + "time": "2017-04-12 14:14:56" + } + ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "friendsofphp/php-cs-fixer": 0 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/src/Mailinator/Inbox.php b/src/Mailinator/Inbox.php new file mode 100644 index 0000000..c2631d3 --- /dev/null +++ b/src/Mailinator/Inbox.php @@ -0,0 +1,47 @@ + + */ +class Inbox +{ + private $messages = array(); + + /** + * Constructs a new inbox. + * + * @param array $returnData The data received from a call to the Mailinator API + */ + public function __construct($returnData) + { + foreach ($returnData as $message) { + $this->messages[] = new Message($message); + } + } + + /** + * Returns the messages in this inbox + * + * @return array The list of messages in this inbox as an array of Message objects + */ + public function messages() + { + return $this->messages; + } + + /** + * Counts the amount of messages in this inbox. + * + * @return int The amount of messages in this inbox + */ + public function count() + { + return count($this->messages); + } +} diff --git a/src/Mailinator/Mailinator.php b/src/Mailinator/Mailinator.php index eff39f0..2929f65 100644 --- a/src/Mailinator/Mailinator.php +++ b/src/Mailinator/Mailinator.php @@ -1,4 +1,10 @@ - * @author Muntean Doru */ -class Mailinator { - /** - * The user's token, used to authenticate with the Mailinator API. Can be obtained by creating a free account at http://www.mailinator.com/ - * @var string - */ - private $token; - - /** - * Constructs a new Mailinator instance. - * - * @param string $token The user's token, used to authenticate with the Mailinator API. Can be obtained by creating a free account at http://www.mailinator.com/ - */ - public function __construct($token) { - $this->token = $token; - } - - /** - * Makes a call to the Mailinator API. - * - * @param string $method The method to call - * @param array $params The parameters to send - * @return array The JSON decoded response from the Mailinator API - * @throws \Exception Any errors encountered - */ - private function call($method, $params) { - $ch = curl_init(); - - $callback_parameters = http_build_query(array_merge($params, array('token' => $this->token)),'', '&'); - curl_setopt($ch, CURLOPT_URL, "https://api.mailinator.com/api/" . $method . '?' . $callback_parameters); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - - $exec = curl_exec($ch); - $info = curl_getinfo($ch); - curl_close($ch); - - if($info["http_code"] == 200) { - return json_decode($exec, true); - } else { - throw new \Exception('There was an error contacting the Mailinator API endpoint.'); - } - } - - /** - * Gets the messages for a specified inbox. - * - * @param string $inbox The e-mailaddress to query - * @return Inbox The inbox - * @throws \Exception Any errors encountered - */ - public function inbox($inbox) { - $query = $this->call('inbox', array('to' => $inbox)); - - if(!isset($query["messages"])) { - throw new \Exception('Missing messages data in response from Mailinator API.'); - } - return new Inbox($query["messages"]); - } - - /** - * Gets the message details for the specified message id. - * - * @param string $msgId The id of the message - * @return Message the message - * @throws \Exception Any errors encountered - */ - public function message($msgId) { - $query = $this->call('email', array('id' => $msgId)); - - if(!isset($query["data"])) { - throw new \Exception('Missing data in response from Mailinator API.'); - } - - return new Message($query["data"]); - } - - /** - * Deletes a specified message from the inbox - * - * @param string $msgId The id of the message to delete - * @return bool true if the message was deleted - * @throws \Exception Any errors encountered - */ - public function delete($msgId) { - $query = $this->call('delete', array('id' => $msgId)); - - if(!isset($query["status"])) { - throw new \Exception("Missing result in response from Mailinator API."); - } - - return $query["status"] == "ok"; - } -} - -/** - * Mailinator Inbox - * @package Mailinator - * @license http://opensource.org/licenses/MIT - * @since 2015-09-26 - * @author Pieter De Clercq - */ -class Inbox { - - private $messages = array(); - - /** - * Constructs a new inbox. - * - * @param array $returnData The data received from a call to the Mailinator API - */ - public function __construct($returnData) { - foreach($returnData as $message) { - $this->messages[] = new Message($message); - } - } - - /** - * Returns the messages in this inbox - * - * @return array The list of messages in this inbox as an array of Message objects - */ - public function messages() { - return $this->messages; - } - - /** - * Counts the amount of messages in this inbox. - * - * @return int The amount of messages in this inbox - */ - public function count() { - return count($this->messages); - } -} - -/** - * Mailinator Message - * @package Mailinator - * @license http://opensource.org/licenses/MIT - * @since 2015-09-26 - * @author Pieter De Clercq - */ -class Message { - private $body; - private $fromEmail; - private $fromName; - private $headers = array(); - private $id; - private $ip; - private $read; - private $subject; - private $time; - private $to; - private $secondsAgo; - - /** - * Constructs a new message. - * - * @param array $returnData The data received from a call to the Mailinator API - */ - public function __construct($msgData) { - if(isset($msgData["parts"]) && isset($msgData["parts"][0]) && isset($msgData["parts"][0]["body"])) { - $this->body = $msgData["parts"][0]["body"]; - } - $this->fromEmail = isset($msgData["fromEmail"]) ? $msgData["fromEmail"] : null; - $this->fromName = isset($msgData["from"]) ? $msgData["from"] : null; - if(isset($msgData["headers"])) { - $this->headers = $msgData["headers"]; - } - $this->id = $msgData["id"]; - $this->ip = isset($msgData["ip"]) ? $msgData["ip"] : null; - $this->read = isset($msgData["been_read"]) ? $msgData["been_read"] : null; - $this->subject = $msgData["subject"]; - $this->time = $msgData["time"]; - $this->to = $msgData["to"]; - $this->secondsAgo = $msgData["seconds_ago"]; - } - - /** - * Returns the contents of this message. - * This is only available if the message has been constructed from a call to Mailinator->message() - * - * @return string The message contents - */ - public function body() { - return $this->body; - } - - /** - * Returns the sender's email. - * - * @return string The sender's email - */ - public function fromEmail() { - return $this->fromEmail; - } - - /** - * Returns the name of the sender. - * - * @return string The sender's name - */ - public function fromName() { - return $this->fromName; - } - /** - * Returns the headers of this message. - * This is only available if the message has been constructed from a call to Mailinator->message() - * - * @return array The message headers - */ - public function headers() { - return $this->headers; - } - - /** - * Returns the id of this message. - * - * @return int The message id - */ - public function id() { - return $this->id; - } - - /** - * Returns the IP address of the mailserver this message is originating from. - * - * @return string The mailserver's IP address - */ - public function ip() { - return $this->ip; - } - - /** - * Returns wether or not this message has been read. - * - * @return bool true if this message has been read - */ - public function read() { - return $this->read; - } - - /** - * Returns the subject of this message. - * - * @return string The subject of this message - */ - public function subject() { - return $this->subject; - } - - /** - * Returns the time this message was sent. - * - * @return int The time this message was sent, in seconds since 01/01/1970 - */ - public function time() { - return $this->time; - } - - /** - * Returns the name of the receiver of this message. - * - * @return string The name of the receiver of this message - */ - public function to() { - return $this->to; - } - - /** - * Returns the time this message was sent. - * - * @return int The time this message was sent, in seconds. - */ - public function secondsAgo(){ - return $this->secondsAgo; - } +class Mailinator +{ + /** + * The user's token, used to authenticate with the Mailinator API. Can be obtained by creating a free account at http://www.mailinator.com/ + * @var string + */ + private $token; + + /** + * Constructs a new Mailinator instance. + * + * @param string $token The user's token, used to authenticate with the Mailinator API. Can be obtained by creating a free account at http://www.mailinator.com/ + */ + public function __construct($token) + { + $this->token = $token; + } + + /** + * Makes a call to the Mailinator API. + * + * @param string $method The method to call + * @param array $params The parameters to send + * @return array The JSON decoded response from the Mailinator API + * @throws Exception Any errors encountered + */ + private function call($method, $params) + { + $ch = curl_init(); + + $callback_parameters = http_build_query(array_merge($params, array('token' => $this->token)), '', '&'); + curl_setopt($ch, CURLOPT_URL, "https://api.mailinator.com/api/" . $method . '?' . $callback_parameters); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + + $exec = curl_exec($ch); + $info = curl_getinfo($ch); + curl_close($ch); + + if ($info["http_code"] == 200) { + return json_decode($exec, true); + } else { + throw new Exception('There was an error contacting the Mailinator API endpoint.'); + } + } + + /** + * Gets the messages for a specified inbox. + * + * @param string $inbox The e-mailaddress to query + * @return Inbox The inbox + * @throws Exception Any errors encountered + */ + public function inbox($inbox) + { + $query = $this->call('inbox', array('to' => $inbox)); + + if (!isset($query["messages"])) { + throw new Exception('Missing messages data in response from Mailinator API.'); + } + return new Inbox($query["messages"]); + } + + /** + * Gets the message details for the specified message id. + * + * @param string $msgId The id of the message + * @return Message the message + * @throws Exception Any errors encountered + */ + public function message($msgId) + { + $query = $this->call('email', array('id' => $msgId)); + + if (!isset($query["data"])) { + throw new Exception('Missing data in response from Mailinator API.'); + } + + return new Message($query["data"]); + } + + /** + * Deletes a specified message from the inbox + * + * @param string $msgId The id of the message to delete + * @return bool true if the message was deleted + * @throws Exception Any errors encountered + */ + public function delete($msgId) + { + $query = $this->call('delete', array('id' => $msgId)); + + if (! isset($query["status"])) { + throw new Exception("Missing result in response from Mailinator API."); + } + + return $query["status"] == "ok"; + } } diff --git a/src/Mailinator/Message.php b/src/Mailinator/Message.php new file mode 100644 index 0000000..1cb1f5b --- /dev/null +++ b/src/Mailinator/Message.php @@ -0,0 +1,160 @@ + + */ +class Message +{ + private $body; + private $fromEmail; + private $fromName; + private $headers = array(); + private $id; + private $ip; + private $read; + private $subject; + private $time; + private $to; + private $secondsAgo; + + /** + * Constructs a new message. + * + * @param array $returnData The data received from a call to the Mailinator API + */ + public function __construct($msgData) + { + if (isset($msgData["parts"]) && isset($msgData["parts"][0]) && isset($msgData["parts"][0]["body"])) { + $this->body = $msgData["parts"][0]["body"]; + } + $this->fromEmail = isset($msgData["fromEmail"]) ? $msgData["fromEmail"] : null; + $this->fromName = isset($msgData["from"]) ? $msgData["from"] : null; + if (isset($msgData["headers"])) { + $this->headers = $msgData["headers"]; + } + $this->id = $msgData["id"]; + $this->ip = isset($msgData["ip"]) ? $msgData["ip"] : null; + $this->read = isset($msgData["been_read"]) ? $msgData["been_read"] : null; + $this->subject = $msgData["subject"]; + $this->time = $msgData["time"]; + $this->to = $msgData["to"]; + $this->secondsAgo = $msgData["seconds_ago"]; + } + + /** + * Returns the contents of this message. + * This is only available if the message has been constructed from a call to Mailinator->message() + * + * @return string The message contents + */ + public function body() + { + return $this->body; + } + + /** + * Returns the sender's email. + * + * @return string The sender's email + */ + public function fromEmail() + { + return $this->fromEmail; + } + + /** + * Returns the name of the sender. + * + * @return string The sender's name + */ + public function fromName() + { + return $this->fromName; + } + /** + * Returns the headers of this message. + * This is only available if the message has been constructed from a call to Mailinator->message() + * + * @return array The message headers + */ + public function headers() + { + return $this->headers; + } + + /** + * Returns the id of this message. + * + * @return int The message id + */ + public function id() + { + return $this->id; + } + + /** + * Returns the IP address of the mailserver this message is originating from. + * + * @return string The mailserver's IP address + */ + public function ip() + { + return $this->ip; + } + + /** + * Returns wether or not this message has been read. + * + * @return bool true if this message has been read + */ + public function read() + { + return $this->read; + } + + /** + * Returns the subject of this message. + * + * @return string The subject of this message + */ + public function subject() + { + return $this->subject; + } + + /** + * Returns the time this message was sent. + * + * @return int The time this message was sent, in seconds since 01/01/1970 + */ + public function time() + { + return $this->time; + } + + /** + * Returns the name of the receiver of this message. + * + * @return string The name of the receiver of this message + */ + public function to() + { + return $this->to; + } + + /** + * Returns the time this message was sent. + * + * @return int The time this message was sent, in seconds. + */ + public function secondsAgo() + { + return $this->secondsAgo; + } +}