diff options
author | yehudah <yehudah@b8457f37-d9ea-0310-8a92-e5e31aec5664> | 2017-12-12 22:00:06 +0000 |
---|---|---|
committer | yehudah <yehudah@b8457f37-d9ea-0310-8a92-e5e31aec5664> | 2017-12-12 22:00:06 +0000 |
commit | 7439876060c3496cce6943850b111350cc350c0b (patch) | |
tree | 40db7ffcd0dab2fdaa6420955c7738ba72079665 /Postman/Postman-Mail/mailgun | |
parent | 118c9d4dce31e2fd85f4177caf70fda521773a98 (diff) | |
download | Post-SMTP-7439876060c3496cce6943850b111350cc350c0b.zip |
* MAILGUN IS ABOUT TO RELEASE
* Email log - trash all
* Email log - records per page
* Welcome page
* Fix config screen tabs
git-svn-id: https://plugins.svn.wordpress.org/post-smtp/trunk@1785793 b8457f37-d9ea-0310-8a92-e5e31aec5664
Diffstat (limited to 'Postman/Postman-Mail/mailgun')
386 files changed, 37649 insertions, 0 deletions
diff --git a/Postman/Postman-Mail/mailgun/composer.json b/Postman/Postman-Mail/mailgun/composer.json new file mode 100644 index 0000000..4806c80 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/composer.json @@ -0,0 +1,7 @@ +{ + "require": { + "mailgun/mailgun-php": "^2.3", + "php-http/curl-client": "^1.7", + "guzzlehttp/psr7": "^1.4" + } +} diff --git a/Postman/Postman-Mail/mailgun/composer.lock b/Postman/Postman-Mail/mailgun/composer.lock new file mode 100644 index 0000000..a00eb9e --- /dev/null +++ b/Postman/Postman-Mail/mailgun/composer.lock @@ -0,0 +1,801 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "313ef327f6509ec8ad576598f4256808", + "content-hash": "262cbcab9c136c29b36e81b0562c427a", + "packages": [ + { + "name": "clue/stream-filter", + "version": "v1.4.0", + "source": { + "type": "git", + "url": "https://github.com/clue/php-stream-filter.git", + "reference": "d80fdee9b3a7e0d16fc330a22f41f3ad0eeb09d0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/clue/php-stream-filter/zipball/d80fdee9b3a7e0d16fc330a22f41f3ad0eeb09d0", + "reference": "d80fdee9b3a7e0d16fc330a22f41f3ad0eeb09d0", + "shasum": "" + }, + "require": { + "php": ">=5.3" + }, + "require-dev": { + "phpunit/phpunit": "^5.0 || ^4.8" + }, + "type": "library", + "autoload": { + "psr-4": { + "Clue\\StreamFilter\\": "src/" + }, + "files": [ + "src/functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@lueck.tv" + } + ], + "description": "A simple and modern approach to stream filtering in PHP", + "homepage": "https://github.com/clue/php-stream-filter", + "keywords": [ + "bucket brigade", + "callback", + "filter", + "php_user_filter", + "stream", + "stream_filter_append", + "stream_filter_register" + ], + "time": "2017-08-18 09:54:01" + }, + { + "name": "guzzlehttp/psr7", + "version": "1.4.2", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c", + "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "psr/http-message": "~1.0" + }, + "provide": { + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Schultze", + "homepage": "https://github.com/Tobion" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "request", + "response", + "stream", + "uri", + "url" + ], + "time": "2017-03-20 17:10:46" + }, + { + "name": "mailgun/mailgun-php", + "version": "2.3.4", + "source": { + "type": "git", + "url": "https://github.com/mailgun/mailgun-php.git", + "reference": "f58c5914aefa16fa6ed2b5cf9ee84d40cbda1b3a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mailgun/mailgun-php/zipball/f58c5914aefa16fa6ed2b5cf9ee84d40cbda1b3a", + "reference": "f58c5914aefa16fa6ed2b5cf9ee84d40cbda1b3a", + "shasum": "" + }, + "require": { + "php": "^5.5|^7.0", + "php-http/client-common": "^1.1", + "php-http/discovery": "^1.0", + "php-http/httplug": "^1.0", + "php-http/message": "^1.0", + "php-http/multipart-stream-builder": "^1.0", + "webmozart/assert": "^1.2" + }, + "require-dev": { + "guzzlehttp/psr7": "^1.4", + "php-http/guzzle6-adapter": "^1.0", + "phpunit/phpunit": "~4.8" + }, + "type": "library", + "autoload": { + "psr-0": { + "Mailgun": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Travis Swientek", + "email": "travis@mailgunhq.com" + } + ], + "description": "The Mailgun SDK provides methods for all API functions.", + "time": "2017-06-20 19:56:09" + }, + { + "name": "php-http/client-common", + "version": "1.7.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/client-common.git", + "reference": "9accb4a082eb06403747c0ffd444112eda41a0fd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/client-common/zipball/9accb4a082eb06403747c0ffd444112eda41a0fd", + "reference": "9accb4a082eb06403747c0ffd444112eda41a0fd", + "shasum": "" + }, + "require": { + "php": "^5.4 || ^7.0", + "php-http/httplug": "^1.1", + "php-http/message": "^1.6", + "php-http/message-factory": "^1.0", + "symfony/options-resolver": "^2.6 || ^3.0 || ^4.0" + }, + "require-dev": { + "guzzlehttp/psr7": "^1.4", + "phpspec/phpspec": "^2.5 || ^3.4 || ^4.2" + }, + "suggest": { + "php-http/cache-plugin": "PSR-6 Cache plugin", + "php-http/logger-plugin": "PSR-3 Logger plugin", + "php-http/stopwatch-plugin": "Symfony Stopwatch plugin" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.7-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Client\\Common\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Common HTTP Client implementations and tools for HTTPlug", + "homepage": "http://httplug.io", + "keywords": [ + "client", + "common", + "http", + "httplug" + ], + "time": "2017-11-30 11:06:59" + }, + { + "name": "php-http/curl-client", + "version": "v1.7.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/curl-client.git", + "reference": "0972ad0d7d37032a52077a5cbe27cf370f2007d8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/curl-client/zipball/0972ad0d7d37032a52077a5cbe27cf370f2007d8", + "reference": "0972ad0d7d37032a52077a5cbe27cf370f2007d8", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "php": "^5.5 || ^7.0", + "php-http/discovery": "^1.0", + "php-http/httplug": "^1.0", + "php-http/message": "^1.2", + "php-http/message-factory": "^1.0.2" + }, + "provide": { + "php-http/async-client-implementation": "1.0", + "php-http/client-implementation": "1.0" + }, + "require-dev": { + "guzzlehttp/psr7": "^1.0", + "php-http/client-integration-tests": "^0.5.1", + "phpunit/phpunit": "^4.8.27", + "zendframework/zend-diactoros": "^1.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Http\\Client\\Curl\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Михаил Красильников", + "email": "m.krasilnikov@yandex.ru" + } + ], + "description": "cURL client for PHP-HTTP", + "homepage": "http://php-http.org", + "keywords": [ + "curl", + "http" + ], + "time": "2017-02-09 15:18:33" + }, + { + "name": "php-http/discovery", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/discovery.git", + "reference": "7b50ab4d6c9fdaa1ed53ae310c955900af6e3372" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/discovery/zipball/7b50ab4d6c9fdaa1ed53ae310c955900af6e3372", + "reference": "7b50ab4d6c9fdaa1ed53ae310c955900af6e3372", + "shasum": "" + }, + "require": { + "php": "^5.5 || ^7.0" + }, + "require-dev": { + "henrikbjorn/phpspec-code-coverage": "^2.0.2", + "php-http/httplug": "^1.0", + "php-http/message-factory": "^1.0", + "phpspec/phpspec": "^2.4", + "puli/composer-plugin": "1.0.0-beta10" + }, + "suggest": { + "php-http/message": "Allow to use Guzzle, Diactoros or Slim Framework factories", + "puli/composer-plugin": "Sets up Puli which is recommended for Discovery to work. Check http://docs.php-http.org/en/latest/discovery.html for more details." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Discovery\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Finds installed HTTPlug implementations and PSR-7 message factories", + "homepage": "http://php-http.org", + "keywords": [ + "adapter", + "client", + "discovery", + "factory", + "http", + "message", + "psr7" + ], + "time": "2017-08-03 10:12:53" + }, + { + "name": "php-http/httplug", + "version": "v1.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/httplug.git", + "reference": "1c6381726c18579c4ca2ef1ec1498fdae8bdf018" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/httplug/zipball/1c6381726c18579c4ca2ef1ec1498fdae8bdf018", + "reference": "1c6381726c18579c4ca2ef1ec1498fdae8bdf018", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "php-http/promise": "^1.0", + "psr/http-message": "^1.0" + }, + "require-dev": { + "henrikbjorn/phpspec-code-coverage": "^1.0", + "phpspec/phpspec": "^2.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Eric GELOEN", + "email": "geloen.eric@gmail.com" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "HTTPlug, the HTTP client abstraction for PHP", + "homepage": "http://httplug.io", + "keywords": [ + "client", + "http" + ], + "time": "2016-08-31 08:30:17" + }, + { + "name": "php-http/message", + "version": "1.6.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/message.git", + "reference": "2edd63bae5f52f79363c5f18904b05ce3a4b7253" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/message/zipball/2edd63bae5f52f79363c5f18904b05ce3a4b7253", + "reference": "2edd63bae5f52f79363c5f18904b05ce3a4b7253", + "shasum": "" + }, + "require": { + "clue/stream-filter": "^1.3", + "php": ">=5.4", + "php-http/message-factory": "^1.0.2", + "psr/http-message": "^1.0" + }, + "provide": { + "php-http/message-factory-implementation": "1.0" + }, + "require-dev": { + "akeneo/phpspec-skip-example-extension": "^1.0", + "coduo/phpspec-data-provider-extension": "^1.0", + "ext-zlib": "*", + "guzzlehttp/psr7": "^1.0", + "henrikbjorn/phpspec-code-coverage": "^1.0", + "phpspec/phpspec": "^2.4", + "slim/slim": "^3.0", + "zendframework/zend-diactoros": "^1.0" + }, + "suggest": { + "ext-zlib": "Used with compressor/decompressor streams", + "guzzlehttp/psr7": "Used with Guzzle PSR-7 Factories", + "slim/slim": "Used with Slim Framework PSR-7 implementation", + "zendframework/zend-diactoros": "Used with Diactoros Factories" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.6-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Message\\": "src/" + }, + "files": [ + "src/filters.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "HTTP Message related tools", + "homepage": "http://php-http.org", + "keywords": [ + "http", + "message", + "psr-7" + ], + "time": "2017-07-05 06:40:53" + }, + { + "name": "php-http/message-factory", + "version": "v1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-http/message-factory.git", + "reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/message-factory/zipball/a478cb11f66a6ac48d8954216cfed9aa06a501a1", + "reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Factory interfaces for PSR-7 HTTP Message", + "homepage": "http://php-http.org", + "keywords": [ + "factory", + "http", + "message", + "stream", + "uri" + ], + "time": "2015-12-19 14:08:53" + }, + { + "name": "php-http/multipart-stream-builder", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/multipart-stream-builder.git", + "reference": "1fa3c623fc813a43b39494b2a1612174e36e0fb0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/multipart-stream-builder/zipball/1fa3c623fc813a43b39494b2a1612174e36e0fb0", + "reference": "1fa3c623fc813a43b39494b2a1612174e36e0fb0", + "shasum": "" + }, + "require": { + "php": "^5.5 || ^7.0", + "php-http/discovery": "^1.0", + "php-http/message-factory": "^1.0.2", + "psr/http-message": "^1.0" + }, + "require-dev": { + "php-http/message": "^1.5", + "phpunit/phpunit": "^4.8 || ^5.4", + "zendframework/zend-diactoros": "^1.3.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.3-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Message\\MultipartStream\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com" + } + ], + "description": "A builder class that help you create a multipart stream", + "homepage": "http://php-http.org", + "keywords": [ + "factory", + "http", + "message", + "multipart stream", + "stream" + ], + "time": "2017-05-21 17:45:25" + }, + { + "name": "php-http/promise", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/promise.git", + "reference": "dc494cdc9d7160b9a09bd5573272195242ce7980" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/promise/zipball/dc494cdc9d7160b9a09bd5573272195242ce7980", + "reference": "dc494cdc9d7160b9a09bd5573272195242ce7980", + "shasum": "" + }, + "require-dev": { + "henrikbjorn/phpspec-code-coverage": "^1.0", + "phpspec/phpspec": "^2.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + }, + { + "name": "Joel Wurtz", + "email": "joel.wurtz@gmail.com" + } + ], + "description": "Promise used for asynchronous HTTP requests", + "homepage": "http://httplug.io", + "keywords": [ + "promise" + ], + "time": "2016-01-26 13:27:02" + }, + { + "name": "psr/http-message", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "time": "2016-08-06 14:39:51" + }, + { + "name": "symfony/options-resolver", + "version": "v3.4.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/options-resolver.git", + "reference": "08748edfe6982f4d878cc42b8325b19a276fb1cf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/08748edfe6982f4d878cc42b8325b19a276fb1cf", + "reference": "08748edfe6982f4d878cc42b8325b19a276fb1cf", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-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-11-05 16:10:10" + }, + { + "name": "webmozart/assert", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/webmozart/assert.git", + "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozart/assert/zipball/2db61e59ff05fe5126d152bd0655c9ea113e550f", + "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.6", + "sebastian/version": "^1.0.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ], + "time": "2016-11-23 20:04:58" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [] +} diff --git a/Postman/Postman-Mail/mailgun/mailgun.php b/Postman/Postman-Mail/mailgun/mailgun.php new file mode 100644 index 0000000..a999c2c --- /dev/null +++ b/Postman/Postman-Mail/mailgun/mailgun.php @@ -0,0 +1,2 @@ +<?php +require 'vendor/autoload.php'; diff --git a/Postman/Postman-Mail/mailgun/vendor/autoload.php b/Postman/Postman-Mail/mailgun/vendor/autoload.php new file mode 100644 index 0000000..f0b6ae9 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/autoload.php @@ -0,0 +1,7 @@ +<?php + +// autoload.php @generated by Composer + +require_once __DIR__ . '/composer' . '/autoload_real.php'; + +return ComposerAutoloaderInit2e493976577e1ff95afbbd5ca63b2ef1::getLoader(); diff --git a/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/.gitignore b/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/.gitignore new file mode 100644 index 0000000..de4a392 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/.gitignore @@ -0,0 +1,2 @@ +/vendor +/composer.lock diff --git a/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/.travis.yml b/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/.travis.yml new file mode 100644 index 0000000..a71864a --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/.travis.yml @@ -0,0 +1,26 @@ +language: php + +php: +# - 5.3 # requires old distro, see below + - 5.4 + - 5.5 + - 5.6 + - 7.0 + - 7.1 + - hhvm # ignore errors, see below + +# lock distro so new future defaults will not break the build +dist: trusty + +matrix: + include: + - php: 5.3 + dist: precise + allow_failures: + - php: hhvm + +install: + - composer install --no-interaction + +script: + - vendor/bin/phpunit --coverage-text diff --git a/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/CHANGELOG.md b/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/CHANGELOG.md new file mode 100644 index 0000000..9d53cd8 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/CHANGELOG.md @@ -0,0 +1,54 @@ +# Changelog + +## 1.4.0 (2017-08-18) + +* Feature / Fix: The `fun()` function does not pass filter parameter `null` + to underlying `stream_filter_append()` by default + (#15 by @Nyholm) + + Certain filters (such as `convert.quoted-printable-encode`) do not accept + a filter parameter at all. If no explicit filter parameter is given, we no + longer pass a default `null` value. + + ```php + $encode = Filter\fun('convert.quoted-printable-encode'); + assert('t=C3=A4st' === $encode('täst')); + ``` + +* Add examples and improve documentation + (#13 and #20 by @clue and #18 by @Nyholm) + +* Improve test suite by adding PHPUnit to require-dev, + fix HHVM build for now again and ignore future HHVM build errors, + lock Travis distro so new future defaults will not break the build + and test on PHP 7.1 + (#12, #14 and #19 by @clue and #16 by @Nyholm) + +## 1.3.0 (2015-11-08) + +* Feature: Support accessing built-in filters as callbacks + (#5 by @clue) + + ```php + $fun = Filter\fun('zlib.deflate'); + + $ret = $fun('hello') . $fun('world') . $fun(); + assert('helloworld' === gzinflate($ret)); + ``` + +## 1.2.0 (2015-10-23) + +* Feature: Invoke close event when closing filter (flush buffer) + (#9 by @clue) + +## 1.1.0 (2015-10-22) + +* Feature: Abort filter operation when catching an Exception + (#10 by @clue) + +* Feature: Additional safeguards to prevent filter state corruption + (#7 by @clue) + +## 1.0.0 (2015-10-18) + +* First tagged release diff --git a/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/LICENSE b/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/LICENSE new file mode 100644 index 0000000..dc09d1e --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Christian Lück + +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/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/README.md b/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/README.md new file mode 100644 index 0000000..d46c2b5 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/README.md @@ -0,0 +1,297 @@ +# clue/stream-filter [![Build Status](https://travis-ci.org/clue/php-stream-filter.svg?branch=master)](https://travis-ci.org/clue/php-stream-filter) + +A simple and modern approach to stream filtering in PHP + +**Table of contents** + +* [Why?](#why) +* [Usage](#usage) + * [append()](#append) + * [prepend()](#prepend) + * [fun()](#fun) + * [remove()](#remove) +* [Install](#install) +* [Tests](#tests) +* [License](#license) + +## Why? + +PHP's stream filtering system is great! + +It offers very powerful stream filtering options and comes with a useful set of built-in filters. +These filters can be used to easily and efficiently perform various transformations on-the-fly, such as: + +* read from a gzip'ed input file, +* transcode from ISO-8859-1 (Latin1) to UTF-8, +* write to a bzip output file +* and much more. + +But let's face it: +Its API is [*difficult to work with*](http://php.net/manual/en/php-user-filter.filter.php) +and its documentation is [*subpar*](http://stackoverflow.com/questions/27103269/what-is-a-bucket-brigade). +This combined means its powerful features are often neglected. + +This project aims to make these features more accessible to a broader audience. +* **Lightweight, SOLID design** - + Provides a thin abstraction that is [*just good enough*](http://en.wikipedia.org/wiki/Principle_of_good_enough) + and does not get in your way. + Custom filters require trivial effort. +* **Good test coverage** - + Comes with an automated tests suite and is regularly tested in the *real world* + +## Usage + +This lightweight library consists only of a few simple functions. +All functions reside under the `Clue\StreamFilter` namespace. + +The below examples assume you use an import statement similar to this: + +```php +use Clue\StreamFilter as Filter; + +Filter\append(…); +``` + +Alternatively, you can also refer to them with their fully-qualified name: + +```php +\Clue\StreamFilter\append(…); +``` + +### append() + +The `append($stream, $callback, $read_write = STREAM_FILTER_ALL)` function can be used to +append a filter callback to the given stream. + +Each stream can have a list of filters attached. +This function appends a filter to the end of this list. + +This function returns a filter resource which can be passed to [`remove()`](#remove). +If the given filter can not be added, it throws an `Exception`. + +The `$stream` can be any valid stream resource, such as: + +```php +$stream = fopen('demo.txt', 'w+'); +``` + +The `$callback` should be a valid callable function which accepts an individual chunk of data +and should return the updated chunk: + +```php +$filter = Filter\append($stream, function ($chunk) { + // will be called each time you read or write a $chunk to/from the stream + return $chunk; +}); +``` + +As such, you can also use native PHP functions or any other `callable`: + +```php +Filter\append($stream, 'strtoupper'); + +// will write "HELLO" to the underlying stream +fwrite($stream, 'hello'); +``` + +If the `$callback` accepts invocation without parameters, then this signature +will be invoked once ending (flushing) the filter: + +```php +Filter\append($stream, function ($chunk = null) { + if ($chunk === null) { + // will be called once ending the filter + return 'end'; + } + // will be called each time you read or write a $chunk to/from the stream + return $chunk; +}); + +fclose($stream); +``` + +> Note: Legacy PHP versions (PHP < 5.4) do not support passing additional data +from the end signal handler if the stream is being closed. + +If your callback throws an `Exception`, then the filter process will be aborted. +In order to play nice with PHP's stream handling, the `Exception` will be +transformed to a PHP warning instead: + +```php +Filter\append($stream, function ($chunk) { + throw new \RuntimeException('Unexpected chunk'); +}); + +// raises an E_USER_WARNING with "Error invoking filter: Unexpected chunk" +fwrite($stream, 'hello'); +``` + +The optional `$read_write` parameter can be used to only invoke the `$callback` when either writing to the stream or only when reading from the stream: + +```php +Filter\append($stream, function ($chunk) { + // will be called each time you write to the stream + return $chunk; +}, STREAM_FILTER_WRITE); + +Filter\append($stream, function ($chunk) { + // will be called each time you read from the stream + return $chunk; +}, STREAM_FILTER_READ); +``` + +> Note that once a filter has been added to stream, the stream can no longer be passed to +> [`stream_select()`](http://php.net/manual/en/function.stream-select.php) +> (and family). +> +> > Warning: stream_select(): cannot cast a filtered stream on this system in {file} on line {line} +> +> This is due to limitations of PHP's stream filter support, as it can no longer reliably +> tell when the underlying stream resource is actually ready. +> As an alternative, consider calling `stream_select()` on the unfiltered stream and +> then pass the unfiltered data through the [`fun()`](#fun) function. + +### prepend() + +The `prepend($stream, $callback, $read_write = STREAM_FILTER_ALL)` function can be used to +prepend a filter callback to the given stream. + +Each stream can have a list of filters attached. +This function prepends a filter to the start of this list. + +This function returns a filter resource which can be passed to [`remove()`](#remove). +If the given filter can not be added, it throws an `Exception`. + +```php +$filter = Filter\prepend($stream, function ($chunk) { + // will be called each time you read or write a $chunk to/from the stream + return $chunk; +}); +``` + +Except for the position in the list of filters, this function behaves exactly +like the [`append()`](#append) function. +For more details about its behavior, see also the [`append()`](#append) function. + +### fun() + +The `fun($filter, $parameters = null)` function can be used to +create a filter function which uses the given built-in `$filter`. + +PHP comes with a useful set of [built-in filters](http://php.net/manual/en/filters.php). +Using `fun()` makes accessing these as easy as passing an input string to filter +and getting the filtered output string. + +```php +$fun = Filter\fun('string.rot13'); + +assert('grfg' === $fun('test')); +assert('test' === $fun($fun('test')); +``` + +Please note that not all filter functions may be available depending on installed +PHP extensions and the PHP version in use. +In particular, [HHVM](http://hhvm.com/) may not offer the same filter functions +or parameters as Zend PHP. +Accessing an unknown filter function will result in a `RuntimeException`: + +```php +Filter\fun('unknown'); // throws RuntimeException +``` + +Some filters may accept or require additional filter parameters – most +filters do not require filter parameters. +If given, the optional `$parameters` argument will be passed to the +underlying filter handler as-is. +In particular, note how *not passing* this parameter at all differs from +explicitly passing a `null` value (which many filters do not accept). +Please refer to the individual filter definition for more details. +For example, the `string.strip_tags` filter can be invoked like this: + +```php +$fun = Filter\fun('string.strip_tags', '<a><b>'); + +$ret = $fun('<b>h<br>i</b>'); +assert('<b>hi</b>' === $ret); +``` + +Under the hood, this function allocates a temporary memory stream, so it's +recommended to clean up the filter function after use. +Also, some filter functions (in particular the +[zlib compression filters](http://php.net/manual/en/filters.compression.php)) +may use internal buffers and may emit a final data chunk on close. +The filter function can be closed by invoking without any arguments: + +```php +$fun = Filter\fun('zlib.deflate'); + +$ret = $fun('hello') . $fun('world') . $fun(); +assert('helloworld' === gzinflate($ret)); +``` + +The filter function must not be used anymore after it has been closed. +Doing so will result in a `RuntimeException`: + +```php +$fun = Filter\fun('string.rot13'); +$fun(); + +$fun('test'); // throws RuntimeException +``` + +> Note: If you're using the zlib compression filters, then you should be wary +about engine inconsistencies between different PHP versions and HHVM. +These inconsistencies exist in the underlying PHP engines and there's little we +can do about this in this library. +[Our test suite](tests/) contains several test cases that exhibit these issues. +If you feel some test case is missing or outdated, we're happy to accept PRs! :) + +### remove() + +The `remove($filter)` function can be used to +remove a filter previously added via [`append()`](#append) or [`prepend()`](#prepend). + +```php +$filter = Filter\append($stream, function () { + // … +}); +Filter\remove($filter); +``` + +## Install + +The recommended way to install this library is [through Composer](https://getcomposer.org). +[New to Composer?](https://getcomposer.org/doc/00-intro.md) + +This will install the latest supported version: + +```bash +$ composer require clue/stream-filter:^1.4 +``` + +See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades. + +This project aims to run on any platform and thus does not require any PHP +extensions and supports running on legacy PHP 5.3 through current PHP 7+ and +HHVM. +It's *highly recommended to use PHP 7+* for this project. +Older PHP versions may suffer from a number of inconsistencies documented above. + +## Tests + +To run the test suite, you first need to clone this repo and then install all +dependencies [through Composer](http://getcomposer.org): + +```bash +$ composer install +``` + +To run the test suite, go to the project root and run: + +```bash +$ php vendor/bin/phpunit +``` + +## License + +MIT diff --git a/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/composer.json b/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/composer.json new file mode 100644 index 0000000..f871053 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/composer.json @@ -0,0 +1,23 @@ +{ + "name": "clue/stream-filter", + "description": "A simple and modern approach to stream filtering in PHP", + "keywords": ["stream", "callback", "filter", "php_user_filter", "stream_filter_append", "stream_filter_register", "bucket brigade"], + "homepage": "https://github.com/clue/php-stream-filter", + "license": "MIT", + "authors": [ + { + "name": "Christian Lück", + "email": "christian@lueck.tv" + } + ], + "require": { + "php": ">=5.3" + }, + "require-dev": { + "phpunit/phpunit": "^5.0 || ^4.8" + }, + "autoload": { + "psr-4": { "Clue\\StreamFilter\\": "src/" }, + "files": [ "src/functions.php" ] + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/examples/base64_decode.php b/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/examples/base64_decode.php new file mode 100644 index 0000000..2b49f10 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/examples/base64_decode.php @@ -0,0 +1,29 @@ +<?php + +// $ echo test | php examples/base64_encode.php | php examples/base64_decode.php + +require __DIR__ . '/../vendor/autoload.php'; + +// decoding requires buffering in chunks of 4 bytes each +$buffer = ''; +Clue\StreamFilter\append(STDIN, function ($chunk = null) use (&$buffer) { + if ($chunk === null) { + if (strlen($buffer) % 4 !== 0) { + throw new \UnexpectedValueException('Invalid length'); + } + $chunk = $buffer; + } else { + $buffer .= $chunk; + $len = strlen($buffer) - (strlen($buffer) % 4); + $chunk = (string)substr($buffer, 0, $len); + $buffer = (string)substr($buffer, $len); + } + + $ret = base64_decode($chunk, true); + if ($ret === false) { + throw new \UnexpectedValueException('Not a valid base64 encoded chunk'); + } + return $ret; +}, STREAM_FILTER_READ); + +fpassthru(STDIN); diff --git a/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/examples/base64_encode.php b/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/examples/base64_encode.php new file mode 100644 index 0000000..fed78ac --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/examples/base64_encode.php @@ -0,0 +1,21 @@ +<?php + +// $ echo test | php examples/base64_encode.php | base64 --decode + +require __DIR__ . '/../vendor/autoload.php'; + +// encoding requires buffering in chunks of 3 bytes each +$buffer = ''; +Clue\StreamFilter\append(STDIN, function ($chunk = null) use (&$buffer) { + if ($chunk === null) { + return base64_encode($buffer); + } + $buffer .= $chunk; + $len = strlen($buffer) - (strlen($buffer) % 3); + $chunk = substr($buffer, 0, $len); + $buffer = substr($buffer, $len); + + return base64_encode($chunk); +}, STREAM_FILTER_READ); + +fpassthru(STDIN); diff --git a/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/examples/uppercase.php b/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/examples/uppercase.php new file mode 100644 index 0000000..5a86f8e --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/examples/uppercase.php @@ -0,0 +1,9 @@ +<?php + +// $ echo test | php examples/uppercase.php + +require __DIR__ . '/../vendor/autoload.php'; + +Clue\StreamFilter\append(STDIN, 'strtoupper'); + +fpassthru(STDIN); diff --git a/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/phpunit.xml.dist b/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/phpunit.xml.dist new file mode 100644 index 0000000..f373698 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/phpunit.xml.dist @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<phpunit bootstrap="vendor/autoload.php" + colors="true" + convertErrorsToExceptions="true" + convertNoticesToExceptions="true" + convertWarningsToExceptions="true" +> + <testsuites> + <testsuite> + <directory>./tests/</directory> + </testsuite> + </testsuites> + <filter> + <whitelist> + <directory>./src/</directory> + </whitelist> + </filter> +</phpunit>
\ No newline at end of file diff --git a/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/src/CallbackFilter.php b/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/src/CallbackFilter.php new file mode 100644 index 0000000..710940b --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/src/CallbackFilter.php @@ -0,0 +1,120 @@ +<?php + +namespace Clue\StreamFilter; + +use php_user_filter; +use InvalidArgumentException; +use ReflectionFunction; +use Exception; + +/** + * + * @internal + * @see append() + * @see prepend() + */ +class CallbackFilter extends php_user_filter +{ + private $callback; + private $closed = true; + private $supportsClose = false; + + public function onCreate() + { + $this->closed = false; + + if (!is_callable($this->params)) { + throw new InvalidArgumentException('No valid callback parameter given to stream_filter_(append|prepend)'); + } + $this->callback = $this->params; + + // callback supports end event if it accepts invocation without arguments + $ref = new ReflectionFunction($this->callback); + $this->supportsClose = ($ref->getNumberOfRequiredParameters() === 0); + + return true; + } + + public function onClose() + { + $this->closed = true; + + // callback supports closing and is not already closed + if ($this->supportsClose) { + $this->supportsClose = false; + // invoke without argument to signal end and discard resulting buffer + try { + call_user_func($this->callback); + } catch (Exception $ignored) { + // this might be called during engine shutdown, so it's not safe + // to raise any errors or exceptions here + // trigger_error('Error closing filter: ' . $ignored->getMessage(), E_USER_WARNING); + } + } + + $this->callback = null; + } + + public function filter($in, $out, &$consumed, $closing) + { + // concatenate whole buffer from input brigade + $data = ''; + while ($bucket = stream_bucket_make_writeable($in)) { + $consumed += $bucket->datalen; + $data .= $bucket->data; + } + + // skip processing callback that already ended + if ($this->closed) { + return PSFS_FEED_ME; + } + + // only invoke filter function if buffer is not empty + // this may skip flushing a closing filter + if ($data !== '') { + try { + $data = call_user_func($this->callback, $data); + } catch (Exception $e) { + // exception should mark filter as closed + $this->onClose(); + trigger_error('Error invoking filter: ' . $e->getMessage(), E_USER_WARNING); + + return PSFS_ERR_FATAL; + } + } + + // mark filter as closed after processing closing chunk + if ($closing) { + $this->closed = true; + + // callback supports closing and is not already closed + if ($this->supportsClose) { + $this->supportsClose = false; + + // invoke without argument to signal end and append resulting buffer + try { + $data .= call_user_func($this->callback); + } catch (Exception $e) { + trigger_error('Error ending filter: ' . $e->getMessage(), E_USER_WARNING); + + return PSFS_ERR_FATAL; + } + } + } + + if ($data !== '') { + // create a new bucket for writing the resulting buffer to the output brigade + // reusing an existing bucket turned out to be bugged in some environments (ancient PHP versions and HHVM) + $bucket = @stream_bucket_new($this->stream, $data); + + // legacy PHP versions (PHP < 5.4) do not support passing data from the event signal handler + // because closing the stream invalidates the stream and its stream bucket brigade before + // invoking the filter close handler. + if ($bucket !== false) { + stream_bucket_append($out, $bucket); + } + } + + return PSFS_PASS_ON; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/src/functions.php b/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/src/functions.php new file mode 100644 index 0000000..d1ca9dc --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/src/functions.php @@ -0,0 +1,146 @@ +<?php + +namespace Clue\StreamFilter; + +use RuntimeException; + +/** + * append a callback filter to the given stream + * + * @param resource $stream + * @param callable $callback + * @param int $read_write + * @return resource filter resource which can be used for `remove()` + * @throws Exception on error + * @uses stream_filter_append() + */ +function append($stream, $callback, $read_write = STREAM_FILTER_ALL) +{ + $ret = @stream_filter_append($stream, register(), $read_write, $callback); + + if ($ret === false) { + $error = error_get_last() + array('message' => ''); + throw new RuntimeException('Unable to append filter: ' . $error['message']); + } + + return $ret; +} + +/** + * prepend a callback filter to the given stream + * + * @param resource $stream + * @param callable $callback + * @param int $read_write + * @return resource filter resource which can be used for `remove()` + * @throws Exception on error + * @uses stream_filter_prepend() + */ +function prepend($stream, $callback, $read_write = STREAM_FILTER_ALL) +{ + $ret = @stream_filter_prepend($stream, register(), $read_write, $callback); + + if ($ret === false) { + $error = error_get_last() + array('message' => ''); + throw new RuntimeException('Unable to prepend filter: ' . $error['message']); + } + + return $ret; +} + +/** + * Creates filter fun (function) which uses the given built-in $filter + * + * Some filters may accept or require additional filter parameters – most + * filters do not require filter parameters. + * If given, the optional `$parameters` argument will be passed to the + * underlying filter handler as-is. + * In particular, note how *not passing* this parameter at all differs from + * explicitly passing a `null` value (which many filters do not accept). + * Please refer to the individual filter definition for more details. + * + * @param string $filter built-in filter name. See stream_get_filters() or http://php.net/manual/en/filters.php + * @param mixed $parameters (optional) parameters to pass to the built-in filter as-is + * @return callable a filter callback which can be append()'ed or prepend()'ed + * @throws RuntimeException on error + * @link http://php.net/manual/en/filters.php + * @see stream_get_filters() + * @see append() + */ +function fun($filter, $parameters = null) +{ + $fp = fopen('php://memory', 'w'); + if (func_num_args() === 1) { + $filter = @stream_filter_append($fp, $filter, STREAM_FILTER_WRITE); + } else { + $filter = @stream_filter_append($fp, $filter, STREAM_FILTER_WRITE, $parameters); + } + + if ($filter === false) { + fclose($fp); + $error = error_get_last() + array('message' => ''); + throw new RuntimeException('Unable to access built-in filter: ' . $error['message']); + } + + // append filter function which buffers internally + $buffer = ''; + append($fp, function ($chunk) use (&$buffer) { + $buffer .= $chunk; + + // always return empty string in order to skip actually writing to stream resource + return ''; + }, STREAM_FILTER_WRITE); + + $closed = false; + + return function ($chunk = null) use ($fp, $filter, &$buffer, &$closed) { + if ($closed) { + throw new \RuntimeException('Unable to perform operation on closed stream'); + } + if ($chunk === null) { + $closed = true; + $buffer = ''; + fclose($fp); + return $buffer; + } + // initialize buffer and invoke filters by attempting to write to stream + $buffer = ''; + fwrite($fp, $chunk); + + // buffer now contains everything the filter function returned + return $buffer; + }; +} + +/** + * remove a callback filter from the given stream + * + * @param resource $filter + * @return boolean true on success or false on error + * @throws Exception on error + * @uses stream_filter_remove() + */ +function remove($filter) +{ + if (@stream_filter_remove($filter) === false) { + throw new RuntimeException('Unable to remove given filter'); + } +} + +/** + * registers the callback filter and returns the resulting filter name + * + * There should be little reason to call this function manually. + * + * @return string filter name + * @uses CallbackFilter + */ +function register() +{ + static $registered = null; + if ($registered === null) { + $registered = 'stream-callback'; + stream_filter_register($registered, __NAMESPACE__ . '\CallbackFilter'); + } + return $registered; +} diff --git a/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/tests/FilterTest.php b/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/tests/FilterTest.php new file mode 100644 index 0000000..02aa3a4 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/tests/FilterTest.php @@ -0,0 +1,386 @@ +<?php + +use Clue\StreamFilter; + +class FilterTest extends PHPUnit_Framework_TestCase +{ + public function testAppendSimpleCallback() + { + $stream = $this->createStream(); + + StreamFilter\append($stream, function ($chunk) { + return strtoupper($chunk); + }); + + fwrite($stream, 'hello'); + fwrite($stream, 'world'); + rewind($stream); + + $this->assertEquals('HELLOWORLD', stream_get_contents($stream)); + + fclose($stream); + } + + public function testAppendNativePhpFunction() + { + $stream = $this->createStream(); + + StreamFilter\append($stream, 'strtoupper'); + + fwrite($stream, 'hello'); + fwrite($stream, 'world'); + rewind($stream); + + $this->assertEquals('HELLOWORLD', stream_get_contents($stream)); + + fclose($stream); + } + + public function testAppendChangingChunkSize() + { + $stream = $this->createStream(); + + StreamFilter\append($stream, function ($chunk) { + return str_replace(array('a','e','i','o','u'), '', $chunk); + }); + + fwrite($stream, 'hello'); + fwrite($stream, 'world'); + rewind($stream); + + $this->assertEquals('hllwrld', stream_get_contents($stream)); + + fclose($stream); + } + + public function testAppendReturningEmptyStringWillNotPassThrough() + { + $stream = $this->createStream(); + + StreamFilter\append($stream, function ($chunk) { + return ''; + }); + + fwrite($stream, 'hello'); + fwrite($stream, 'world'); + rewind($stream); + + $this->assertEquals('', stream_get_contents($stream)); + + fclose($stream); + } + + public function testAppendEndEventCanBeBufferedOnClose() + { + if (PHP_VERSION < 5.4) $this->markTestSkipped('Not supported on legacy PHP'); + + $stream = $this->createStream(); + + StreamFilter\append($stream, function ($chunk = null) { + if ($chunk === null) { + // this signals the end event + return '!'; + } + return $chunk . ' '; + }, STREAM_FILTER_WRITE); + + $buffered = ''; + StreamFilter\append($stream, function ($chunk) use (&$buffered) { + $buffered .= $chunk; + return ''; + }); + + fwrite($stream, 'hello'); + fwrite($stream, 'world'); + + fclose($stream); + + $this->assertEquals('hello world !', $buffered); + } + + public function testAppendEndEventWillBeCalledOnRemove() + { + $stream = $this->createStream(); + + $ended = false; + $filter = StreamFilter\append($stream, function ($chunk = null) use (&$ended) { + if ($chunk === null) { + $ended = true; + } + return $chunk; + }, STREAM_FILTER_WRITE); + + $this->assertEquals(0, $ended); + StreamFilter\remove($filter); + $this->assertEquals(1, $ended); + } + + public function testAppendEndEventWillBeCalledOnClose() + { + $stream = $this->createStream(); + + $ended = false; + StreamFilter\append($stream, function ($chunk = null) use (&$ended) { + if ($chunk === null) { + $ended = true; + } + return $chunk; + }, STREAM_FILTER_WRITE); + + $this->assertEquals(0, $ended); + fclose($stream); + $this->assertEquals(1, $ended); + } + + public function testAppendWriteOnly() + { + $stream = $this->createStream(); + + $invoked = 0; + + StreamFilter\append($stream, function ($chunk) use (&$invoked) { + ++$invoked; + + return $chunk; + }, STREAM_FILTER_WRITE); + + fwrite($stream, 'a'); + fwrite($stream, 'b'); + fwrite($stream, 'c'); + rewind($stream); + + $this->assertEquals(3, $invoked); + $this->assertEquals('abc', stream_get_contents($stream)); + + fclose($stream); + } + + public function testAppendReadOnly() + { + $stream = $this->createStream(); + + $invoked = 0; + + StreamFilter\append($stream, function ($chunk) use (&$invoked) { + ++$invoked; + + return $chunk; + }, STREAM_FILTER_READ); + + fwrite($stream, 'a'); + fwrite($stream, 'b'); + fwrite($stream, 'c'); + rewind($stream); + + $this->assertEquals(0, $invoked); + $this->assertEquals('abc', stream_get_contents($stream)); + $this->assertEquals(1, $invoked); + + fclose($stream); + } + + public function testOrderCallingAppendAfterPrepend() + { + $stream = $this->createStream(); + + StreamFilter\append($stream, function ($chunk) { + return '[' . $chunk . ']'; + }, STREAM_FILTER_WRITE); + + StreamFilter\prepend($stream, function ($chunk) { + return '(' . $chunk . ')'; + }, STREAM_FILTER_WRITE); + + fwrite($stream, 'hello'); + rewind($stream); + + $this->assertEquals('[(hello)]', stream_get_contents($stream)); + + fclose($stream); + } + + public function testRemoveFilter() + { + $stream = $this->createStream(); + + $first = StreamFilter\append($stream, function ($chunk) { + return $chunk . '?'; + }, STREAM_FILTER_WRITE); + + StreamFilter\append($stream, function ($chunk) { + return $chunk . '!'; + }, STREAM_FILTER_WRITE); + + StreamFilter\remove($first); + + fwrite($stream, 'hello'); + rewind($stream); + + $this->assertEquals('hello!', stream_get_contents($stream)); + + fclose($stream); + } + + public function testAppendFunDechunk() + { + if (defined('HHVM_VERSION')) $this->markTestSkipped('Not supported on HHVM (dechunk filter does not exist)'); + + $stream = $this->createStream(); + + StreamFilter\append($stream, StreamFilter\fun('dechunk'), STREAM_FILTER_WRITE); + + fwrite($stream, "2\r\nhe\r\n"); + fwrite($stream, "3\r\nllo\r\n"); + fwrite($stream, "0\r\n\r\n"); + rewind($stream); + + $this->assertEquals('hello', stream_get_contents($stream)); + + fclose($stream); + } + + public function testAppendThrows() + { + $this->createErrorHandler($errors); + + $stream = $this->createStream(); + $this->createErrorHandler($errors); + + StreamFilter\append($stream, function ($chunk) { + throw new \DomainException($chunk); + }); + + fwrite($stream, 'test'); + + $this->removeErrorHandler(); + $this->assertCount(1, $errors); + $this->assertContains('test', $errors[0]); + } + + public function testAppendThrowsDuringEnd() + { + $stream = $this->createStream(); + $this->createErrorHandler($errors); + + StreamFilter\append($stream, function ($chunk = null) { + if ($chunk === null) { + throw new \DomainException('end'); + } + return $chunk; + }); + + fclose($stream); + + $this->removeErrorHandler(); + + // We can only assert we're not seeing an exception here… + // * php 5.3-5.6 sees one error here + // * php 7 does not see any error here + // * hhvm sees the same error twice + // + // If you're curious: + // + // var_dump($errors); + // $this->assertCount(1, $errors); + // $this->assertContains('end', $errors[0]); + } + + public function testAppendThrowsShouldTriggerEnd() + { + $stream = $this->createStream(); + $this->createErrorHandler($errors); + + $ended = false; + StreamFilter\append($stream, function ($chunk = null) use (&$ended) { + if ($chunk === null) { + $ended = true; + return ''; + } + throw new \DomainException($chunk); + }); + + $this->assertEquals(false, $ended); + fwrite($stream, 'test'); + $this->assertEquals(true, $ended); + + $this->removeErrorHandler(); + $this->assertCount(1, $errors); + $this->assertContains('test', $errors[0]); + } + + public function testAppendThrowsShouldTriggerEndButIgnoreExceptionDuringEnd() + { + //$this->markTestIncomplete(); + $stream = $this->createStream(); + $this->createErrorHandler($errors); + + StreamFilter\append($stream, function ($chunk = null) { + if ($chunk === null) { + $chunk = 'end'; + //return ''; + } + throw new \DomainException($chunk); + }); + + fwrite($stream, 'test'); + + $this->removeErrorHandler(); + $this->assertCount(1, $errors); + $this->assertContains('test', $errors[0]); + } + + /** + * @expectedException RuntimeException + */ + public function testAppendInvalidStreamIsRuntimeError() + { + if (defined('HHVM_VERSION')) $this->markTestSkipped('Not supported on HHVM (does not reject invalid stream)'); + StreamFilter\append(false, function () { }); + } + + /** + * @expectedException RuntimeException + */ + public function testPrependInvalidStreamIsRuntimeError() + { + if (defined('HHVM_VERSION')) $this->markTestSkipped('Not supported on HHVM (does not reject invalid stream)'); + StreamFilter\prepend(false, function () { }); + } + + /** + * @expectedException RuntimeException + */ + public function testRemoveInvalidFilterIsRuntimeError() + { + if (defined('HHVM_VERSION')) $this->markTestSkipped('Not supported on HHVM (does not reject invalid filters)'); + StreamFilter\remove(false); + } + + /** + * @expectedException InvalidArgumentException + */ + public function testInvalidCallbackIsInvalidArgument() + { + $stream = $this->createStream(); + + StreamFilter\append($stream, 'a-b-c'); + } + + private function createStream() + { + return fopen('php://memory', 'r+'); + } + + private function createErrorHandler(&$errors) + { + $errors = array(); + set_error_handler(function ($_, $message) use (&$errors) { + $errors []= $message; + }); + } + + private function removeErrorHandler() + { + restore_error_handler(); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/tests/FunTest.php b/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/tests/FunTest.php new file mode 100644 index 0000000..a52668c --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/tests/FunTest.php @@ -0,0 +1,44 @@ +<?php + +use Clue\StreamFilter as Filter; + +class FunTest extends PHPUnit_Framework_TestCase +{ + public function testFunInRot13() + { + $rot = Filter\fun('string.rot13'); + + $this->assertEquals('grfg', $rot('test')); + $this->assertEquals('test', $rot($rot('test'))); + $this->assertEquals(null, $rot()); + } + + public function testFunInQuotedPrintable() + { + $encode = Filter\fun('convert.quoted-printable-encode'); + $decode = Filter\fun('convert.quoted-printable-decode'); + + $this->assertEquals('t=C3=A4st', $encode('täst')); + $this->assertEquals('täst', $decode($encode('täst'))); + $this->assertEquals(null, $encode()); + } + + /** + * @expectedException RuntimeException + */ + public function testFunWriteAfterCloseRot13() + { + $rot = Filter\fun('string.rot13'); + + $this->assertEquals(null, $rot()); + $rot('test'); + } + + /** + * @expectedException RuntimeException + */ + public function testFunInvalid() + { + Filter\fun('unknown'); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/tests/FunZlibTest.php b/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/tests/FunZlibTest.php new file mode 100644 index 0000000..752c8a2 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/clue/stream-filter/tests/FunZlibTest.php @@ -0,0 +1,79 @@ +<?php + +use Clue\StreamFilter; + +class BuiltInZlibTest extends PHPUnit_Framework_TestCase +{ + public function testFunZlibDeflateHelloWorld() + { + $deflate = StreamFilter\fun('zlib.deflate'); + + $data = $deflate('hello') . $deflate(' ') . $deflate('world') . $deflate(); + + $this->assertEquals(gzdeflate('hello world'), $data); + } + + public function testFunZlibDeflateEmpty() + { + if (PHP_VERSION >= 7) $this->markTestSkipped('Not supported on PHP7 (empty string does not invoke filter)'); + + $deflate = StreamFilter\fun('zlib.deflate'); + + //$data = gzdeflate(''); + $data = $deflate(); + + $this->assertEquals("\x03\x00", $data); + } + + public function testFunZlibDeflateBig() + { + $deflate = StreamFilter\fun('zlib.deflate'); + + $n = 1000; + $expected = str_repeat('hello', $n); + + $bytes = ''; + for ($i = 0; $i < $n; ++$i) { + $bytes .= $deflate('hello'); + } + $bytes .= $deflate(); + + $this->assertEquals($expected, gzinflate($bytes)); + } + + public function testFunZlibInflateHelloWorld() + { + $inflate = StreamFilter\fun('zlib.inflate'); + + $data = $inflate(gzdeflate('hello world')) . $inflate(); + + $this->assertEquals('hello world', $data); + } + + public function testFunZlibInflateEmpty() + { + $inflate = StreamFilter\fun('zlib.inflate'); + + $data = $inflate("\x03\x00") . $inflate(); + + $this->assertEquals('', $data); + } + + public function testFunZlibInflateBig() + { + if (defined('HHVM_VERSION')) $this->markTestSkipped('Not supported on HHVM (final chunk will not be emitted)'); + + $inflate = StreamFilter\fun('zlib.inflate'); + + $expected = str_repeat('hello', 10); + $bytes = gzdeflate($expected); + + $ret = ''; + foreach (str_split($bytes, 2) as $chunk) { + $ret .= $inflate($chunk); + } + $ret .= $inflate(); + + $this->assertEquals($expected, $ret); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/composer/ClassLoader.php b/Postman/Postman-Mail/mailgun/vendor/composer/ClassLoader.php new file mode 100644 index 0000000..ff6ecfb --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/composer/ClassLoader.php @@ -0,0 +1,413 @@ +<?php + +/* + * This file is part of Composer. + * + * (c) Nils Adermann <naderman@naderman.de> + * Jordi Boggiano <j.boggiano@seld.be> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier <fabien@symfony.com> + * @author Jordi Boggiano <j.boggiano@seld.be> + * @see http://www.php-fig.org/psr/psr-0/ + * @see http://www.php-fig.org/psr/psr-4/ + */ +class ClassLoader +{ + // PSR-4 + private $prefixLengthsPsr4 = array(); + private $prefixDirsPsr4 = array(); + private $fallbackDirsPsr4 = array(); + + // PSR-0 + private $prefixesPsr0 = array(); + private $fallbackDirsPsr0 = array(); + + private $useIncludePath = false; + private $classMap = array(); + + private $classMapAuthoritative = false; + + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', $this->prefixesPsr0); + } + + return array(); + } + + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param array $classMap Class to filename map + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + */ + public function add($prefix, $paths, $prepend = false) + { + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + (array) $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + (array) $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = (array) $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + (array) $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + (array) $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + (array) $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + (array) $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 base directories + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + } + + /** + * Unregisters this instance as an autoloader. + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return bool|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + includeFile($file); + + return true; + } + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731 + if ('\\' == $class[0]) { + $class = substr($class, 1); + } + + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative) { + return false; + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if ($file === null && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if ($file === null) { + // Remember that this class does not exist. + return $this->classMap[$class] = false; + } + + return $file; + } + + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { + if (0 === strpos($class, $prefix)) { + foreach ($this->prefixDirsPsr4[$prefix] as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + } +} + +/** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + */ +function includeFile($file) +{ + include $file; +} diff --git a/Postman/Postman-Mail/mailgun/vendor/composer/LICENSE b/Postman/Postman-Mail/mailgun/vendor/composer/LICENSE new file mode 100644 index 0000000..ee274f1 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/composer/LICENSE @@ -0,0 +1,433 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: Composer +Upstream-Contact: Jordi Boggiano <j.boggiano@seld.be> +Source: https://github.com/composer/composer + +Files: * +Copyright: 2016, Nils Adermann <naderman@naderman.de> + 2016, Jordi Boggiano <j.boggiano@seld.be> +License: Expat + +Files: res/cacert.pem +Copyright: 2015, Mozilla Foundation +License: MPL-2.0 + +Files: src/Composer/Util/RemoteFilesystem.php + src/Composer/Util/TlsHelper.php +Copyright: 2016, Nils Adermann <naderman@naderman.de> + 2016, Jordi Boggiano <j.boggiano@seld.be> + 2013, Evan Coury <me@evancoury.com> +License: Expat and BSD-2-Clause + +License: BSD-2-Clause + Redistribution and use in source and binary forms, with or without modification, + are permitted provided that the following conditions are met: + . + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + . + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + . + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License: Expat + 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. + +License: MPL-2.0 + 1. Definitions + -------------- + . + 1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + . + 1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + . + 1.3. "Contribution" + means Covered Software of a particular Contributor. + . + 1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + . + 1.5. "Incompatible With Secondary Licenses" + means + . + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + . + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + . + 1.6. "Executable Form" + means any form of the work other than Source Code Form. + . + 1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + . + 1.8. "License" + means this document. + . + 1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + . + 1.10. "Modifications" + means any of the following: + . + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + . + (b) any new file in Source Code Form that contains any Covered + Software. + . + 1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + . + 1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + . + 1.13. "Source Code Form" + means the form of the work preferred for making modifications. + . + 1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + . + 2. License Grants and Conditions + -------------------------------- + . + 2.1. Grants + . + Each Contributor hereby grants You a world-wide, royalty-free, + non-exclusive license: + . + (a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + . + (b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + . + 2.2. Effective Date + . + The licenses granted in Section 2.1 with respect to any Contribution + become effective for each Contribution on the date the Contributor first + distributes such Contribution. + . + 2.3. Limitations on Grant Scope + . + The licenses granted in this Section 2 are the only rights granted under + this License. No additional rights or licenses will be implied from the + distribution or licensing of Covered Software under this License. + Notwithstanding Section 2.1(b) above, no patent license is granted by a + Contributor: + . + (a) for any code that a Contributor has removed from Covered Software; + or + . + (b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + . + (c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + . + This License does not grant any rights in the trademarks, service marks, + or logos of any Contributor (except as may be necessary to comply with + the notice requirements in Section 3.4). + . + 2.4. Subsequent Licenses + . + No Contributor makes additional grants as a result of Your choice to + distribute the Covered Software under a subsequent version of this + License (see Section 10.2) or under the terms of a Secondary License (if + permitted under the terms of Section 3.3). + . + 2.5. Representation + . + Each Contributor represents that the Contributor believes its + Contributions are its original creation(s) or it has sufficient rights + to grant the rights to its Contributions conveyed by this License. + . + 2.6. Fair Use + . + This License is not intended to limit any rights You have under + applicable copyright doctrines of fair use, fair dealing, or other + equivalents. + . + 2.7. Conditions + . + Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted + in Section 2.1. + . + 3. Responsibilities + ------------------- + . + 3.1. Distribution of Source Form + . + All distribution of Covered Software in Source Code Form, including any + Modifications that You create or to which You contribute, must be under + the terms of this License. You must inform recipients that the Source + Code Form of the Covered Software is governed by the terms of this + License, and how they can obtain a copy of this License. You may not + attempt to alter or restrict the recipients' rights in the Source Code + Form. + . + 3.2. Distribution of Executable Form + . + If You distribute Covered Software in Executable Form then: + . + (a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + . + (b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + . + 3.3. Distribution of a Larger Work + . + You may create and distribute a Larger Work under terms of Your choice, + provided that You also comply with the requirements of this License for + the Covered Software. If the Larger Work is a combination of Covered + Software with a work governed by one or more Secondary Licenses, and the + Covered Software is not Incompatible With Secondary Licenses, this + License permits You to additionally distribute such Covered Software + under the terms of such Secondary License(s), so that the recipient of + the Larger Work may, at their option, further distribute the Covered + Software under the terms of either this License or such Secondary + License(s). + . + 3.4. Notices + . + You may not remove or alter the substance of any license notices + (including copyright notices, patent notices, disclaimers of warranty, + or limitations of liability) contained within the Source Code Form of + the Covered Software, except that You may alter any license notices to + the extent required to remedy known factual inaccuracies. + . + 3.5. Application of Additional Terms + . + You may choose to offer, and to charge a fee for, warranty, support, + indemnity or liability obligations to one or more recipients of Covered + Software. However, You may do so only on Your own behalf, and not on + behalf of any Contributor. You must make it absolutely clear that any + such warranty, support, indemnity, or liability obligation is offered by + You alone, and You hereby agree to indemnify every Contributor for any + liability incurred by such Contributor as a result of warranty, support, + indemnity or liability terms You offer. You may include additional + disclaimers of warranty and limitations of liability specific to any + jurisdiction. + . + 4. Inability to Comply Due to Statute or Regulation + --------------------------------------------------- + . + If it is impossible for You to comply with any of the terms of this + License with respect to some or all of the Covered Software due to + statute, judicial order, or regulation then You must: (a) comply with + the terms of this License to the maximum extent possible; and (b) + describe the limitations and the code they affect. Such description must + be placed in a text file included with all distributions of the Covered + Software under this License. Except to the extent prohibited by statute + or regulation, such description must be sufficiently detailed for a + recipient of ordinary skill to be able to understand it. + . + 5. Termination + -------------- + . + 5.1. The rights granted under this License will terminate automatically + if You fail to comply with any of its terms. However, if You become + compliant, then the rights granted under this License from a particular + Contributor are reinstated (a) provisionally, unless and until such + Contributor explicitly and finally terminates Your grants, and (b) on an + ongoing basis, if such Contributor fails to notify You of the + non-compliance by some reasonable means prior to 60 days after You have + come back into compliance. Moreover, Your grants from a particular + Contributor are reinstated on an ongoing basis if such Contributor + notifies You of the non-compliance by some reasonable means, this is the + first time You have received notice of non-compliance with this License + from such Contributor, and You become compliant prior to 30 days after + Your receipt of the notice. + . + 5.2. If You initiate litigation against any entity by asserting a patent + infringement claim (excluding declaratory judgment actions, + counter-claims, and cross-claims) alleging that a Contributor Version + directly or indirectly infringes any patent, then the rights granted to + You by any and all Contributors for the Covered Software under Section + 2.1 of this License shall terminate. + . + 5.3. In the event of termination under Sections 5.1 or 5.2 above, all + end user license agreements (excluding distributors and resellers) which + have been validly granted by You or Your distributors under this License + prior to termination shall survive termination. + . + ************************************************************************ + * * + * 6. Disclaimer of Warranty * + * ------------------------- * + * * + * Covered Software is provided under this License on an "as is" * + * basis, without warranty of any kind, either expressed, implied, or * + * statutory, including, without limitation, warranties that the * + * Covered Software is free of defects, merchantable, fit for a * + * particular purpose or non-infringing. The entire risk as to the * + * quality and performance of the Covered Software is with You. * + * Should any Covered Software prove defective in any respect, You * + * (not any Contributor) assume the cost of any necessary servicing, * + * repair, or correction. This disclaimer of warranty constitutes an * + * essential part of this License. No use of any Covered Software is * + * authorized under this License except under this disclaimer. * + * * + ************************************************************************ + . + ************************************************************************ + * * + * 7. Limitation of Liability * + * -------------------------- * + * * + * Under no circumstances and under no legal theory, whether tort * + * (including negligence), contract, or otherwise, shall any * + * Contributor, or anyone who distributes Covered Software as * + * permitted above, be liable to You for any direct, indirect, * + * special, incidental, or consequential damages of any character * + * including, without limitation, damages for lost profits, loss of * + * goodwill, work stoppage, computer failure or malfunction, or any * + * and all other commercial damages or losses, even if such party * + * shall have been informed of the possibility of such damages. This * + * limitation of liability shall not apply to liability for death or * + * personal injury resulting from such party's negligence to the * + * extent applicable law prohibits such limitation. Some * + * jurisdictions do not allow the exclusion or limitation of * + * incidental or consequential damages, so this exclusion and * + * limitation may not apply to You. * + * * + ************************************************************************ + . + 8. Litigation + ------------- + . + Any litigation relating to this License may be brought only in the + courts of a jurisdiction where the defendant maintains its principal + place of business and such litigation shall be governed by laws of that + jurisdiction, without reference to its conflict-of-law provisions. + Nothing in this Section shall prevent a party's ability to bring + cross-claims or counter-claims. + . + 9. Miscellaneous + ---------------- + . + This License represents the complete agreement concerning the subject + matter hereof. If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the extent + necessary to make it enforceable. Any law or regulation which provides + that the language of a contract shall be construed against the drafter + shall not be used to construe this License against a Contributor. + . + 10. Versions of the License + --------------------------- + . + 10.1. New Versions + . + Mozilla Foundation is the license steward. Except as provided in Section + 10.3, no one other than the license steward has the right to modify or + publish new versions of this License. Each version will be given a + distinguishing version number. + . + 10.2. Effect of New Versions + . + You may distribute the Covered Software under the terms of the version + of the License under which You originally received the Covered Software, + or under the terms of any subsequent version published by the license + steward. + . + 10.3. Modified Versions + . + If you create software not governed by this License, and you want to + create a new license for such software, you may create and use a + modified version of this License if you rename the license and remove + any references to the name of the license steward (except to note that + such modified license differs from this License). + . + 10.4. Distributing Source Code Form that is Incompatible With Secondary + Licenses + . + If You choose to distribute Source Code Form that is Incompatible With + Secondary Licenses under the terms of this version of the License, the + notice described in Exhibit B of this License must be attached. + . + Exhibit A - Source Code Form License Notice + ------------------------------------------- + . + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + . + If it is not possible or desirable to put the notice in a particular + file, then You may include the notice in a location (such as a LICENSE + file in a relevant directory) where a recipient would be likely to look + for such a notice. + . + You may add additional accurate notices of copyright ownership. + . + Exhibit B - "Incompatible With Secondary Licenses" Notice + --------------------------------------------------------- + . + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. diff --git a/Postman/Postman-Mail/mailgun/vendor/composer/autoload_classmap.php b/Postman/Postman-Mail/mailgun/vendor/composer/autoload_classmap.php new file mode 100644 index 0000000..7a91153 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/composer/autoload_classmap.php @@ -0,0 +1,9 @@ +<?php + +// autoload_classmap.php @generated by Composer + +$vendorDir = dirname(dirname(__FILE__)); +$baseDir = dirname($vendorDir); + +return array( +); diff --git a/Postman/Postman-Mail/mailgun/vendor/composer/autoload_files.php b/Postman/Postman-Mail/mailgun/vendor/composer/autoload_files.php new file mode 100644 index 0000000..7069f16 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/composer/autoload_files.php @@ -0,0 +1,12 @@ +<?php + +// autoload_files.php @generated by Composer + +$vendorDir = dirname(dirname(__FILE__)); +$baseDir = dirname($vendorDir); + +return array( + 'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php', + 'ddc0a4d7e61c0286f0f8593b1903e894' => $vendorDir . '/clue/stream-filter/src/functions.php', + '8cff32064859f4559445b89279f3199c' => $vendorDir . '/php-http/message/src/filters.php', +); diff --git a/Postman/Postman-Mail/mailgun/vendor/composer/autoload_namespaces.php b/Postman/Postman-Mail/mailgun/vendor/composer/autoload_namespaces.php new file mode 100644 index 0000000..a3af1a0 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/composer/autoload_namespaces.php @@ -0,0 +1,10 @@ +<?php + +// autoload_namespaces.php @generated by Composer + +$vendorDir = dirname(dirname(__FILE__)); +$baseDir = dirname($vendorDir); + +return array( + 'Mailgun' => array($vendorDir . '/mailgun/mailgun-php/src'), +); diff --git a/Postman/Postman-Mail/mailgun/vendor/composer/autoload_psr4.php b/Postman/Postman-Mail/mailgun/vendor/composer/autoload_psr4.php new file mode 100644 index 0000000..f81dce4 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/composer/autoload_psr4.php @@ -0,0 +1,21 @@ +<?php + +// autoload_psr4.php @generated by Composer + +$vendorDir = dirname(dirname(__FILE__)); +$baseDir = dirname($vendorDir); + +return array( + 'Webmozart\\Assert\\' => array($vendorDir . '/webmozart/assert/src'), + 'Symfony\\Component\\OptionsResolver\\' => array($vendorDir . '/symfony/options-resolver'), + 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'), + 'Http\\Promise\\' => array($vendorDir . '/php-http/promise/src'), + 'Http\\Message\\MultipartStream\\' => array($vendorDir . '/php-http/multipart-stream-builder/src'), + 'Http\\Message\\' => array($vendorDir . '/php-http/message-factory/src', $vendorDir . '/php-http/message/src'), + 'Http\\Discovery\\' => array($vendorDir . '/php-http/discovery/src'), + 'Http\\Client\\Curl\\' => array($vendorDir . '/php-http/curl-client/src'), + 'Http\\Client\\Common\\' => array($vendorDir . '/php-http/client-common/src'), + 'Http\\Client\\' => array($vendorDir . '/php-http/httplug/src'), + 'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'), + 'Clue\\StreamFilter\\' => array($vendorDir . '/clue/stream-filter/src'), +); diff --git a/Postman/Postman-Mail/mailgun/vendor/composer/autoload_real.php b/Postman/Postman-Mail/mailgun/vendor/composer/autoload_real.php new file mode 100644 index 0000000..2e43f61 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/composer/autoload_real.php @@ -0,0 +1,59 @@ +<?php + +// autoload_real.php @generated by Composer + +class ComposerAutoloaderInit2e493976577e1ff95afbbd5ca63b2ef1 +{ + private static $loader; + + public static function loadClassLoader($class) + { + if ('Composer\Autoload\ClassLoader' === $class) { + require __DIR__ . '/ClassLoader.php'; + } + } + + public static function getLoader() + { + if (null !== self::$loader) { + return self::$loader; + } + + spl_autoload_register(array('ComposerAutoloaderInit2e493976577e1ff95afbbd5ca63b2ef1', 'loadClassLoader'), true, true); + self::$loader = $loader = new \Composer\Autoload\ClassLoader(); + spl_autoload_unregister(array('ComposerAutoloaderInit2e493976577e1ff95afbbd5ca63b2ef1', 'loadClassLoader')); + + $map = require __DIR__ . '/autoload_namespaces.php'; + foreach ($map as $namespace => $path) { + $loader->set($namespace, $path); + } + + $map = require __DIR__ . '/autoload_psr4.php'; + foreach ($map as $namespace => $path) { + $loader->setPsr4($namespace, $path); + } + + $classMap = require __DIR__ . '/autoload_classmap.php'; + if ($classMap) { + $loader->addClassMap($classMap); + } + + $loader->register(true); + + $includeFiles = require __DIR__ . '/autoload_files.php'; + foreach ($includeFiles as $fileIdentifier => $file) { + composerRequire2e493976577e1ff95afbbd5ca63b2ef1($fileIdentifier, $file); + } + + return $loader; + } +} + +function composerRequire2e493976577e1ff95afbbd5ca63b2ef1($fileIdentifier, $file) +{ + if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { + require $file; + + $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/composer/installed.json b/Postman/Postman-Mail/mailgun/vendor/composer/installed.json new file mode 100644 index 0000000..aee855c --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/composer/installed.json @@ -0,0 +1,812 @@ +[ + { + "name": "php-http/discovery", + "version": "1.3.0", + "version_normalized": "1.3.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/discovery.git", + "reference": "7b50ab4d6c9fdaa1ed53ae310c955900af6e3372" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/discovery/zipball/7b50ab4d6c9fdaa1ed53ae310c955900af6e3372", + "reference": "7b50ab4d6c9fdaa1ed53ae310c955900af6e3372", + "shasum": "" + }, + "require": { + "php": "^5.5 || ^7.0" + }, + "require-dev": { + "henrikbjorn/phpspec-code-coverage": "^2.0.2", + "php-http/httplug": "^1.0", + "php-http/message-factory": "^1.0", + "phpspec/phpspec": "^2.4", + "puli/composer-plugin": "1.0.0-beta10" + }, + "suggest": { + "php-http/message": "Allow to use Guzzle, Diactoros or Slim Framework factories", + "puli/composer-plugin": "Sets up Puli which is recommended for Discovery to work. Check http://docs.php-http.org/en/latest/discovery.html for more details." + }, + "time": "2017-08-03 10:12:53", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Http\\Discovery\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Finds installed HTTPlug implementations and PSR-7 message factories", + "homepage": "http://php-http.org", + "keywords": [ + "adapter", + "client", + "discovery", + "factory", + "http", + "message", + "psr7" + ] + }, + { + "name": "clue/stream-filter", + "version": "v1.4.0", + "version_normalized": "1.4.0.0", + "source": { + "type": "git", + "url": "https://github.com/clue/php-stream-filter.git", + "reference": "d80fdee9b3a7e0d16fc330a22f41f3ad0eeb09d0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/clue/php-stream-filter/zipball/d80fdee9b3a7e0d16fc330a22f41f3ad0eeb09d0", + "reference": "d80fdee9b3a7e0d16fc330a22f41f3ad0eeb09d0", + "shasum": "" + }, + "require": { + "php": ">=5.3" + }, + "require-dev": { + "phpunit/phpunit": "^5.0 || ^4.8" + }, + "time": "2017-08-18 09:54:01", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Clue\\StreamFilter\\": "src/" + }, + "files": [ + "src/functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@lueck.tv" + } + ], + "description": "A simple and modern approach to stream filtering in PHP", + "homepage": "https://github.com/clue/php-stream-filter", + "keywords": [ + "bucket brigade", + "callback", + "filter", + "php_user_filter", + "stream", + "stream_filter_append", + "stream_filter_register" + ] + }, + { + "name": "psr/http-message", + "version": "1.0.1", + "version_normalized": "1.0.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "time": "2016-08-06 14:39:51", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ] + }, + { + "name": "php-http/message-factory", + "version": "v1.0.2", + "version_normalized": "1.0.2.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/message-factory.git", + "reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/message-factory/zipball/a478cb11f66a6ac48d8954216cfed9aa06a501a1", + "reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "psr/http-message": "^1.0" + }, + "time": "2015-12-19 14:08:53", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Factory interfaces for PSR-7 HTTP Message", + "homepage": "http://php-http.org", + "keywords": [ + "factory", + "http", + "message", + "stream", + "uri" + ] + }, + { + "name": "php-http/message", + "version": "1.6.0", + "version_normalized": "1.6.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/message.git", + "reference": "2edd63bae5f52f79363c5f18904b05ce3a4b7253" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/message/zipball/2edd63bae5f52f79363c5f18904b05ce3a4b7253", + "reference": "2edd63bae5f52f79363c5f18904b05ce3a4b7253", + "shasum": "" + }, + "require": { + "clue/stream-filter": "^1.3", + "php": ">=5.4", + "php-http/message-factory": "^1.0.2", + "psr/http-message": "^1.0" + }, + "provide": { + "php-http/message-factory-implementation": "1.0" + }, + "require-dev": { + "akeneo/phpspec-skip-example-extension": "^1.0", + "coduo/phpspec-data-provider-extension": "^1.0", + "ext-zlib": "*", + "guzzlehttp/psr7": "^1.0", + "henrikbjorn/phpspec-code-coverage": "^1.0", + "phpspec/phpspec": "^2.4", + "slim/slim": "^3.0", + "zendframework/zend-diactoros": "^1.0" + }, + "suggest": { + "ext-zlib": "Used with compressor/decompressor streams", + "guzzlehttp/psr7": "Used with Guzzle PSR-7 Factories", + "slim/slim": "Used with Slim Framework PSR-7 implementation", + "zendframework/zend-diactoros": "Used with Diactoros Factories" + }, + "time": "2017-07-05 06:40:53", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.6-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Http\\Message\\": "src/" + }, + "files": [ + "src/filters.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "HTTP Message related tools", + "homepage": "http://php-http.org", + "keywords": [ + "http", + "message", + "psr-7" + ] + }, + { + "name": "php-http/promise", + "version": "v1.0.0", + "version_normalized": "1.0.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/promise.git", + "reference": "dc494cdc9d7160b9a09bd5573272195242ce7980" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/promise/zipball/dc494cdc9d7160b9a09bd5573272195242ce7980", + "reference": "dc494cdc9d7160b9a09bd5573272195242ce7980", + "shasum": "" + }, + "require-dev": { + "henrikbjorn/phpspec-code-coverage": "^1.0", + "phpspec/phpspec": "^2.4" + }, + "time": "2016-01-26 13:27:02", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Http\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + }, + { + "name": "Joel Wurtz", + "email": "joel.wurtz@gmail.com" + } + ], + "description": "Promise used for asynchronous HTTP requests", + "homepage": "http://httplug.io", + "keywords": [ + "promise" + ] + }, + { + "name": "php-http/httplug", + "version": "v1.1.0", + "version_normalized": "1.1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/httplug.git", + "reference": "1c6381726c18579c4ca2ef1ec1498fdae8bdf018" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/httplug/zipball/1c6381726c18579c4ca2ef1ec1498fdae8bdf018", + "reference": "1c6381726c18579c4ca2ef1ec1498fdae8bdf018", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "php-http/promise": "^1.0", + "psr/http-message": "^1.0" + }, + "require-dev": { + "henrikbjorn/phpspec-code-coverage": "^1.0", + "phpspec/phpspec": "^2.4" + }, + "time": "2016-08-31 08:30:17", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Eric GELOEN", + "email": "geloen.eric@gmail.com" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "HTTPlug, the HTTP client abstraction for PHP", + "homepage": "http://httplug.io", + "keywords": [ + "client", + "http" + ] + }, + { + "name": "php-http/curl-client", + "version": "v1.7.0", + "version_normalized": "1.7.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/curl-client.git", + "reference": "0972ad0d7d37032a52077a5cbe27cf370f2007d8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/curl-client/zipball/0972ad0d7d37032a52077a5cbe27cf370f2007d8", + "reference": "0972ad0d7d37032a52077a5cbe27cf370f2007d8", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "php": "^5.5 || ^7.0", + "php-http/discovery": "^1.0", + "php-http/httplug": "^1.0", + "php-http/message": "^1.2", + "php-http/message-factory": "^1.0.2" + }, + "provide": { + "php-http/async-client-implementation": "1.0", + "php-http/client-implementation": "1.0" + }, + "require-dev": { + "guzzlehttp/psr7": "^1.0", + "php-http/client-integration-tests": "^0.5.1", + "phpunit/phpunit": "^4.8.27", + "zendframework/zend-diactoros": "^1.0" + }, + "time": "2017-02-09 15:18:33", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Http\\Client\\Curl\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Михаил Красильников", + "email": "m.krasilnikov@yandex.ru" + } + ], + "description": "cURL client for PHP-HTTP", + "homepage": "http://php-http.org", + "keywords": [ + "curl", + "http" + ] + }, + { + "name": "webmozart/assert", + "version": "1.2.0", + "version_normalized": "1.2.0.0", + "source": { + "type": "git", + "url": "https://github.com/webmozart/assert.git", + "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozart/assert/zipball/2db61e59ff05fe5126d152bd0655c9ea113e550f", + "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.6", + "sebastian/version": "^1.0.1" + }, + "time": "2016-11-23 20:04:58", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ] + }, + { + "name": "symfony/options-resolver", + "version": "v3.4.1", + "version_normalized": "3.4.1.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/options-resolver.git", + "reference": "08748edfe6982f4d878cc42b8325b19a276fb1cf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/08748edfe6982f4d878cc42b8325b19a276fb1cf", + "reference": "08748edfe6982f4d878cc42b8325b19a276fb1cf", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8" + }, + "time": "2017-11-05 16:10:10", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "installation-source": "dist", + "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" + ] + }, + { + "name": "php-http/client-common", + "version": "1.7.0", + "version_normalized": "1.7.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/client-common.git", + "reference": "9accb4a082eb06403747c0ffd444112eda41a0fd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/client-common/zipball/9accb4a082eb06403747c0ffd444112eda41a0fd", + "reference": "9accb4a082eb06403747c0ffd444112eda41a0fd", + "shasum": "" + }, + "require": { + "php": "^5.4 || ^7.0", + "php-http/httplug": "^1.1", + "php-http/message": "^1.6", + "php-http/message-factory": "^1.0", + "symfony/options-resolver": "^2.6 || ^3.0 || ^4.0" + }, + "require-dev": { + "guzzlehttp/psr7": "^1.4", + "phpspec/phpspec": "^2.5 || ^3.4 || ^4.2" + }, + "suggest": { + "php-http/cache-plugin": "PSR-6 Cache plugin", + "php-http/logger-plugin": "PSR-3 Logger plugin", + "php-http/stopwatch-plugin": "Symfony Stopwatch plugin" + }, + "time": "2017-11-30 11:06:59", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.7-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Http\\Client\\Common\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Common HTTP Client implementations and tools for HTTPlug", + "homepage": "http://httplug.io", + "keywords": [ + "client", + "common", + "http", + "httplug" + ] + }, + { + "name": "php-http/multipart-stream-builder", + "version": "1.0.0", + "version_normalized": "1.0.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/multipart-stream-builder.git", + "reference": "1fa3c623fc813a43b39494b2a1612174e36e0fb0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/multipart-stream-builder/zipball/1fa3c623fc813a43b39494b2a1612174e36e0fb0", + "reference": "1fa3c623fc813a43b39494b2a1612174e36e0fb0", + "shasum": "" + }, + "require": { + "php": "^5.5 || ^7.0", + "php-http/discovery": "^1.0", + "php-http/message-factory": "^1.0.2", + "psr/http-message": "^1.0" + }, + "require-dev": { + "php-http/message": "^1.5", + "phpunit/phpunit": "^4.8 || ^5.4", + "zendframework/zend-diactoros": "^1.3.5" + }, + "time": "2017-05-21 17:45:25", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.3-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Http\\Message\\MultipartStream\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com" + } + ], + "description": "A builder class that help you create a multipart stream", + "homepage": "http://php-http.org", + "keywords": [ + "factory", + "http", + "message", + "multipart stream", + "stream" + ] + }, + { + "name": "mailgun/mailgun-php", + "version": "2.3.4", + "version_normalized": "2.3.4.0", + "source": { + "type": "git", + "url": "https://github.com/mailgun/mailgun-php.git", + "reference": "f58c5914aefa16fa6ed2b5cf9ee84d40cbda1b3a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mailgun/mailgun-php/zipball/f58c5914aefa16fa6ed2b5cf9ee84d40cbda1b3a", + "reference": "f58c5914aefa16fa6ed2b5cf9ee84d40cbda1b3a", + "shasum": "" + }, + "require": { + "php": "^5.5|^7.0", + "php-http/client-common": "^1.1", + "php-http/discovery": "^1.0", + "php-http/httplug": "^1.0", + "php-http/message": "^1.0", + "php-http/multipart-stream-builder": "^1.0", + "webmozart/assert": "^1.2" + }, + "require-dev": { + "guzzlehttp/psr7": "^1.4", + "php-http/guzzle6-adapter": "^1.0", + "phpunit/phpunit": "~4.8" + }, + "time": "2017-06-20 19:56:09", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "Mailgun": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Travis Swientek", + "email": "travis@mailgunhq.com" + } + ], + "description": "The Mailgun SDK provides methods for all API functions." + }, + { + "name": "guzzlehttp/psr7", + "version": "1.4.2", + "version_normalized": "1.4.2.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c", + "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "psr/http-message": "~1.0" + }, + "provide": { + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "time": "2017-03-20 17:10:46", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Schultze", + "homepage": "https://github.com/Tobion" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "request", + "response", + "stream", + "uri", + "url" + ] + } +] diff --git a/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/CHANGELOG.md b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/CHANGELOG.md new file mode 100644 index 0000000..5c252b3 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/CHANGELOG.md @@ -0,0 +1,110 @@ +# CHANGELOG + +## 1.4.2 - 2017-03-20 + +* Reverted BC break to `Uri::resolve` and `Uri::removeDotSegments` by removing + calls to `trigger_error` when deprecated methods are invoked. + +## 1.4.1 - 2017-02-27 + +* Reverted BC break by reintroducing behavior to automagically fix a URI with a + relative path and an authority by adding a leading slash to the path. It's only + deprecated now. +* Added triggering of silenced deprecation warnings. + +## 1.4.0 - 2017-02-21 + +* Fix `Stream::read` when length parameter <= 0. +* `copy_to_stream` reads bytes in chunks instead of `maxLen` into memory. +* Fix `ServerRequest::getUriFromGlobals` when `Host` header contains port. +* Ensure `ServerRequest::getUriFromGlobals` returns a URI in absolute form. +* Allow `parse_response` to parse a response without delimiting space and reason. +* Ensure each URI modification results in a valid URI according to PSR-7 discussions. + Invalid modifications will throw an exception instead of returning a wrong URI or + doing some magic. + - `(new Uri)->withPath('foo')->withHost('example.com')` will throw an exception + because the path of a URI with an authority must start with a slash "/" or be empty + - `(new Uri())->withScheme('http')` will return `'http://localhost'` +* Fix compatibility of URIs with `file` scheme and empty host. +* Added common URI utility methods based on RFC 3986 (see documentation in the readme): + - `Uri::isDefaultPort` + - `Uri::isAbsolute` + - `Uri::isNetworkPathReference` + - `Uri::isAbsolutePathReference` + - `Uri::isRelativePathReference` + - `Uri::isSameDocumentReference` + - `Uri::composeComponents` + - `UriNormalizer::normalize` + - `UriNormalizer::isEquivalent` + - `UriResolver::relativize` +* Deprecated `Uri::resolve` in favor of `UriResolver::resolve` +* Deprecated `Uri::removeDotSegments` in favor of `UriResolver::removeDotSegments` + +## 1.3.1 - 2016-06-25 + +* Fix `Uri::__toString` for network path references, e.g. `//example.org`. +* Fix missing lowercase normalization for host. +* Fix handling of URI components in case they are `'0'` in a lot of places, + e.g. as a user info password. +* Fix `Uri::withAddedHeader` to correctly merge headers with different case. +* Fix trimming of header values in `Uri::withAddedHeader`. Header values may + be surrounded by whitespace which should be ignored according to RFC 7230 + Section 3.2.4. This does not apply to header names. +* Fix `Uri::withAddedHeader` with an array of header values. +* Fix `Uri::resolve` when base path has no slash and handling of fragment. +* Fix handling of encoding in `Uri::with(out)QueryValue` so one can pass the + key/value both in encoded as well as decoded form to those methods. This is + consistent with withPath, withQuery etc. +* Fix `ServerRequest::withoutAttribute` when attribute value is null. + +## 1.3.0 - 2016-04-13 + +* Added remaining interfaces needed for full PSR7 compatibility + (ServerRequestInterface, UploadedFileInterface, etc.). +* Added support for stream_for from scalars. +* Can now extend Uri. +* Fixed a bug in validating request methods by making it more permissive. + +## 1.2.3 - 2016-02-18 + +* Fixed support in `GuzzleHttp\Psr7\CachingStream` for seeking forward on remote + streams, which can sometimes return fewer bytes than requested with `fread`. +* Fixed handling of gzipped responses with FNAME headers. + +## 1.2.2 - 2016-01-22 + +* Added support for URIs without any authority. +* Added support for HTTP 451 'Unavailable For Legal Reasons.' +* Added support for using '0' as a filename. +* Added support for including non-standard ports in Host headers. + +## 1.2.1 - 2015-11-02 + +* Now supporting negative offsets when seeking to SEEK_END. + +## 1.2.0 - 2015-08-15 + +* Body as `"0"` is now properly added to a response. +* Now allowing forward seeking in CachingStream. +* Now properly parsing HTTP requests that contain proxy targets in + `parse_request`. +* functions.php is now conditionally required. +* user-info is no longer dropped when resolving URIs. + +## 1.1.0 - 2015-06-24 + +* URIs can now be relative. +* `multipart/form-data` headers are now overridden case-insensitively. +* URI paths no longer encode the following characters because they are allowed + in URIs: "(", ")", "*", "!", "'" +* A port is no longer added to a URI when the scheme is missing and no port is + present. + +## 1.0.0 - 2015-05-19 + +Initial release. + +Currently unsupported: + +- `Psr\Http\Message\ServerRequestInterface` +- `Psr\Http\Message\UploadedFileInterface` diff --git a/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/LICENSE b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/LICENSE new file mode 100644 index 0000000..581d95f --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2015 Michael Dowling, https://github.com/mtdowling <mtdowling@gmail.com> + +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/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/README.md b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/README.md new file mode 100644 index 0000000..1649935 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/README.md @@ -0,0 +1,739 @@ +# PSR-7 Message Implementation + +This repository contains a full [PSR-7](http://www.php-fig.org/psr/psr-7/) +message implementation, several stream decorators, and some helpful +functionality like query string parsing. + + +[![Build Status](https://travis-ci.org/guzzle/psr7.svg?branch=master)](https://travis-ci.org/guzzle/psr7) + + +# Stream implementation + +This package comes with a number of stream implementations and stream +decorators. + + +## AppendStream + +`GuzzleHttp\Psr7\AppendStream` + +Reads from multiple streams, one after the other. + +```php +use GuzzleHttp\Psr7; + +$a = Psr7\stream_for('abc, '); +$b = Psr7\stream_for('123.'); +$composed = new Psr7\AppendStream([$a, $b]); + +$composed->addStream(Psr7\stream_for(' Above all listen to me')); + +echo $composed; // abc, 123. Above all listen to me. +``` + + +## BufferStream + +`GuzzleHttp\Psr7\BufferStream` + +Provides a buffer stream that can be written to fill a buffer, and read +from to remove bytes from the buffer. + +This stream returns a "hwm" metadata value that tells upstream consumers +what the configured high water mark of the stream is, or the maximum +preferred size of the buffer. + +```php +use GuzzleHttp\Psr7; + +// When more than 1024 bytes are in the buffer, it will begin returning +// false to writes. This is an indication that writers should slow down. +$buffer = new Psr7\BufferStream(1024); +``` + + +## CachingStream + +The CachingStream is used to allow seeking over previously read bytes on +non-seekable streams. This can be useful when transferring a non-seekable +entity body fails due to needing to rewind the stream (for example, resulting +from a redirect). Data that is read from the remote stream will be buffered in +a PHP temp stream so that previously read bytes are cached first in memory, +then on disk. + +```php +use GuzzleHttp\Psr7; + +$original = Psr7\stream_for(fopen('http://www.google.com', 'r')); +$stream = new Psr7\CachingStream($original); + +$stream->read(1024); +echo $stream->tell(); +// 1024 + +$stream->seek(0); +echo $stream->tell(); +// 0 +``` + + +## DroppingStream + +`GuzzleHttp\Psr7\DroppingStream` + +Stream decorator that begins dropping data once the size of the underlying +stream becomes too full. + +```php +use GuzzleHttp\Psr7; + +// Create an empty stream +$stream = Psr7\stream_for(); + +// Start dropping data when the stream has more than 10 bytes +$dropping = new Psr7\DroppingStream($stream, 10); + +$dropping->write('01234567890123456789'); +echo $stream; // 0123456789 +``` + + +## FnStream + +`GuzzleHttp\Psr7\FnStream` + +Compose stream implementations based on a hash of functions. + +Allows for easy testing and extension of a provided stream without needing +to create a concrete class for a simple extension point. + +```php + +use GuzzleHttp\Psr7; + +$stream = Psr7\stream_for('hi'); +$fnStream = Psr7\FnStream::decorate($stream, [ + 'rewind' => function () use ($stream) { + echo 'About to rewind - '; + $stream->rewind(); + echo 'rewound!'; + } +]); + +$fnStream->rewind(); +// Outputs: About to rewind - rewound! +``` + + +## InflateStream + +`GuzzleHttp\Psr7\InflateStream` + +Uses PHP's zlib.inflate filter to inflate deflate or gzipped content. + +This stream decorator skips the first 10 bytes of the given stream to remove +the gzip header, converts the provided stream to a PHP stream resource, +then appends the zlib.inflate filter. The stream is then converted back +to a Guzzle stream resource to be used as a Guzzle stream. + + +## LazyOpenStream + +`GuzzleHttp\Psr7\LazyOpenStream` + +Lazily reads or writes to a file that is opened only after an IO operation +take place on the stream. + +```php +use GuzzleHttp\Psr7; + +$stream = new Psr7\LazyOpenStream('/path/to/file', 'r'); +// The file has not yet been opened... + +echo $stream->read(10); +// The file is opened and read from only when needed. +``` + + +## LimitStream + +`GuzzleHttp\Psr7\LimitStream` + +LimitStream can be used to read a subset or slice of an existing stream object. +This can be useful for breaking a large file into smaller pieces to be sent in +chunks (e.g. Amazon S3's multipart upload API). + +```php +use GuzzleHttp\Psr7; + +$original = Psr7\stream_for(fopen('/tmp/test.txt', 'r+')); +echo $original->getSize(); +// >>> 1048576 + +// Limit the size of the body to 1024 bytes and start reading from byte 2048 +$stream = new Psr7\LimitStream($original, 1024, 2048); +echo $stream->getSize(); +// >>> 1024 +echo $stream->tell(); +// >>> 0 +``` + + +## MultipartStream + +`GuzzleHttp\Psr7\MultipartStream` + +Stream that when read returns bytes for a streaming multipart or +multipart/form-data stream. + + +## NoSeekStream + +`GuzzleHttp\Psr7\NoSeekStream` + +NoSeekStream wraps a stream and does not allow seeking. + +```php +use GuzzleHttp\Psr7; + +$original = Psr7\stream_for('foo'); +$noSeek = new Psr7\NoSeekStream($original); + +echo $noSeek->read(3); +// foo +var_export($noSeek->isSeekable()); +// false +$noSeek->seek(0); +var_export($noSeek->read(3)); +// NULL +``` + + +## PumpStream + +`GuzzleHttp\Psr7\PumpStream` + +Provides a read only stream that pumps data from a PHP callable. + +When invoking the provided callable, the PumpStream will pass the amount of +data requested to read to the callable. The callable can choose to ignore +this value and return fewer or more bytes than requested. Any extra data +returned by the provided callable is buffered internally until drained using +the read() function of the PumpStream. The provided callable MUST return +false when there is no more data to read. + + +## Implementing stream decorators + +Creating a stream decorator is very easy thanks to the +`GuzzleHttp\Psr7\StreamDecoratorTrait`. This trait provides methods that +implement `Psr\Http\Message\StreamInterface` by proxying to an underlying +stream. Just `use` the `StreamDecoratorTrait` and implement your custom +methods. + +For example, let's say we wanted to call a specific function each time the last +byte is read from a stream. This could be implemented by overriding the +`read()` method. + +```php +use Psr\Http\Message\StreamInterface; +use GuzzleHttp\Psr7\StreamDecoratorTrait; + +class EofCallbackStream implements StreamInterface +{ + use StreamDecoratorTrait; + + private $callback; + + public function __construct(StreamInterface $stream, callable $cb) + { + $this->stream = $stream; + $this->callback = $cb; + } + + public function read($length) + { + $result = $this->stream->read($length); + + // Invoke the callback when EOF is hit. + if ($this->eof()) { + call_user_func($this->callback); + } + + return $result; + } +} +``` + +This decorator could be added to any existing stream and used like so: + +```php +use GuzzleHttp\Psr7; + +$original = Psr7\stream_for('foo'); + +$eofStream = new EofCallbackStream($original, function () { + echo 'EOF!'; +}); + +$eofStream->read(2); +$eofStream->read(1); +// echoes "EOF!" +$eofStream->seek(0); +$eofStream->read(3); +// echoes "EOF!" +``` + + +## PHP StreamWrapper + +You can use the `GuzzleHttp\Psr7\StreamWrapper` class if you need to use a +PSR-7 stream as a PHP stream resource. + +Use the `GuzzleHttp\Psr7\StreamWrapper::getResource()` method to create a PHP +stream from a PSR-7 stream. + +```php +use GuzzleHttp\Psr7\StreamWrapper; + +$stream = GuzzleHttp\Psr7\stream_for('hello!'); +$resource = StreamWrapper::getResource($stream); +echo fread($resource, 6); // outputs hello! +``` + + +# Function API + +There are various functions available under the `GuzzleHttp\Psr7` namespace. + + +## `function str` + +`function str(MessageInterface $message)` + +Returns the string representation of an HTTP message. + +```php +$request = new GuzzleHttp\Psr7\Request('GET', 'http://example.com'); +echo GuzzleHttp\Psr7\str($request); +``` + + +## `function uri_for` + +`function uri_for($uri)` + +This function accepts a string or `Psr\Http\Message\UriInterface` and returns a +UriInterface for the given value. If the value is already a `UriInterface`, it +is returned as-is. + +```php +$uri = GuzzleHttp\Psr7\uri_for('http://example.com'); +assert($uri === GuzzleHttp\Psr7\uri_for($uri)); +``` + + +## `function stream_for` + +`function stream_for($resource = '', array $options = [])` + +Create a new stream based on the input type. + +Options is an associative array that can contain the following keys: + +* - metadata: Array of custom metadata. +* - size: Size of the stream. + +This method accepts the following `$resource` types: + +- `Psr\Http\Message\StreamInterface`: Returns the value as-is. +- `string`: Creates a stream object that uses the given string as the contents. +- `resource`: Creates a stream object that wraps the given PHP stream resource. +- `Iterator`: If the provided value implements `Iterator`, then a read-only + stream object will be created that wraps the given iterable. Each time the + stream is read from, data from the iterator will fill a buffer and will be + continuously called until the buffer is equal to the requested read size. + Subsequent read calls will first read from the buffer and then call `next` + on the underlying iterator until it is exhausted. +- `object` with `__toString()`: If the object has the `__toString()` method, + the object will be cast to a string and then a stream will be returned that + uses the string value. +- `NULL`: When `null` is passed, an empty stream object is returned. +- `callable` When a callable is passed, a read-only stream object will be + created that invokes the given callable. The callable is invoked with the + number of suggested bytes to read. The callable can return any number of + bytes, but MUST return `false` when there is no more data to return. The + stream object that wraps the callable will invoke the callable until the + number of requested bytes are available. Any additional bytes will be + buffered and used in subsequent reads. + +```php +$stream = GuzzleHttp\Psr7\stream_for('foo'); +$stream = GuzzleHttp\Psr7\stream_for(fopen('/path/to/file', 'r')); + +$generator function ($bytes) { + for ($i = 0; $i < $bytes; $i++) { + yield ' '; + } +} + +$stream = GuzzleHttp\Psr7\stream_for($generator(100)); +``` + + +## `function parse_header` + +`function parse_header($header)` + +Parse an array of header values containing ";" separated data into an array of +associative arrays representing the header key value pair data of the header. +When a parameter does not contain a value, but just contains a key, this +function will inject a key with a '' string value. + + +## `function normalize_header` + +`function normalize_header($header)` + +Converts an array of header values that may contain comma separated headers +into an array of headers with no comma separated values. + + +## `function modify_request` + +`function modify_request(RequestInterface $request, array $changes)` + +Clone and modify a request with the given changes. This method is useful for +reducing the number of clones needed to mutate a message. + +The changes can be one of: + +- method: (string) Changes the HTTP method. +- set_headers: (array) Sets the given headers. +- remove_headers: (array) Remove the given headers. +- body: (mixed) Sets the given body. +- uri: (UriInterface) Set the URI. +- query: (string) Set the query string value of the URI. +- version: (string) Set the protocol version. + + +## `function rewind_body` + +`function rewind_body(MessageInterface $message)` + +Attempts to rewind a message body and throws an exception on failure. The body +of the message will only be rewound if a call to `tell()` returns a value other +than `0`. + + +## `function try_fopen` + +`function try_fopen($filename, $mode)` + +Safely opens a PHP stream resource using a filename. + +When fopen fails, PHP normally raises a warning. This function adds an error +handler that checks for errors and throws an exception instead. + + +## `function copy_to_string` + +`function copy_to_string(StreamInterface $stream, $maxLen = -1)` + +Copy the contents of a stream into a string until the given number of bytes +have been read. + + +## `function copy_to_stream` + +`function copy_to_stream(StreamInterface $source, StreamInterface $dest, $maxLen = -1)` + +Copy the contents of a stream into another stream until the given number of +bytes have been read. + + +## `function hash` + +`function hash(StreamInterface $stream, $algo, $rawOutput = false)` + +Calculate a hash of a Stream. This method reads the entire stream to calculate +a rolling hash (based on PHP's hash_init functions). + + +## `function readline` + +`function readline(StreamInterface $stream, $maxLength = null)` + +Read a line from the stream up to the maximum allowed buffer length. + + +## `function parse_request` + +`function parse_request($message)` + +Parses a request message string into a request object. + + +## `function parse_response` + +`function parse_response($message)` + +Parses a response message string into a response object. + + +## `function parse_query` + +`function parse_query($str, $urlEncoding = true)` + +Parse a query string into an associative array. + +If multiple values are found for the same key, the value of that key value pair +will become an array. This function does not parse nested PHP style arrays into +an associative array (e.g., `foo[a]=1&foo[b]=2` will be parsed into +`['foo[a]' => '1', 'foo[b]' => '2']`). + + +## `function build_query` + +`function build_query(array $params, $encoding = PHP_QUERY_RFC3986)` + +Build a query string from an array of key value pairs. + +This function can use the return value of parse_query() to build a query string. +This function does not modify the provided keys when an array is encountered +(like http_build_query would). + + +## `function mimetype_from_filename` + +`function mimetype_from_filename($filename)` + +Determines the mimetype of a file by looking at its extension. + + +## `function mimetype_from_extension` + +`function mimetype_from_extension($extension)` + +Maps a file extensions to a mimetype. + + +# Additional URI Methods + +Aside from the standard `Psr\Http\Message\UriInterface` implementation in form of the `GuzzleHttp\Psr7\Uri` class, +this library also provides additional functionality when working with URIs as static methods. + +## URI Types + +An instance of `Psr\Http\Message\UriInterface` can either be an absolute URI or a relative reference. +An absolute URI has a scheme. A relative reference is used to express a URI relative to another URI, +the base URI. Relative references can be divided into several forms according to +[RFC 3986 Section 4.2](https://tools.ietf.org/html/rfc3986#section-4.2): + +- network-path references, e.g. `//example.com/path` +- absolute-path references, e.g. `/path` +- relative-path references, e.g. `subpath` + +The following methods can be used to identify the type of the URI. + +### `GuzzleHttp\Psr7\Uri::isAbsolute` + +`public static function isAbsolute(UriInterface $uri): bool` + +Whether the URI is absolute, i.e. it has a scheme. + +### `GuzzleHttp\Psr7\Uri::isNetworkPathReference` + +`public static function isNetworkPathReference(UriInterface $uri): bool` + +Whether the URI is a network-path reference. A relative reference that begins with two slash characters is +termed an network-path reference. + +### `GuzzleHttp\Psr7\Uri::isAbsolutePathReference` + +`public static function isAbsolutePathReference(UriInterface $uri): bool` + +Whether the URI is a absolute-path reference. A relative reference that begins with a single slash character is +termed an absolute-path reference. + +### `GuzzleHttp\Psr7\Uri::isRelativePathReference` + +`public static function isRelativePathReference(UriInterface $uri): bool` + +Whether the URI is a relative-path reference. A relative reference that does not begin with a slash character is +termed a relative-path reference. + +### `GuzzleHttp\Psr7\Uri::isSameDocumentReference` + +`public static function isSameDocumentReference(UriInterface $uri, UriInterface $base = null): bool` + +Whether the URI is a same-document reference. A same-document reference refers to a URI that is, aside from its +fragment component, identical to the base URI. When no base URI is given, only an empty URI reference +(apart from its fragment) is considered a same-document reference. + +## URI Components + +Additional methods to work with URI components. + +### `GuzzleHttp\Psr7\Uri::isDefaultPort` + +`public static function isDefaultPort(UriInterface $uri): bool` + +Whether the URI has the default port of the current scheme. `Psr\Http\Message\UriInterface::getPort` may return null +or the standard port. This method can be used independently of the implementation. + +### `GuzzleHttp\Psr7\Uri::composeComponents` + +`public static function composeComponents($scheme, $authority, $path, $query, $fragment): string` + +Composes a URI reference string from its various components according to +[RFC 3986 Section 5.3](https://tools.ietf.org/html/rfc3986#section-5.3). Usually this method does not need to be called +manually but instead is used indirectly via `Psr\Http\Message\UriInterface::__toString`. + +### `GuzzleHttp\Psr7\Uri::fromParts` + +`public static function fromParts(array $parts): UriInterface` + +Creates a URI from a hash of [`parse_url`](http://php.net/manual/en/function.parse-url.php) components. + + +### `GuzzleHttp\Psr7\Uri::withQueryValue` + +`public static function withQueryValue(UriInterface $uri, $key, $value): UriInterface` + +Creates a new URI with a specific query string value. Any existing query string values that exactly match the +provided key are removed and replaced with the given key value pair. A value of null will set the query string +key without a value, e.g. "key" instead of "key=value". + + +### `GuzzleHttp\Psr7\Uri::withoutQueryValue` + +`public static function withoutQueryValue(UriInterface $uri, $key): UriInterface` + +Creates a new URI with a specific query string value removed. Any existing query string values that exactly match the +provided key are removed. + +## Reference Resolution + +`GuzzleHttp\Psr7\UriResolver` provides methods to resolve a URI reference in the context of a base URI according +to [RFC 3986 Section 5](https://tools.ietf.org/html/rfc3986#section-5). This is for example also what web browsers +do when resolving a link in a website based on the current request URI. + +### `GuzzleHttp\Psr7\UriResolver::resolve` + +`public static function resolve(UriInterface $base, UriInterface $rel): UriInterface` + +Converts the relative URI into a new URI that is resolved against the base URI. + +### `GuzzleHttp\Psr7\UriResolver::removeDotSegments` + +`public static function removeDotSegments(string $path): string` + +Removes dot segments from a path and returns the new path according to +[RFC 3986 Section 5.2.4](https://tools.ietf.org/html/rfc3986#section-5.2.4). + +### `GuzzleHttp\Psr7\UriResolver::relativize` + +`public static function relativize(UriInterface $base, UriInterface $target): UriInterface` + +Returns the target URI as a relative reference from the base URI. This method is the counterpart to resolve(): + +```php +(string) $target === (string) UriResolver::resolve($base, UriResolver::relativize($base, $target)) +``` + +One use-case is to use the current request URI as base URI and then generate relative links in your documents +to reduce the document size or offer self-contained downloadable document archives. + +```php +$base = new Uri('http://example.com/a/b/'); +echo UriResolver::relativize($base, new Uri('http://example.com/a/b/c')); // prints 'c'. +echo UriResolver::relativize($base, new Uri('http://example.com/a/x/y')); // prints '../x/y'. +echo UriResolver::relativize($base, new Uri('http://example.com/a/b/?q')); // prints '?q'. +echo UriResolver::relativize($base, new Uri('http://example.org/a/b/')); // prints '//example.org/a/b/'. +``` + +## Normalization and Comparison + +`GuzzleHttp\Psr7\UriNormalizer` provides methods to normalize and compare URIs according to +[RFC 3986 Section 6](https://tools.ietf.org/html/rfc3986#section-6). + +### `GuzzleHttp\Psr7\UriNormalizer::normalize` + +`public static function normalize(UriInterface $uri, $flags = self::PRESERVING_NORMALIZATIONS): UriInterface` + +Returns a normalized URI. The scheme and host component are already normalized to lowercase per PSR-7 UriInterface. +This methods adds additional normalizations that can be configured with the `$flags` parameter which is a bitmask +of normalizations to apply. The following normalizations are available: + +- `UriNormalizer::PRESERVING_NORMALIZATIONS` + + Default normalizations which only include the ones that preserve semantics. + +- `UriNormalizer::CAPITALIZE_PERCENT_ENCODING` + + All letters within a percent-encoding triplet (e.g., "%3A") are case-insensitive, and should be capitalized. + + Example: `http://example.org/a%c2%b1b` → `http://example.org/a%C2%B1b` + +- `UriNormalizer::DECODE_UNRESERVED_CHARACTERS` + + Decodes percent-encoded octets of unreserved characters. For consistency, percent-encoded octets in the ranges of + ALPHA (%41–%5A and %61–%7A), DIGIT (%30–%39), hyphen (%2D), period (%2E), underscore (%5F), or tilde (%7E) should + not be created by URI producers and, when found in a URI, should be decoded to their corresponding unreserved + characters by URI normalizers. + + Example: `http://example.org/%7Eusern%61me/` → `http://example.org/~username/` + +- `UriNormalizer::CONVERT_EMPTY_PATH` + + Converts the empty path to "/" for http and https URIs. + + Example: `http://example.org` → `http://example.org/` + +- `UriNormalizer::REMOVE_DEFAULT_HOST` + + Removes the default host of the given URI scheme from the URI. Only the "file" scheme defines the default host + "localhost". All of `file:/myfile`, `file:///myfile`, and `file://localhost/myfile` are equivalent according to + RFC 3986. + + Example: `file://localhost/myfile` → `file:///myfile` + +- `UriNormalizer::REMOVE_DEFAULT_PORT` + + Removes the default port of the given URI scheme from the URI. + + Example: `http://example.org:80/` → `http://example.org/` + +- `UriNormalizer::REMOVE_DOT_SEGMENTS` + + Removes unnecessary dot-segments. Dot-segments in relative-path references are not removed as it would + change the semantics of the URI reference. + + Example: `http://example.org/../a/b/../c/./d.html` → `http://example.org/a/c/d.html` + +- `UriNormalizer::REMOVE_DUPLICATE_SLASHES` + + Paths which include two or more adjacent slashes are converted to one. Webservers usually ignore duplicate slashes + and treat those URIs equivalent. But in theory those URIs do not need to be equivalent. So this normalization + may change the semantics. Encoded slashes (%2F) are not removed. + + Example: `http://example.org//foo///bar.html` → `http://example.org/foo/bar.html` + +- `UriNormalizer::SORT_QUERY_PARAMETERS` + + Sort query parameters with their values in alphabetical order. However, the order of parameters in a URI may be + significant (this is not defined by the standard). So this normalization is not safe and may change the semantics + of the URI. + + Example: `?lang=en&article=fred` → `?article=fred&lang=en` + +### `GuzzleHttp\Psr7\UriNormalizer::isEquivalent` + +`public static function isEquivalent(UriInterface $uri1, UriInterface $uri2, $normalizations = self::PRESERVING_NORMALIZATIONS): bool` + +Whether two URIs can be considered equivalent. Both URIs are normalized automatically before comparison with the given +`$normalizations` bitmask. The method also accepts relative URI references and returns true when they are equivalent. +This of course assumes they will be resolved against the same base URI. If this is not the case, determination of +equivalence or difference of relative references does not mean anything. diff --git a/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/composer.json b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/composer.json new file mode 100644 index 0000000..b1c5a90 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/composer.json @@ -0,0 +1,39 @@ +{ + "name": "guzzlehttp/psr7", + "type": "library", + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": ["request", "response", "message", "stream", "http", "uri", "url"], + "license": "MIT", + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Schultze", + "homepage": "https://github.com/Tobion" + } + ], + "require": { + "php": ">=5.4.0", + "psr/http-message": "~1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "provide": { + "psr/http-message-implementation": "1.0" + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + }, + "files": ["src/functions_include.php"] + }, + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/AppendStream.php b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/AppendStream.php new file mode 100644 index 0000000..23039fd --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/AppendStream.php @@ -0,0 +1,233 @@ +<?php +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\StreamInterface; + +/** + * Reads from multiple streams, one after the other. + * + * This is a read-only stream decorator. + */ +class AppendStream implements StreamInterface +{ + /** @var StreamInterface[] Streams being decorated */ + private $streams = []; + + private $seekable = true; + private $current = 0; + private $pos = 0; + private $detached = false; + + /** + * @param StreamInterface[] $streams Streams to decorate. Each stream must + * be readable. + */ + public function __construct(array $streams = []) + { + foreach ($streams as $stream) { + $this->addStream($stream); + } + } + + public function __toString() + { + try { + $this->rewind(); + return $this->getContents(); + } catch (\Exception $e) { + return ''; + } + } + + /** + * Add a stream to the AppendStream + * + * @param StreamInterface $stream Stream to append. Must be readable. + * + * @throws \InvalidArgumentException if the stream is not readable + */ + public function addStream(StreamInterface $stream) + { + if (!$stream->isReadable()) { + throw new \InvalidArgumentException('Each stream must be readable'); + } + + // The stream is only seekable if all streams are seekable + if (!$stream->isSeekable()) { + $this->seekable = false; + } + + $this->streams[] = $stream; + } + + public function getContents() + { + return copy_to_string($this); + } + + /** + * Closes each attached stream. + * + * {@inheritdoc} + */ + public function close() + { + $this->pos = $this->current = 0; + + foreach ($this->streams as $stream) { + $stream->close(); + } + + $this->streams = []; + } + + /** + * Detaches each attached stream + * + * {@inheritdoc} + */ + public function detach() + { + $this->close(); + $this->detached = true; + } + + public function tell() + { + return $this->pos; + } + + /** + * Tries to calculate the size by adding the size of each stream. + * + * If any of the streams do not return a valid number, then the size of the + * append stream cannot be determined and null is returned. + * + * {@inheritdoc} + */ + public function getSize() + { + $size = 0; + + foreach ($this->streams as $stream) { + $s = $stream->getSize(); + if ($s === null) { + return null; + } + $size += $s; + } + + return $size; + } + + public function eof() + { + return !$this->streams || + ($this->current >= count($this->streams) - 1 && + $this->streams[$this->current]->eof()); + } + + public function rewind() + { + $this->seek(0); + } + + /** + * Attempts to seek to the given position. Only supports SEEK_SET. + * + * {@inheritdoc} + */ + public function seek($offset, $whence = SEEK_SET) + { + if (!$this->seekable) { + throw new \RuntimeException('This AppendStream is not seekable'); + } elseif ($whence !== SEEK_SET) { + throw new \RuntimeException('The AppendStream can only seek with SEEK_SET'); + } + + $this->pos = $this->current = 0; + + // Rewind each stream + foreach ($this->streams as $i => $stream) { + try { + $stream->rewind(); + } catch (\Exception $e) { + throw new \RuntimeException('Unable to seek stream ' + . $i . ' of the AppendStream', 0, $e); + } + } + + // Seek to the actual position by reading from each stream + while ($this->pos < $offset && !$this->eof()) { + $result = $this->read(min(8096, $offset - $this->pos)); + if ($result === '') { + break; + } + } + } + + /** + * Reads from all of the appended streams until the length is met or EOF. + * + * {@inheritdoc} + */ + public function read($length) + { + $buffer = ''; + $total = count($this->streams) - 1; + $remaining = $length; + $progressToNext = false; + + while ($remaining > 0) { + + // Progress to the next stream if needed. + if ($progressToNext || $this->streams[$this->current]->eof()) { + $progressToNext = false; + if ($this->current === $total) { + break; + } + $this->current++; + } + + $result = $this->streams[$this->current]->read($remaining); + + // Using a loose comparison here to match on '', false, and null + if ($result == null) { + $progressToNext = true; + continue; + } + + $buffer .= $result; + $remaining = $length - strlen($buffer); + } + + $this->pos += strlen($buffer); + + return $buffer; + } + + public function isReadable() + { + return true; + } + + public function isWritable() + { + return false; + } + + public function isSeekable() + { + return $this->seekable; + } + + public function write($string) + { + throw new \RuntimeException('Cannot write to an AppendStream'); + } + + public function getMetadata($key = null) + { + return $key ? null : []; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/BufferStream.php b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/BufferStream.php new file mode 100644 index 0000000..af4d4c2 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/BufferStream.php @@ -0,0 +1,137 @@ +<?php +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\StreamInterface; + +/** + * Provides a buffer stream that can be written to to fill a buffer, and read + * from to remove bytes from the buffer. + * + * This stream returns a "hwm" metadata value that tells upstream consumers + * what the configured high water mark of the stream is, or the maximum + * preferred size of the buffer. + */ +class BufferStream implements StreamInterface +{ + private $hwm; + private $buffer = ''; + + /** + * @param int $hwm High water mark, representing the preferred maximum + * buffer size. If the size of the buffer exceeds the high + * water mark, then calls to write will continue to succeed + * but will return false to inform writers to slow down + * until the buffer has been drained by reading from it. + */ + public function __construct($hwm = 16384) + { + $this->hwm = $hwm; + } + + public function __toString() + { + return $this->getContents(); + } + + public function getContents() + { + $buffer = $this->buffer; + $this->buffer = ''; + + return $buffer; + } + + public function close() + { + $this->buffer = ''; + } + + public function detach() + { + $this->close(); + } + + public function getSize() + { + return strlen($this->buffer); + } + + public function isReadable() + { + return true; + } + + public function isWritable() + { + return true; + } + + public function isSeekable() + { + return false; + } + + public function rewind() + { + $this->seek(0); + } + + public function seek($offset, $whence = SEEK_SET) + { + throw new \RuntimeException('Cannot seek a BufferStream'); + } + + public function eof() + { + return strlen($this->buffer) === 0; + } + + public function tell() + { + throw new \RuntimeException('Cannot determine the position of a BufferStream'); + } + + /** + * Reads data from the buffer. + */ + public function read($length) + { + $currentLength = strlen($this->buffer); + + if ($length >= $currentLength) { + // No need to slice the buffer because we don't have enough data. + $result = $this->buffer; + $this->buffer = ''; + } else { + // Slice up the result to provide a subset of the buffer. + $result = substr($this->buffer, 0, $length); + $this->buffer = substr($this->buffer, $length); + } + + return $result; + } + + /** + * Writes data to the buffer. + */ + public function write($string) + { + $this->buffer .= $string; + + // TODO: What should happen here? + if (strlen($this->buffer) >= $this->hwm) { + return false; + } + + return strlen($string); + } + + public function getMetadata($key = null) + { + if ($key == 'hwm') { + return $this->hwm; + } + + return $key ? null : []; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/CachingStream.php b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/CachingStream.php new file mode 100644 index 0000000..ed68f08 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/CachingStream.php @@ -0,0 +1,138 @@ +<?php +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\StreamInterface; + +/** + * Stream decorator that can cache previously read bytes from a sequentially + * read stream. + */ +class CachingStream implements StreamInterface +{ + use StreamDecoratorTrait; + + /** @var StreamInterface Stream being wrapped */ + private $remoteStream; + + /** @var int Number of bytes to skip reading due to a write on the buffer */ + private $skipReadBytes = 0; + + /** + * We will treat the buffer object as the body of the stream + * + * @param StreamInterface $stream Stream to cache + * @param StreamInterface $target Optionally specify where data is cached + */ + public function __construct( + StreamInterface $stream, + StreamInterface $target = null + ) { + $this->remoteStream = $stream; + $this->stream = $target ?: new Stream(fopen('php://temp', 'r+')); + } + + public function getSize() + { + return max($this->stream->getSize(), $this->remoteStream->getSize()); + } + + public function rewind() + { + $this->seek(0); + } + + public function seek($offset, $whence = SEEK_SET) + { + if ($whence == SEEK_SET) { + $byte = $offset; + } elseif ($whence == SEEK_CUR) { + $byte = $offset + $this->tell(); + } elseif ($whence == SEEK_END) { + $size = $this->remoteStream->getSize(); + if ($size === null) { + $size = $this->cacheEntireStream(); + } + $byte = $size + $offset; + } else { + throw new \InvalidArgumentException('Invalid whence'); + } + + $diff = $byte - $this->stream->getSize(); + + if ($diff > 0) { + // Read the remoteStream until we have read in at least the amount + // of bytes requested, or we reach the end of the file. + while ($diff > 0 && !$this->remoteStream->eof()) { + $this->read($diff); + $diff = $byte - $this->stream->getSize(); + } + } else { + // We can just do a normal seek since we've already seen this byte. + $this->stream->seek($byte); + } + } + + public function read($length) + { + // Perform a regular read on any previously read data from the buffer + $data = $this->stream->read($length); + $remaining = $length - strlen($data); + + // More data was requested so read from the remote stream + if ($remaining) { + // If data was written to the buffer in a position that would have + // been filled from the remote stream, then we must skip bytes on + // the remote stream to emulate overwriting bytes from that + // position. This mimics the behavior of other PHP stream wrappers. + $remoteData = $this->remoteStream->read( + $remaining + $this->skipReadBytes + ); + + if ($this->skipReadBytes) { + $len = strlen($remoteData); + $remoteData = substr($remoteData, $this->skipReadBytes); + $this->skipReadBytes = max(0, $this->skipReadBytes - $len); + } + + $data .= $remoteData; + $this->stream->write($remoteData); + } + + return $data; + } + + public function write($string) + { + // When appending to the end of the currently read stream, you'll want + // to skip bytes from being read from the remote stream to emulate + // other stream wrappers. Basically replacing bytes of data of a fixed + // length. + $overflow = (strlen($string) + $this->tell()) - $this->remoteStream->tell(); + if ($overflow > 0) { + $this->skipReadBytes += $overflow; + } + + return $this->stream->write($string); + } + + public function eof() + { + return $this->stream->eof() && $this->remoteStream->eof(); + } + + /** + * Close both the remote stream and buffer stream + */ + public function close() + { + $this->remoteStream->close() && $this->stream->close(); + } + + private function cacheEntireStream() + { + $target = new FnStream(['write' => 'strlen']); + copy_to_stream($this, $target); + + return $this->tell(); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/DroppingStream.php b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/DroppingStream.php new file mode 100644 index 0000000..8935c80 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/DroppingStream.php @@ -0,0 +1,42 @@ +<?php +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\StreamInterface; + +/** + * Stream decorator that begins dropping data once the size of the underlying + * stream becomes too full. + */ +class DroppingStream implements StreamInterface +{ + use StreamDecoratorTrait; + + private $maxLength; + + /** + * @param StreamInterface $stream Underlying stream to decorate. + * @param int $maxLength Maximum size before dropping data. + */ + public function __construct(StreamInterface $stream, $maxLength) + { + $this->stream = $stream; + $this->maxLength = $maxLength; + } + + public function write($string) + { + $diff = $this->maxLength - $this->stream->getSize(); + + // Begin returning 0 when the underlying stream is too large. + if ($diff <= 0) { + return 0; + } + + // Write the stream or a subset of the stream if needed. + if (strlen($string) < $diff) { + return $this->stream->write($string); + } + + return $this->stream->write(substr($string, 0, $diff)); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/FnStream.php b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/FnStream.php new file mode 100644 index 0000000..cc9b445 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/FnStream.php @@ -0,0 +1,149 @@ +<?php +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\StreamInterface; + +/** + * Compose stream implementations based on a hash of functions. + * + * Allows for easy testing and extension of a provided stream without needing + * to create a concrete class for a simple extension point. + */ +class FnStream implements StreamInterface +{ + /** @var array */ + private $methods; + + /** @var array Methods that must be implemented in the given array */ + private static $slots = ['__toString', 'close', 'detach', 'rewind', + 'getSize', 'tell', 'eof', 'isSeekable', 'seek', 'isWritable', 'write', + 'isReadable', 'read', 'getContents', 'getMetadata']; + + /** + * @param array $methods Hash of method name to a callable. + */ + public function __construct(array $methods) + { + $this->methods = $methods; + + // Create the functions on the class + foreach ($methods as $name => $fn) { + $this->{'_fn_' . $name} = $fn; + } + } + + /** + * Lazily determine which methods are not implemented. + * @throws \BadMethodCallException + */ + public function __get($name) + { + throw new \BadMethodCallException(str_replace('_fn_', '', $name) + . '() is not implemented in the FnStream'); + } + + /** + * The close method is called on the underlying stream only if possible. + */ + public function __destruct() + { + if (isset($this->_fn_close)) { + call_user_func($this->_fn_close); + } + } + + /** + * Adds custom functionality to an underlying stream by intercepting + * specific method calls. + * + * @param StreamInterface $stream Stream to decorate + * @param array $methods Hash of method name to a closure + * + * @return FnStream + */ + public static function decorate(StreamInterface $stream, array $methods) + { + // If any of the required methods were not provided, then simply + // proxy to the decorated stream. + foreach (array_diff(self::$slots, array_keys($methods)) as $diff) { + $methods[$diff] = [$stream, $diff]; + } + + return new self($methods); + } + + public function __toString() + { + return call_user_func($this->_fn___toString); + } + + public function close() + { + return call_user_func($this->_fn_close); + } + + public function detach() + { + return call_user_func($this->_fn_detach); + } + + public function getSize() + { + return call_user_func($this->_fn_getSize); + } + + public function tell() + { + return call_user_func($this->_fn_tell); + } + + public function eof() + { + return call_user_func($this->_fn_eof); + } + + public function isSeekable() + { + return call_user_func($this->_fn_isSeekable); + } + + public function rewind() + { + call_user_func($this->_fn_rewind); + } + + public function seek($offset, $whence = SEEK_SET) + { + call_user_func($this->_fn_seek, $offset, $whence); + } + + public function isWritable() + { + return call_user_func($this->_fn_isWritable); + } + + public function write($string) + { + return call_user_func($this->_fn_write, $string); + } + + public function isReadable() + { + return call_user_func($this->_fn_isReadable); + } + + public function read($length) + { + return call_user_func($this->_fn_read, $length); + } + + public function getContents() + { + return call_user_func($this->_fn_getContents); + } + + public function getMetadata($key = null) + { + return call_user_func($this->_fn_getMetadata, $key); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/InflateStream.php b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/InflateStream.php new file mode 100644 index 0000000..0051d3f --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/InflateStream.php @@ -0,0 +1,52 @@ +<?php +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\StreamInterface; + +/** + * Uses PHP's zlib.inflate filter to inflate deflate or gzipped content. + * + * This stream decorator skips the first 10 bytes of the given stream to remove + * the gzip header, converts the provided stream to a PHP stream resource, + * then appends the zlib.inflate filter. The stream is then converted back + * to a Guzzle stream resource to be used as a Guzzle stream. + * + * @link http://tools.ietf.org/html/rfc1952 + * @link http://php.net/manual/en/filters.compression.php + */ +class InflateStream implements StreamInterface +{ + use StreamDecoratorTrait; + + public function __construct(StreamInterface $stream) + { + // read the first 10 bytes, ie. gzip header + $header = $stream->read(10); + $filenameHeaderLength = $this->getLengthOfPossibleFilenameHeader($stream, $header); + // Skip the header, that is 10 + length of filename + 1 (nil) bytes + $stream = new LimitStream($stream, -1, 10 + $filenameHeaderLength); + $resource = StreamWrapper::getResource($stream); + stream_filter_append($resource, 'zlib.inflate', STREAM_FILTER_READ); + $this->stream = new Stream($resource); + } + + /** + * @param StreamInterface $stream + * @param $header + * @return int + */ + private function getLengthOfPossibleFilenameHeader(StreamInterface $stream, $header) + { + $filename_header_length = 0; + + if (substr(bin2hex($header), 6, 2) === '08') { + // we have a filename, read until nil + $filename_header_length = 1; + while ($stream->read(1) !== chr(0)) { + $filename_header_length++; + } + } + + return $filename_header_length; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/LazyOpenStream.php b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/LazyOpenStream.php new file mode 100644 index 0000000..02cec3a --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/LazyOpenStream.php @@ -0,0 +1,39 @@ +<?php +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\StreamInterface; + +/** + * Lazily reads or writes to a file that is opened only after an IO operation + * take place on the stream. + */ +class LazyOpenStream implements StreamInterface +{ + use StreamDecoratorTrait; + + /** @var string File to open */ + private $filename; + + /** @var string $mode */ + private $mode; + + /** + * @param string $filename File to lazily open + * @param string $mode fopen mode to use when opening the stream + */ + public function __construct($filename, $mode) + { + $this->filename = $filename; + $this->mode = $mode; + } + + /** + * Creates the underlying stream lazily when required. + * + * @return StreamInterface + */ + protected function createStream() + { + return stream_for(try_fopen($this->filename, $this->mode)); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/LimitStream.php b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/LimitStream.php new file mode 100644 index 0000000..3c13d4f --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/LimitStream.php @@ -0,0 +1,155 @@ +<?php +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\StreamInterface; + + +/** + * Decorator used to return only a subset of a stream + */ +class LimitStream implements StreamInterface +{ + use StreamDecoratorTrait; + + /** @var int Offset to start reading from */ + private $offset; + + /** @var int Limit the number of bytes that can be read */ + private $limit; + + /** + * @param StreamInterface $stream Stream to wrap + * @param int $limit Total number of bytes to allow to be read + * from the stream. Pass -1 for no limit. + * @param int $offset Position to seek to before reading (only + * works on seekable streams). + */ + public function __construct( + StreamInterface $stream, + $limit = -1, + $offset = 0 + ) { + $this->stream = $stream; + $this->setLimit($limit); + $this->setOffset($offset); + } + + public function eof() + { + // Always return true if the underlying stream is EOF + if ($this->stream->eof()) { + return true; + } + + // No limit and the underlying stream is not at EOF + if ($this->limit == -1) { + return false; + } + + return $this->stream->tell() >= $this->offset + $this->limit; + } + + /** + * Returns the size of the limited subset of data + * {@inheritdoc} + */ + public function getSize() + { + if (null === ($length = $this->stream->getSize())) { + return null; + } elseif ($this->limit == -1) { + return $length - $this->offset; + } else { + return min($this->limit, $length - $this->offset); + } + } + + /** + * Allow for a bounded seek on the read limited stream + * {@inheritdoc} + */ + public function seek($offset, $whence = SEEK_SET) + { + if ($whence !== SEEK_SET || $offset < 0) { + throw new \RuntimeException(sprintf( + 'Cannot seek to offset % with whence %s', + $offset, + $whence + )); + } + + $offset += $this->offset; + + if ($this->limit !== -1) { + if ($offset > $this->offset + $this->limit) { + $offset = $this->offset + $this->limit; + } + } + + $this->stream->seek($offset); + } + + /** + * Give a relative tell() + * {@inheritdoc} + */ + public function tell() + { + return $this->stream->tell() - $this->offset; + } + + /** + * Set the offset to start limiting from + * + * @param int $offset Offset to seek to and begin byte limiting from + * + * @throws \RuntimeException if the stream cannot be seeked. + */ + public function setOffset($offset) + { + $current = $this->stream->tell(); + + if ($current !== $offset) { + // If the stream cannot seek to the offset position, then read to it + if ($this->stream->isSeekable()) { + $this->stream->seek($offset); + } elseif ($current > $offset) { + throw new \RuntimeException("Could not seek to stream offset $offset"); + } else { + $this->stream->read($offset - $current); + } + } + + $this->offset = $offset; + } + + /** + * Set the limit of bytes that the decorator allows to be read from the + * stream. + * + * @param int $limit Number of bytes to allow to be read from the stream. + * Use -1 for no limit. + */ + public function setLimit($limit) + { + $this->limit = $limit; + } + + public function read($length) + { + if ($this->limit == -1) { + return $this->stream->read($length); + } + + // Check if the current position is less than the total allowed + // bytes + original offset + $remaining = ($this->offset + $this->limit) - $this->stream->tell(); + if ($remaining > 0) { + // Only return the amount of requested data, ensuring that the byte + // limit is not exceeded + return $this->stream->read(min($remaining, $length)); + } + + return ''; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/MessageTrait.php b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/MessageTrait.php new file mode 100644 index 0000000..1e4da64 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/MessageTrait.php @@ -0,0 +1,183 @@ +<?php +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\StreamInterface; + +/** + * Trait implementing functionality common to requests and responses. + */ +trait MessageTrait +{ + /** @var array Map of all registered headers, as original name => array of values */ + private $headers = []; + + /** @var array Map of lowercase header name => original name at registration */ + private $headerNames = []; + + /** @var string */ + private $protocol = '1.1'; + + /** @var StreamInterface */ + private $stream; + + public function getProtocolVersion() + { + return $this->protocol; + } + + public function withProtocolVersion($version) + { + if ($this->protocol === $version) { + return $this; + } + + $new = clone $this; + $new->protocol = $version; + return $new; + } + + public function getHeaders() + { + return $this->headers; + } + + public function hasHeader($header) + { + return isset($this->headerNames[strtolower($header)]); + } + + public function getHeader($header) + { + $header = strtolower($header); + + if (!isset($this->headerNames[$header])) { + return []; + } + + $header = $this->headerNames[$header]; + + return $this->headers[$header]; + } + + public function getHeaderLine($header) + { + return implode(', ', $this->getHeader($header)); + } + + public function withHeader($header, $value) + { + if (!is_array($value)) { + $value = [$value]; + } + + $value = $this->trimHeaderValues($value); + $normalized = strtolower($header); + + $new = clone $this; + if (isset($new->headerNames[$normalized])) { + unset($new->headers[$new->headerNames[$normalized]]); + } + $new->headerNames[$normalized] = $header; + $new->headers[$header] = $value; + + return $new; + } + + public function withAddedHeader($header, $value) + { + if (!is_array($value)) { + $value = [$value]; + } + + $value = $this->trimHeaderValues($value); + $normalized = strtolower($header); + + $new = clone $this; + if (isset($new->headerNames[$normalized])) { + $header = $this->headerNames[$normalized]; + $new->headers[$header] = array_merge($this->headers[$header], $value); + } else { + $new->headerNames[$normalized] = $header; + $new->headers[$header] = $value; + } + + return $new; + } + + public function withoutHeader($header) + { + $normalized = strtolower($header); + + if (!isset($this->headerNames[$normalized])) { + return $this; + } + + $header = $this->headerNames[$normalized]; + + $new = clone $this; + unset($new->headers[$header], $new->headerNames[$normalized]); + + return $new; + } + + public function getBody() + { + if (!$this->stream) { + $this->stream = stream_for(''); + } + + return $this->stream; + } + + public function withBody(StreamInterface $body) + { + if ($body === $this->stream) { + return $this; + } + + $new = clone $this; + $new->stream = $body; + return $new; + } + + private function setHeaders(array $headers) + { + $this->headerNames = $this->headers = []; + foreach ($headers as $header => $value) { + if (!is_array($value)) { + $value = [$value]; + } + + $value = $this->trimHeaderValues($value); + $normalized = strtolower($header); + if (isset($this->headerNames[$normalized])) { + $header = $this->headerNames[$normalized]; + $this->headers[$header] = array_merge($this->headers[$header], $value); + } else { + $this->headerNames[$normalized] = $header; + $this->headers[$header] = $value; + } + } + } + + /** + * Trims whitespace from the header values. + * + * Spaces and tabs ought to be excluded by parsers when extracting the field value from a header field. + * + * header-field = field-name ":" OWS field-value OWS + * OWS = *( SP / HTAB ) + * + * @param string[] $values Header values + * + * @return string[] Trimmed header values + * + * @see https://tools.ietf.org/html/rfc7230#section-3.2.4 + */ + private function trimHeaderValues(array $values) + { + return array_map(function ($value) { + return trim($value, " \t"); + }, $values); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/MultipartStream.php b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/MultipartStream.php new file mode 100644 index 0000000..c0fd584 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/MultipartStream.php @@ -0,0 +1,153 @@ +<?php +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\StreamInterface; + +/** + * Stream that when read returns bytes for a streaming multipart or + * multipart/form-data stream. + */ +class MultipartStream implements StreamInterface +{ + use StreamDecoratorTrait; + + private $boundary; + + /** + * @param array $elements Array of associative arrays, each containing a + * required "name" key mapping to the form field, + * name, a required "contents" key mapping to a + * StreamInterface/resource/string, an optional + * "headers" associative array of custom headers, + * and an optional "filename" key mapping to a + * string to send as the filename in the part. + * @param string $boundary You can optionally provide a specific boundary + * + * @throws \InvalidArgumentException + */ + public function __construct(array $elements = [], $boundary = null) + { + $this->boundary = $boundary ?: sha1(uniqid('', true)); + $this->stream = $this->createStream($elements); + } + + /** + * Get the boundary + * + * @return string + */ + public function getBoundary() + { + return $this->boundary; + } + + public function isWritable() + { + return false; + } + + /** + * Get the headers needed before transferring the content of a POST file + */ + private function getHeaders(array $headers) + { + $str = ''; + foreach ($headers as $key => $value) { + $str .= "{$key}: {$value}\r\n"; + } + + return "--{$this->boundary}\r\n" . trim($str) . "\r\n\r\n"; + } + + /** + * Create the aggregate stream that will be used to upload the POST data + */ + protected function createStream(array $elements) + { + $stream = new AppendStream(); + + foreach ($elements as $element) { + $this->addElement($stream, $element); + } + + // Add the trailing boundary with CRLF + $stream->addStream(stream_for("--{$this->boundary}--\r\n")); + + return $stream; + } + + private function addElement(AppendStream $stream, array $element) + { + foreach (['contents', 'name'] as $key) { + if (!array_key_exists($key, $element)) { + throw new \InvalidArgumentException("A '{$key}' key is required"); + } + } + + $element['contents'] = stream_for($element['contents']); + + if (empty($element['filename'])) { + $uri = $element['contents']->getMetadata('uri'); + if (substr($uri, 0, 6) !== 'php://') { + $element['filename'] = $uri; + } + } + + list($body, $headers) = $this->createElement( + $element['name'], + $element['contents'], + isset($element['filename']) ? $element['filename'] : null, + isset($element['headers']) ? $element['headers'] : [] + ); + + $stream->addStream(stream_for($this->getHeaders($headers))); + $stream->addStream($body); + $stream->addStream(stream_for("\r\n")); + } + + /** + * @return array + */ + private function createElement($name, StreamInterface $stream, $filename, array $headers) + { + // Set a default content-disposition header if one was no provided + $disposition = $this->getHeader($headers, 'content-disposition'); + if (!$disposition) { + $headers['Content-Disposition'] = ($filename === '0' || $filename) + ? sprintf('form-data; name="%s"; filename="%s"', + $name, + basename($filename)) + : "form-data; name=\"{$name}\""; + } + + // Set a default content-length header if one was no provided + $length = $this->getHeader($headers, 'content-length'); + if (!$length) { + if ($length = $stream->getSize()) { + $headers['Content-Length'] = (string) $length; + } + } + + // Set a default Content-Type if one was not supplied + $type = $this->getHeader($headers, 'content-type'); + if (!$type && ($filename === '0' || $filename)) { + if ($type = mimetype_from_filename($filename)) { + $headers['Content-Type'] = $type; + } + } + + return [$stream, $headers]; + } + + private function getHeader(array $headers, $key) + { + $lowercaseHeader = strtolower($key); + foreach ($headers as $k => $v) { + if (strtolower($k) === $lowercaseHeader) { + return $v; + } + } + + return null; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/NoSeekStream.php b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/NoSeekStream.php new file mode 100644 index 0000000..2332218 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/NoSeekStream.php @@ -0,0 +1,22 @@ +<?php +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\StreamInterface; + +/** + * Stream decorator that prevents a stream from being seeked + */ +class NoSeekStream implements StreamInterface +{ + use StreamDecoratorTrait; + + public function seek($offset, $whence = SEEK_SET) + { + throw new \RuntimeException('Cannot seek a NoSeekStream'); + } + + public function isSeekable() + { + return false; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/PumpStream.php b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/PumpStream.php new file mode 100644 index 0000000..ffb5440 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/PumpStream.php @@ -0,0 +1,165 @@ +<?php +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\StreamInterface; + +/** + * Provides a read only stream that pumps data from a PHP callable. + * + * When invoking the provided callable, the PumpStream will pass the amount of + * data requested to read to the callable. The callable can choose to ignore + * this value and return fewer or more bytes than requested. Any extra data + * returned by the provided callable is buffered internally until drained using + * the read() function of the PumpStream. The provided callable MUST return + * false when there is no more data to read. + */ +class PumpStream implements StreamInterface +{ + /** @var callable */ + private $source; + + /** @var int */ + private $size; + + /** @var int */ + private $tellPos = 0; + + /** @var array */ + private $metadata; + + /** @var BufferStream */ + private $buffer; + + /** + * @param callable $source Source of the stream data. The callable MAY + * accept an integer argument used to control the + * amount of data to return. The callable MUST + * return a string when called, or false on error + * or EOF. + * @param array $options Stream options: + * - metadata: Hash of metadata to use with stream. + * - size: Size of the stream, if known. + */ + public function __construct(callable $source, array $options = []) + { + $this->source = $source; + $this->size = isset($options['size']) ? $options['size'] : null; + $this->metadata = isset($options['metadata']) ? $options['metadata'] : []; + $this->buffer = new BufferStream(); + } + + public function __toString() + { + try { + return copy_to_string($this); + } catch (\Exception $e) { + return ''; + } + } + + public function close() + { + $this->detach(); + } + + public function detach() + { + $this->tellPos = false; + $this->source = null; + } + + public function getSize() + { + return $this->size; + } + + public function tell() + { + return $this->tellPos; + } + + public function eof() + { + return !$this->source; + } + + public function isSeekable() + { + return false; + } + + public function rewind() + { + $this->seek(0); + } + + public function seek($offset, $whence = SEEK_SET) + { + throw new \RuntimeException('Cannot seek a PumpStream'); + } + + public function isWritable() + { + return false; + } + + public function write($string) + { + throw new \RuntimeException('Cannot write to a PumpStream'); + } + + public function isReadable() + { + return true; + } + + public function read($length) + { + $data = $this->buffer->read($length); + $readLen = strlen($data); + $this->tellPos += $readLen; + $remaining = $length - $readLen; + + if ($remaining) { + $this->pump($remaining); + $data .= $this->buffer->read($remaining); + $this->tellPos += strlen($data) - $readLen; + } + + return $data; + } + + public function getContents() + { + $result = ''; + while (!$this->eof()) { + $result .= $this->read(1000000); + } + + return $result; + } + + public function getMetadata($key = null) + { + if (!$key) { + return $this->metadata; + } + + return isset($this->metadata[$key]) ? $this->metadata[$key] : null; + } + + private function pump($length) + { + if ($this->source) { + do { + $data = call_user_func($this->source, $length); + if ($data === false || $data === null) { + $this->source = null; + return; + } + $this->buffer->write($data); + $length -= strlen($data); + } while ($length > 0); + } + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/Request.php b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/Request.php new file mode 100644 index 0000000..0828548 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/Request.php @@ -0,0 +1,142 @@ +<?php +namespace GuzzleHttp\Psr7; + +use InvalidArgumentException; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\StreamInterface; +use Psr\Http\Message\UriInterface; + +/** + * PSR-7 request implementation. + */ +class Request implements RequestInterface +{ + use MessageTrait; + + /** @var string */ + private $method; + + /** @var null|string */ + private $requestTarget; + + /** @var UriInterface */ + private $uri; + + /** + * @param string $method HTTP method + * @param string|UriInterface $uri URI + * @param array $headers Request headers + * @param string|null|resource|StreamInterface $body Request body + * @param string $version Protocol version + */ + public function __construct( + $method, + $uri, + array $headers = [], + $body = null, + $version = '1.1' + ) { + if (!($uri instanceof UriInterface)) { + $uri = new Uri($uri); + } + + $this->method = strtoupper($method); + $this->uri = $uri; + $this->setHeaders($headers); + $this->protocol = $version; + + if (!$this->hasHeader('Host')) { + $this->updateHostFromUri(); + } + + if ($body !== '' && $body !== null) { + $this->stream = stream_for($body); + } + } + + public function getRequestTarget() + { + if ($this->requestTarget !== null) { + return $this->requestTarget; + } + + $target = $this->uri->getPath(); + if ($target == '') { + $target = '/'; + } + if ($this->uri->getQuery() != '') { + $target .= '?' . $this->uri->getQuery(); + } + + return $target; + } + + public function withRequestTarget($requestTarget) + { + if (preg_match('#\s#', $requestTarget)) { + throw new InvalidArgumentException( + 'Invalid request target provided; cannot contain whitespace' + ); + } + + $new = clone $this; + $new->requestTarget = $requestTarget; + return $new; + } + + public function getMethod() + { + return $this->method; + } + + public function withMethod($method) + { + $new = clone $this; + $new->method = strtoupper($method); + return $new; + } + + public function getUri() + { + return $this->uri; + } + + public function withUri(UriInterface $uri, $preserveHost = false) + { + if ($uri === $this->uri) { + return $this; + } + + $new = clone $this; + $new->uri = $uri; + + if (!$preserveHost) { + $new->updateHostFromUri(); + } + + return $new; + } + + private function updateHostFromUri() + { + $host = $this->uri->getHost(); + + if ($host == '') { + return; + } + + if (($port = $this->uri->getPort()) !== null) { + $host .= ':' . $port; + } + + if (isset($this->headerNames['host'])) { + $header = $this->headerNames['host']; + } else { + $header = 'Host'; + $this->headerNames['host'] = 'Host'; + } + // Ensure Host is the first header. + // See: http://tools.ietf.org/html/rfc7230#section-5.4 + $this->headers = [$header => [$host]] + $this->headers; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/Response.php b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/Response.php new file mode 100644 index 0000000..2830c6c --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/Response.php @@ -0,0 +1,132 @@ +<?php +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\StreamInterface; + +/** + * PSR-7 response implementation. + */ +class Response implements ResponseInterface +{ + use MessageTrait; + + /** @var array Map of standard HTTP status code/reason phrases */ + private static $phrases = [ + 100 => 'Continue', + 101 => 'Switching Protocols', + 102 => 'Processing', + 200 => 'OK', + 201 => 'Created', + 202 => 'Accepted', + 203 => 'Non-Authoritative Information', + 204 => 'No Content', + 205 => 'Reset Content', + 206 => 'Partial Content', + 207 => 'Multi-status', + 208 => 'Already Reported', + 300 => 'Multiple Choices', + 301 => 'Moved Permanently', + 302 => 'Found', + 303 => 'See Other', + 304 => 'Not Modified', + 305 => 'Use Proxy', + 306 => 'Switch Proxy', + 307 => 'Temporary Redirect', + 400 => 'Bad Request', + 401 => 'Unauthorized', + 402 => 'Payment Required', + 403 => 'Forbidden', + 404 => 'Not Found', + 405 => 'Method Not Allowed', + 406 => 'Not Acceptable', + 407 => 'Proxy Authentication Required', + 408 => 'Request Time-out', + 409 => 'Conflict', + 410 => 'Gone', + 411 => 'Length Required', + 412 => 'Precondition Failed', + 413 => 'Request Entity Too Large', + 414 => 'Request-URI Too Large', + 415 => 'Unsupported Media Type', + 416 => 'Requested range not satisfiable', + 417 => 'Expectation Failed', + 418 => 'I\'m a teapot', + 422 => 'Unprocessable Entity', + 423 => 'Locked', + 424 => 'Failed Dependency', + 425 => 'Unordered Collection', + 426 => 'Upgrade Required', + 428 => 'Precondition Required', + 429 => 'Too Many Requests', + 431 => 'Request Header Fields Too Large', + 451 => 'Unavailable For Legal Reasons', + 500 => 'Internal Server Error', + 501 => 'Not Implemented', + 502 => 'Bad Gateway', + 503 => 'Service Unavailable', + 504 => 'Gateway Time-out', + 505 => 'HTTP Version not supported', + 506 => 'Variant Also Negotiates', + 507 => 'Insufficient Storage', + 508 => 'Loop Detected', + 511 => 'Network Authentication Required', + ]; + + /** @var string */ + private $reasonPhrase = ''; + + /** @var int */ + private $statusCode = 200; + + /** + * @param int $status Status code + * @param array $headers Response headers + * @param string|null|resource|StreamInterface $body Response body + * @param string $version Protocol version + * @param string|null $reason Reason phrase (when empty a default will be used based on the status code) + */ + public function __construct( + $status = 200, + array $headers = [], + $body = null, + $version = '1.1', + $reason = null + ) { + $this->statusCode = (int) $status; + + if ($body !== '' && $body !== null) { + $this->stream = stream_for($body); + } + + $this->setHeaders($headers); + if ($reason == '' && isset(self::$phrases[$this->statusCode])) { + $this->reasonPhrase = self::$phrases[$this->statusCode]; + } else { + $this->reasonPhrase = (string) $reason; + } + + $this->protocol = $version; + } + + public function getStatusCode() + { + return $this->statusCode; + } + + public function getReasonPhrase() + { + return $this->reasonPhrase; + } + + public function withStatus($code, $reasonPhrase = '') + { + $new = clone $this; + $new->statusCode = (int) $code; + if ($reasonPhrase == '' && isset(self::$phrases[$new->statusCode])) { + $reasonPhrase = self::$phrases[$new->statusCode]; + } + $new->reasonPhrase = $reasonPhrase; + return $new; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/ServerRequest.php b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/ServerRequest.php new file mode 100644 index 0000000..575aab8 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/ServerRequest.php @@ -0,0 +1,358 @@ +<?php + +namespace GuzzleHttp\Psr7; + +use InvalidArgumentException; +use Psr\Http\Message\ServerRequestInterface; +use Psr\Http\Message\UriInterface; +use Psr\Http\Message\StreamInterface; +use Psr\Http\Message\UploadedFileInterface; + +/** + * Server-side HTTP request + * + * Extends the Request definition to add methods for accessing incoming data, + * specifically server parameters, cookies, matched path parameters, query + * string arguments, body parameters, and upload file information. + * + * "Attributes" are discovered via decomposing the request (and usually + * specifically the URI path), and typically will be injected by the application. + * + * Requests are considered immutable; all methods that might change state are + * implemented such that they retain the internal state of the current + * message and return a new instance that contains the changed state. + */ +class ServerRequest extends Request implements ServerRequestInterface +{ + /** + * @var array + */ + private $attributes = []; + + /** + * @var array + */ + private $cookieParams = []; + + /** + * @var null|array|object + */ + private $parsedBody; + + /** + * @var array + */ + private $queryParams = []; + + /** + * @var array + */ + private $serverParams; + + /** + * @var array + */ + private $uploadedFiles = []; + + /** + * @param string $method HTTP method + * @param string|UriInterface $uri URI + * @param array $headers Request headers + * @param string|null|resource|StreamInterface $body Request body + * @param string $version Protocol version + * @param array $serverParams Typically the $_SERVER superglobal + */ + public function __construct( + $method, + $uri, + array $headers = [], + $body = null, + $version = '1.1', + array $serverParams = [] + ) { + $this->serverParams = $serverParams; + + parent::__construct($method, $uri, $headers, $body, $version); + } + + /** + * Return an UploadedFile instance array. + * + * @param array $files A array which respect $_FILES structure + * @throws InvalidArgumentException for unrecognized values + * @return array + */ + public static function normalizeFiles(array $files) + { + $normalized = []; + + foreach ($files as $key => $value) { + if ($value instanceof UploadedFileInterface) { + $normalized[$key] = $value; + } elseif (is_array($value) && isset($value['tmp_name'])) { + $normalized[$key] = self::createUploadedFileFromSpec($value); + } elseif (is_array($value)) { + $normalized[$key] = self::normalizeFiles($value); + continue; + } else { + throw new InvalidArgumentException('Invalid value in files specification'); + } + } + + return $normalized; + } + + /** + * Create and return an UploadedFile instance from a $_FILES specification. + * + * If the specification represents an array of values, this method will + * delegate to normalizeNestedFileSpec() and return that return value. + * + * @param array $value $_FILES struct + * @return array|UploadedFileInterface + */ + private static function createUploadedFileFromSpec(array $value) + { + if (is_array($value['tmp_name'])) { + return self::normalizeNestedFileSpec($value); + } + + return new UploadedFile( + $value['tmp_name'], + (int) $value['size'], + (int) $value['error'], + $value['name'], + $value['type'] + ); + } + + /** + * Normalize an array of file specifications. + * + * Loops through all nested files and returns a normalized array of + * UploadedFileInterface instances. + * + * @param array $files + * @return UploadedFileInterface[] + */ + private static function normalizeNestedFileSpec(array $files = []) + { + $normalizedFiles = []; + + foreach (array_keys($files['tmp_name']) as $key) { + $spec = [ + 'tmp_name' => $files['tmp_name'][$key], + 'size' => $files['size'][$key], + 'error' => $files['error'][$key], + 'name' => $files['name'][$key], + 'type' => $files['type'][$key], + ]; + $normalizedFiles[$key] = self::createUploadedFileFromSpec($spec); + } + + return $normalizedFiles; + } + + /** + * Return a ServerRequest populated with superglobals: + * $_GET + * $_POST + * $_COOKIE + * $_FILES + * $_SERVER + * + * @return ServerRequestInterface + */ + public static function fromGlobals() + { + $method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET'; + $headers = function_exists('getallheaders') ? getallheaders() : []; + $uri = self::getUriFromGlobals(); + $body = new LazyOpenStream('php://input', 'r+'); + $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? str_replace('HTTP/', '', $_SERVER['SERVER_PROTOCOL']) : '1.1'; + + $serverRequest = new ServerRequest($method, $uri, $headers, $body, $protocol, $_SERVER); + + return $serverRequest + ->withCookieParams($_COOKIE) + ->withQueryParams($_GET) + ->withParsedBody($_POST) + ->withUploadedFiles(self::normalizeFiles($_FILES)); + } + + /** + * Get a Uri populated with values from $_SERVER. + * + * @return UriInterface + */ + public static function getUriFromGlobals() { + $uri = new Uri(''); + + $uri = $uri->withScheme(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http'); + + $hasPort = false; + if (isset($_SERVER['HTTP_HOST'])) { + $hostHeaderParts = explode(':', $_SERVER['HTTP_HOST']); + $uri = $uri->withHost($hostHeaderParts[0]); + if (isset($hostHeaderParts[1])) { + $hasPort = true; + $uri = $uri->withPort($hostHeaderParts[1]); + } + } elseif (isset($_SERVER['SERVER_NAME'])) { + $uri = $uri->withHost($_SERVER['SERVER_NAME']); + } elseif (isset($_SERVER['SERVER_ADDR'])) { + $uri = $uri->withHost($_SERVER['SERVER_ADDR']); + } + + if (!$hasPort && isset($_SERVER['SERVER_PORT'])) { + $uri = $uri->withPort($_SERVER['SERVER_PORT']); + } + + $hasQuery = false; + if (isset($_SERVER['REQUEST_URI'])) { + $requestUriParts = explode('?', $_SERVER['REQUEST_URI']); + $uri = $uri->withPath($requestUriParts[0]); + if (isset($requestUriParts[1])) { + $hasQuery = true; + $uri = $uri->withQuery($requestUriParts[1]); + } + } + + if (!$hasQuery && isset($_SERVER['QUERY_STRING'])) { + $uri = $uri->withQuery($_SERVER['QUERY_STRING']); + } + + return $uri; + } + + + /** + * {@inheritdoc} + */ + public function getServerParams() + { + return $this->serverParams; + } + + /** + * {@inheritdoc} + */ + public function getUploadedFiles() + { + return $this->uploadedFiles; + } + + /** + * {@inheritdoc} + */ + public function withUploadedFiles(array $uploadedFiles) + { + $new = clone $this; + $new->uploadedFiles = $uploadedFiles; + + return $new; + } + + /** + * {@inheritdoc} + */ + public function getCookieParams() + { + return $this->cookieParams; + } + + /** + * {@inheritdoc} + */ + public function withCookieParams(array $cookies) + { + $new = clone $this; + $new->cookieParams = $cookies; + + return $new; + } + + /** + * {@inheritdoc} + */ + public function getQueryParams() + { + return $this->queryParams; + } + + /** + * {@inheritdoc} + */ + public function withQueryParams(array $query) + { + $new = clone $this; + $new->queryParams = $query; + + return $new; + } + + /** + * {@inheritdoc} + */ + public function getParsedBody() + { + return $this->parsedBody; + } + + /** + * {@inheritdoc} + */ + public function withParsedBody($data) + { + $new = clone $this; + $new->parsedBody = $data; + + return $new; + } + + /** + * {@inheritdoc} + */ + public function getAttributes() + { + return $this->attributes; + } + + /** + * {@inheritdoc} + */ + public function getAttribute($attribute, $default = null) + { + if (false === array_key_exists($attribute, $this->attributes)) { + return $default; + } + + return $this->attributes[$attribute]; + } + + /** + * {@inheritdoc} + */ + public function withAttribute($attribute, $value) + { + $new = clone $this; + $new->attributes[$attribute] = $value; + + return $new; + } + + /** + * {@inheritdoc} + */ + public function withoutAttribute($attribute) + { + if (false === array_key_exists($attribute, $this->attributes)) { + return $this; + } + + $new = clone $this; + unset($new->attributes[$attribute]); + + return $new; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/Stream.php b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/Stream.php new file mode 100644 index 0000000..e336628 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/Stream.php @@ -0,0 +1,257 @@ +<?php +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\StreamInterface; + +/** + * PHP stream implementation. + * + * @var $stream + */ +class Stream implements StreamInterface +{ + private $stream; + private $size; + private $seekable; + private $readable; + private $writable; + private $uri; + private $customMetadata; + + /** @var array Hash of readable and writable stream types */ + private static $readWriteHash = [ + 'read' => [ + 'r' => true, 'w+' => true, 'r+' => true, 'x+' => true, 'c+' => true, + 'rb' => true, 'w+b' => true, 'r+b' => true, 'x+b' => true, + 'c+b' => true, 'rt' => true, 'w+t' => true, 'r+t' => true, + 'x+t' => true, 'c+t' => true, 'a+' => true + ], + 'write' => [ + 'w' => true, 'w+' => true, 'rw' => true, 'r+' => true, 'x+' => true, + 'c+' => true, 'wb' => true, 'w+b' => true, 'r+b' => true, + 'x+b' => true, 'c+b' => true, 'w+t' => true, 'r+t' => true, + 'x+t' => true, 'c+t' => true, 'a' => true, 'a+' => true + ] + ]; + + /** + * This constructor accepts an associative array of options. + * + * - size: (int) If a read stream would otherwise have an indeterminate + * size, but the size is known due to foreknowledge, then you can + * provide that size, in bytes. + * - metadata: (array) Any additional metadata to return when the metadata + * of the stream is accessed. + * + * @param resource $stream Stream resource to wrap. + * @param array $options Associative array of options. + * + * @throws \InvalidArgumentException if the stream is not a stream resource + */ + public function __construct($stream, $options = []) + { + if (!is_resource($stream)) { + throw new \InvalidArgumentException('Stream must be a resource'); + } + + if (isset($options['size'])) { + $this->size = $options['size']; + } + + $this->customMetadata = isset($options['metadata']) + ? $options['metadata'] + : []; + + $this->stream = $stream; + $meta = stream_get_meta_data($this->stream); + $this->seekable = $meta['seekable']; + $this->readable = isset(self::$readWriteHash['read'][$meta['mode']]); + $this->writable = isset(self::$readWriteHash['write'][$meta['mode']]); + $this->uri = $this->getMetadata('uri'); + } + + public function __get($name) + { + if ($name == 'stream') { + throw new \RuntimeException('The stream is detached'); + } + + throw new \BadMethodCallException('No value for ' . $name); + } + + /** + * Closes the stream when the destructed + */ + public function __destruct() + { + $this->close(); + } + + public function __toString() + { + try { + $this->seek(0); + return (string) stream_get_contents($this->stream); + } catch (\Exception $e) { + return ''; + } + } + + public function getContents() + { + $contents = stream_get_contents($this->stream); + + if ($contents === false) { + throw new \RuntimeException('Unable to read stream contents'); + } + + return $contents; + } + + public function close() + { + if (isset($this->stream)) { + if (is_resource($this->stream)) { + fclose($this->stream); + } + $this->detach(); + } + } + + public function detach() + { + if (!isset($this->stream)) { + return null; + } + + $result = $this->stream; + unset($this->stream); + $this->size = $this->uri = null; + $this->readable = $this->writable = $this->seekable = false; + + return $result; + } + + public function getSize() + { + if ($this->size !== null) { + return $this->size; + } + + if (!isset($this->stream)) { + return null; + } + + // Clear the stat cache if the stream has a URI + if ($this->uri) { + clearstatcache(true, $this->uri); + } + + $stats = fstat($this->stream); + if (isset($stats['size'])) { + $this->size = $stats['size']; + return $this->size; + } + + return null; + } + + public function isReadable() + { + return $this->readable; + } + + public function isWritable() + { + return $this->writable; + } + + public function isSeekable() + { + return $this->seekable; + } + + public function eof() + { + return !$this->stream || feof($this->stream); + } + + public function tell() + { + $result = ftell($this->stream); + + if ($result === false) { + throw new \RuntimeException('Unable to determine stream position'); + } + + return $result; + } + + public function rewind() + { + $this->seek(0); + } + + public function seek($offset, $whence = SEEK_SET) + { + if (!$this->seekable) { + throw new \RuntimeException('Stream is not seekable'); + } elseif (fseek($this->stream, $offset, $whence) === -1) { + throw new \RuntimeException('Unable to seek to stream position ' + . $offset . ' with whence ' . var_export($whence, true)); + } + } + + public function read($length) + { + if (!$this->readable) { + throw new \RuntimeException('Cannot read from non-readable stream'); + } + if ($length < 0) { + throw new \RuntimeException('Length parameter cannot be negative'); + } + + if (0 === $length) { + return ''; + } + + $string = fread($this->stream, $length); + if (false === $string) { + throw new \RuntimeException('Unable to read from stream'); + } + + return $string; + } + + public function write($string) + { + if (!$this->writable) { + throw new \RuntimeException('Cannot write to a non-writable stream'); + } + + // We can't know the size after writing anything + $this->size = null; + $result = fwrite($this->stream, $string); + + if ($result === false) { + throw new \RuntimeException('Unable to write to stream'); + } + + return $result; + } + + public function getMetadata($key = null) + { + if (!isset($this->stream)) { + return $key ? null : []; + } elseif (!$key) { + return $this->customMetadata + stream_get_meta_data($this->stream); + } elseif (isset($this->customMetadata[$key])) { + return $this->customMetadata[$key]; + } + + $meta = stream_get_meta_data($this->stream); + + return isset($meta[$key]) ? $meta[$key] : null; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php new file mode 100644 index 0000000..daec6f5 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php @@ -0,0 +1,149 @@ +<?php +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\StreamInterface; + +/** + * Stream decorator trait + * @property StreamInterface stream + */ +trait StreamDecoratorTrait +{ + /** + * @param StreamInterface $stream Stream to decorate + */ + public function __construct(StreamInterface $stream) + { + $this->stream = $stream; + } + + /** + * Magic method used to create a new stream if streams are not added in + * the constructor of a decorator (e.g., LazyOpenStream). + * + * @param string $name Name of the property (allows "stream" only). + * + * @return StreamInterface + */ + public function __get($name) + { + if ($name == 'stream') { + $this->stream = $this->createStream(); + return $this->stream; + } + + throw new \UnexpectedValueException("$name not found on class"); + } + + public function __toString() + { + try { + if ($this->isSeekable()) { + $this->seek(0); + } + return $this->getContents(); + } catch (\Exception $e) { + // Really, PHP? https://bugs.php.net/bug.php?id=53648 + trigger_error('StreamDecorator::__toString exception: ' + . (string) $e, E_USER_ERROR); + return ''; + } + } + + public function getContents() + { + return copy_to_string($this); + } + + /** + * Allow decorators to implement custom methods + * + * @param string $method Missing method name + * @param array $args Method arguments + * + * @return mixed + */ + public function __call($method, array $args) + { + $result = call_user_func_array([$this->stream, $method], $args); + + // Always return the wrapped object if the result is a return $this + return $result === $this->stream ? $this : $result; + } + + public function close() + { + $this->stream->close(); + } + + public function getMetadata($key = null) + { + return $this->stream->getMetadata($key); + } + + public function detach() + { + return $this->stream->detach(); + } + + public function getSize() + { + return $this->stream->getSize(); + } + + public function eof() + { + return $this->stream->eof(); + } + + public function tell() + { + return $this->stream->tell(); + } + + public function isReadable() + { + return $this->stream->isReadable(); + } + + public function isWritable() + { + return $this->stream->isWritable(); + } + + public function isSeekable() + { + return $this->stream->isSeekable(); + } + + public function rewind() + { + $this->seek(0); + } + + public function seek($offset, $whence = SEEK_SET) + { + $this->stream->seek($offset, $whence); + } + + public function read($length) + { + return $this->stream->read($length); + } + + public function write($string) + { + return $this->stream->write($string); + } + + /** + * Implement in subclasses to dynamically create streams when requested. + * + * @return StreamInterface + * @throws \BadMethodCallException + */ + protected function createStream() + { + throw new \BadMethodCallException('Not implemented'); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/StreamWrapper.php b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/StreamWrapper.php new file mode 100644 index 0000000..cf7b223 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/StreamWrapper.php @@ -0,0 +1,121 @@ +<?php +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\StreamInterface; + +/** + * Converts Guzzle streams into PHP stream resources. + */ +class StreamWrapper +{ + /** @var resource */ + public $context; + + /** @var StreamInterface */ + private $stream; + + /** @var string r, r+, or w */ + private $mode; + + /** + * Returns a resource representing the stream. + * + * @param StreamInterface $stream The stream to get a resource for + * + * @return resource + * @throws \InvalidArgumentException if stream is not readable or writable + */ + public static function getResource(StreamInterface $stream) + { + self::register(); + + if ($stream->isReadable()) { + $mode = $stream->isWritable() ? 'r+' : 'r'; + } elseif ($stream->isWritable()) { + $mode = 'w'; + } else { + throw new \InvalidArgumentException('The stream must be readable, ' + . 'writable, or both.'); + } + + return fopen('guzzle://stream', $mode, null, stream_context_create([ + 'guzzle' => ['stream' => $stream] + ])); + } + + /** + * Registers the stream wrapper if needed + */ + public static function register() + { + if (!in_array('guzzle', stream_get_wrappers())) { + stream_wrapper_register('guzzle', __CLASS__); + } + } + + public function stream_open($path, $mode, $options, &$opened_path) + { + $options = stream_context_get_options($this->context); + + if (!isset($options['guzzle']['stream'])) { + return false; + } + + $this->mode = $mode; + $this->stream = $options['guzzle']['stream']; + + return true; + } + + public function stream_read($count) + { + return $this->stream->read($count); + } + + public function stream_write($data) + { + return (int) $this->stream->write($data); + } + + public function stream_tell() + { + return $this->stream->tell(); + } + + public function stream_eof() + { + return $this->stream->eof(); + } + + public function stream_seek($offset, $whence) + { + $this->stream->seek($offset, $whence); + + return true; + } + + public function stream_stat() + { + static $modeMap = [ + 'r' => 33060, + 'r+' => 33206, + 'w' => 33188 + ]; + + return [ + 'dev' => 0, + 'ino' => 0, + 'mode' => $modeMap[$this->mode], + 'nlink' => 0, + 'uid' => 0, + 'gid' => 0, + 'rdev' => 0, + 'size' => $this->stream->getSize() ?: 0, + 'atime' => 0, + 'mtime' => 0, + 'ctime' => 0, + 'blksize' => 0, + 'blocks' => 0 + ]; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/UploadedFile.php b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/UploadedFile.php new file mode 100644 index 0000000..e62bd5c --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/UploadedFile.php @@ -0,0 +1,316 @@ +<?php +namespace GuzzleHttp\Psr7; + +use InvalidArgumentException; +use Psr\Http\Message\StreamInterface; +use Psr\Http\Message\UploadedFileInterface; +use RuntimeException; + +class UploadedFile implements UploadedFileInterface +{ + /** + * @var int[] + */ + private static $errors = [ + UPLOAD_ERR_OK, + UPLOAD_ERR_INI_SIZE, + UPLOAD_ERR_FORM_SIZE, + UPLOAD_ERR_PARTIAL, + UPLOAD_ERR_NO_FILE, + UPLOAD_ERR_NO_TMP_DIR, + UPLOAD_ERR_CANT_WRITE, + UPLOAD_ERR_EXTENSION, + ]; + + /** + * @var string + */ + private $clientFilename; + + /** + * @var string + */ + private $clientMediaType; + + /** + * @var int + */ + private $error; + + /** + * @var null|string + */ + private $file; + + /** + * @var bool + */ + private $moved = false; + + /** + * @var int + */ + private $size; + + /** + * @var StreamInterface|null + */ + private $stream; + + /** + * @param StreamInterface|string|resource $streamOrFile + * @param int $size + * @param int $errorStatus + * @param string|null $clientFilename + * @param string|null $clientMediaType + */ + public function __construct( + $streamOrFile, + $size, + $errorStatus, + $clientFilename = null, + $clientMediaType = null + ) { + $this->setError($errorStatus); + $this->setSize($size); + $this->setClientFilename($clientFilename); + $this->setClientMediaType($clientMediaType); + + if ($this->isOk()) { + $this->setStreamOrFile($streamOrFile); + } + } + + /** + * Depending on the value set file or stream variable + * + * @param mixed $streamOrFile + * @throws InvalidArgumentException + */ + private function setStreamOrFile($streamOrFile) + { + if (is_string($streamOrFile)) { + $this->file = $streamOrFile; + } elseif (is_resource($streamOrFile)) { + $this->stream = new Stream($streamOrFile); + } elseif ($streamOrFile instanceof StreamInterface) { + $this->stream = $streamOrFile; + } else { + throw new InvalidArgumentException( + 'Invalid stream or file provided for UploadedFile' + ); + } + } + + /** + * @param int $error + * @throws InvalidArgumentException + */ + private function setError($error) + { + if (false === is_int($error)) { + throw new InvalidArgumentException( + 'Upload file error status must be an integer' + ); + } + + if (false === in_array($error, UploadedFile::$errors)) { + throw new InvalidArgumentException( + 'Invalid error status for UploadedFile' + ); + } + + $this->error = $error; + } + + /** + * @param int $size + * @throws InvalidArgumentException + */ + private function setSize($size) + { + if (false === is_int($size)) { + throw new InvalidArgumentException( + 'Upload file size must be an integer' + ); + } + + $this->size = $size; + } + + /** + * @param mixed $param + * @return boolean + */ + private function isStringOrNull($param) + { + return in_array(gettype($param), ['string', 'NULL']); + } + + /** + * @param mixed $param + * @return boolean + */ + private function isStringNotEmpty($param) + { + return is_string($param) && false === empty($param); + } + + /** + * @param string|null $clientFilename + * @throws InvalidArgumentException + */ + private function setClientFilename($clientFilename) + { + if (false === $this->isStringOrNull($clientFilename)) { + throw new InvalidArgumentException( + 'Upload file client filename must be a string or null' + ); + } + + $this->clientFilename = $clientFilename; + } + + /** + * @param string|null $clientMediaType + * @throws InvalidArgumentException + */ + private function setClientMediaType($clientMediaType) + { + if (false === $this->isStringOrNull($clientMediaType)) { + throw new InvalidArgumentException( + 'Upload file client media type must be a string or null' + ); + } + + $this->clientMediaType = $clientMediaType; + } + + /** + * Return true if there is no upload error + * + * @return boolean + */ + private function isOk() + { + return $this->error === UPLOAD_ERR_OK; + } + + /** + * @return boolean + */ + public function isMoved() + { + return $this->moved; + } + + /** + * @throws RuntimeException if is moved or not ok + */ + private function validateActive() + { + if (false === $this->isOk()) { + throw new RuntimeException('Cannot retrieve stream due to upload error'); + } + + if ($this->isMoved()) { + throw new RuntimeException('Cannot retrieve stream after it has already been moved'); + } + } + + /** + * {@inheritdoc} + * @throws RuntimeException if the upload was not successful. + */ + public function getStream() + { + $this->validateActive(); + + if ($this->stream instanceof StreamInterface) { + return $this->stream; + } + + return new LazyOpenStream($this->file, 'r+'); + } + + /** + * {@inheritdoc} + * + * @see http://php.net/is_uploaded_file + * @see http://php.net/move_uploaded_file + * @param string $targetPath Path to which to move the uploaded file. + * @throws RuntimeException if the upload was not successful. + * @throws InvalidArgumentException if the $path specified is invalid. + * @throws RuntimeException on any error during the move operation, or on + * the second or subsequent call to the method. + */ + public function moveTo($targetPath) + { + $this->validateActive(); + + if (false === $this->isStringNotEmpty($targetPath)) { + throw new InvalidArgumentException( + 'Invalid path provided for move operation; must be a non-empty string' + ); + } + + if ($this->file) { + $this->moved = php_sapi_name() == 'cli' + ? rename($this->file, $targetPath) + : move_uploaded_file($this->file, $targetPath); + } else { + copy_to_stream( + $this->getStream(), + new LazyOpenStream($targetPath, 'w') + ); + + $this->moved = true; + } + + if (false === $this->moved) { + throw new RuntimeException( + sprintf('Uploaded file could not be moved to %s', $targetPath) + ); + } + } + + /** + * {@inheritdoc} + * + * @return int|null The file size in bytes or null if unknown. + */ + public function getSize() + { + return $this->size; + } + + /** + * {@inheritdoc} + * + * @see http://php.net/manual/en/features.file-upload.errors.php + * @return int One of PHP's UPLOAD_ERR_XXX constants. + */ + public function getError() + { + return $this->error; + } + + /** + * {@inheritdoc} + * + * @return string|null The filename sent by the client or null if none + * was provided. + */ + public function getClientFilename() + { + return $this->clientFilename; + } + + /** + * {@inheritdoc} + */ + public function getClientMediaType() + { + return $this->clientMediaType; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/Uri.php b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/Uri.php new file mode 100644 index 0000000..f46c1db --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/Uri.php @@ -0,0 +1,702 @@ +<?php +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\UriInterface; + +/** + * PSR-7 URI implementation. + * + * @author Michael Dowling + * @author Tobias Schultze + * @author Matthew Weier O'Phinney + */ +class Uri implements UriInterface +{ + /** + * Absolute http and https URIs require a host per RFC 7230 Section 2.7 + * but in generic URIs the host can be empty. So for http(s) URIs + * we apply this default host when no host is given yet to form a + * valid URI. + */ + const HTTP_DEFAULT_HOST = 'localhost'; + + private static $defaultPorts = [ + 'http' => 80, + 'https' => 443, + 'ftp' => 21, + 'gopher' => 70, + 'nntp' => 119, + 'news' => 119, + 'telnet' => 23, + 'tn3270' => 23, + 'imap' => 143, + 'pop' => 110, + 'ldap' => 389, + ]; + + private static $charUnreserved = 'a-zA-Z0-9_\-\.~'; + private static $charSubDelims = '!\$&\'\(\)\*\+,;='; + private static $replaceQuery = ['=' => '%3D', '&' => '%26']; + + /** @var string Uri scheme. */ + private $scheme = ''; + + /** @var string Uri user info. */ + private $userInfo = ''; + + /** @var string Uri host. */ + private $host = ''; + + /** @var int|null Uri port. */ + private $port; + + /** @var string Uri path. */ + private $path = ''; + + /** @var string Uri query string. */ + private $query = ''; + + /** @var string Uri fragment. */ + private $fragment = ''; + + /** + * @param string $uri URI to parse + */ + public function __construct($uri = '') + { + // weak type check to also accept null until we can add scalar type hints + if ($uri != '') { + $parts = parse_url($uri); + if ($parts === false) { + throw new \InvalidArgumentException("Unable to parse URI: $uri"); + } + $this->applyParts($parts); + } + } + + public function __toString() + { + return self::composeComponents( + $this->scheme, + $this->getAuthority(), + $this->path, + $this->query, + $this->fragment + ); + } + + /** + * Composes a URI reference string from its various components. + * + * Usually this method does not need to be called manually but instead is used indirectly via + * `Psr\Http\Message\UriInterface::__toString`. + * + * PSR-7 UriInterface treats an empty component the same as a missing component as + * getQuery(), getFragment() etc. always return a string. This explains the slight + * difference to RFC 3986 Section 5.3. + * + * Another adjustment is that the authority separator is added even when the authority is missing/empty + * for the "file" scheme. This is because PHP stream functions like `file_get_contents` only work with + * `file:///myfile` but not with `file:/myfile` although they are equivalent according to RFC 3986. But + * `file:///` is the more common syntax for the file scheme anyway (Chrome for example redirects to + * that format). + * + * @param string $scheme + * @param string $authority + * @param string $path + * @param string $query + * @param string $fragment + * + * @return string + * + * @link https://tools.ietf.org/html/rfc3986#section-5.3 + */ + public static function composeComponents($scheme, $authority, $path, $query, $fragment) + { + $uri = ''; + + // weak type checks to also accept null until we can add scalar type hints + if ($scheme != '') { + $uri .= $scheme . ':'; + } + + if ($authority != ''|| $scheme === 'file') { + $uri .= '//' . $authority; + } + + $uri .= $path; + + if ($query != '') { + $uri .= '?' . $query; + } + + if ($fragment != '') { + $uri .= '#' . $fragment; + } + + return $uri; + } + + /** + * Whether the URI has the default port of the current scheme. + * + * `Psr\Http\Message\UriInterface::getPort` may return null or the standard port. This method can be used + * independently of the implementation. + * + * @param UriInterface $uri + * + * @return bool + */ + public static function isDefaultPort(UriInterface $uri) + { + return $uri->getPort() === null + || (isset(self::$defaultPorts[$uri->getScheme()]) && $uri->getPort() === self::$defaultPorts[$uri->getScheme()]); + } + + /** + * Whether the URI is absolute, i.e. it has a scheme. + * + * An instance of UriInterface can either be an absolute URI or a relative reference. This method returns true + * if it is the former. An absolute URI has a scheme. A relative reference is used to express a URI relative + * to another URI, the base URI. Relative references can be divided into several forms: + * - network-path references, e.g. '//example.com/path' + * - absolute-path references, e.g. '/path' + * - relative-path references, e.g. 'subpath' + * + * @param UriInterface $uri + * + * @return bool + * @see Uri::isNetworkPathReference + * @see Uri::isAbsolutePathReference + * @see Uri::isRelativePathReference + * @link https://tools.ietf.org/html/rfc3986#section-4 + */ + public static function isAbsolute(UriInterface $uri) + { + return $uri->getScheme() !== ''; + } + + /** + * Whether the URI is a network-path reference. + * + * A relative reference that begins with two slash characters is termed an network-path reference. + * + * @param UriInterface $uri + * + * @return bool + * @link https://tools.ietf.org/html/rfc3986#section-4.2 + */ + public static function isNetworkPathReference(UriInterface $uri) + { + return $uri->getScheme() === '' && $uri->getAuthority() !== ''; + } + + /** + * Whether the URI is a absolute-path reference. + * + * A relative reference that begins with a single slash character is termed an absolute-path reference. + * + * @param UriInterface $uri + * + * @return bool + * @link https://tools.ietf.org/html/rfc3986#section-4.2 + */ + public static function isAbsolutePathReference(UriInterface $uri) + { + return $uri->getScheme() === '' + && $uri->getAuthority() === '' + && isset($uri->getPath()[0]) + && $uri->getPath()[0] === '/'; + } + + /** + * Whether the URI is a relative-path reference. + * + * A relative reference that does not begin with a slash character is termed a relative-path reference. + * + * @param UriInterface $uri + * + * @return bool + * @link https://tools.ietf.org/html/rfc3986#section-4.2 + */ + public static function isRelativePathReference(UriInterface $uri) + { + return $uri->getScheme() === '' + && $uri->getAuthority() === '' + && (!isset($uri->getPath()[0]) || $uri->getPath()[0] !== '/'); + } + + /** + * Whether the URI is a same-document reference. + * + * A same-document reference refers to a URI that is, aside from its fragment + * component, identical to the base URI. When no base URI is given, only an empty + * URI reference (apart from its fragment) is considered a same-document reference. + * + * @param UriInterface $uri The URI to check + * @param UriInterface|null $base An optional base URI to compare against + * + * @return bool + * @link https://tools.ietf.org/html/rfc3986#section-4.4 + */ + public static function isSameDocumentReference(UriInterface $uri, UriInterface $base = null) + { + if ($base !== null) { + $uri = UriResolver::resolve($base, $uri); + + return ($uri->getScheme() === $base->getScheme()) + && ($uri->getAuthority() === $base->getAuthority()) + && ($uri->getPath() === $base->getPath()) + && ($uri->getQuery() === $base->getQuery()); + } + + return $uri->getScheme() === '' && $uri->getAuthority() === '' && $uri->getPath() === '' && $uri->getQuery() === ''; + } + + /** + * Removes dot segments from a path and returns the new path. + * + * @param string $path + * + * @return string + * + * @deprecated since version 1.4. Use UriResolver::removeDotSegments instead. + * @see UriResolver::removeDotSegments + */ + public static function removeDotSegments($path) + { + return UriResolver::removeDotSegments($path); + } + + /** + * Converts the relative URI into a new URI that is resolved against the base URI. + * + * @param UriInterface $base Base URI + * @param string|UriInterface $rel Relative URI + * + * @return UriInterface + * + * @deprecated since version 1.4. Use UriResolver::resolve instead. + * @see UriResolver::resolve + */ + public static function resolve(UriInterface $base, $rel) + { + if (!($rel instanceof UriInterface)) { + $rel = new self($rel); + } + + return UriResolver::resolve($base, $rel); + } + + /** + * Creates a new URI with a specific query string value removed. + * + * Any existing query string values that exactly match the provided key are + * removed. + * + * @param UriInterface $uri URI to use as a base. + * @param string $key Query string key to remove. + * + * @return UriInterface + */ + public static function withoutQueryValue(UriInterface $uri, $key) + { + $current = $uri->getQuery(); + if ($current === '') { + return $uri; + } + + $decodedKey = rawurldecode($key); + $result = array_filter(explode('&', $current), function ($part) use ($decodedKey) { + return rawurldecode(explode('=', $part)[0]) !== $decodedKey; + }); + + return $uri->withQuery(implode('&', $result)); + } + + /** + * Creates a new URI with a specific query string value. + * + * Any existing query string values that exactly match the provided key are + * removed and replaced with the given key value pair. + * + * A value of null will set the query string key without a value, e.g. "key" + * instead of "key=value". + * + * @param UriInterface $uri URI to use as a base. + * @param string $key Key to set. + * @param string|null $value Value to set + * + * @return UriInterface + */ + public static function withQueryValue(UriInterface $uri, $key, $value) + { + $current = $uri->getQuery(); + + if ($current === '') { + $result = []; + } else { + $decodedKey = rawurldecode($key); + $result = array_filter(explode('&', $current), function ($part) use ($decodedKey) { + return rawurldecode(explode('=', $part)[0]) !== $decodedKey; + }); + } + + // Query string separators ("=", "&") within the key or value need to be encoded + // (while preventing double-encoding) before setting the query string. All other + // chars that need percent-encoding will be encoded by withQuery(). + $key = strtr($key, self::$replaceQuery); + + if ($value !== null) { + $result[] = $key . '=' . strtr($value, self::$replaceQuery); + } else { + $result[] = $key; + } + + return $uri->withQuery(implode('&', $result)); + } + + /** + * Creates a URI from a hash of `parse_url` components. + * + * @param array $parts + * + * @return UriInterface + * @link http://php.net/manual/en/function.parse-url.php + * + * @throws \InvalidArgumentException If the components do not form a valid URI. + */ + public static function fromParts(array $parts) + { + $uri = new self(); + $uri->applyParts($parts); + $uri->validateState(); + + return $uri; + } + + public function getScheme() + { + return $this->scheme; + } + + public function getAuthority() + { + $authority = $this->host; + if ($this->userInfo !== '') { + $authority = $this->userInfo . '@' . $authority; + } + + if ($this->port !== null) { + $authority .= ':' . $this->port; + } + + return $authority; + } + + public function getUserInfo() + { + return $this->userInfo; + } + + public function getHost() + { + return $this->host; + } + + public function getPort() + { + return $this->port; + } + + public function getPath() + { + return $this->path; + } + + public function getQuery() + { + return $this->query; + } + + public function getFragment() + { + return $this->fragment; + } + + public function withScheme($scheme) + { + $scheme = $this->filterScheme($scheme); + + if ($this->scheme === $scheme) { + return $this; + } + + $new = clone $this; + $new->scheme = $scheme; + $new->removeDefaultPort(); + $new->validateState(); + + return $new; + } + + public function withUserInfo($user, $password = null) + { + $info = $user; + if ($password != '') { + $info .= ':' . $password; + } + + if ($this->userInfo === $info) { + return $this; + } + + $new = clone $this; + $new->userInfo = $info; + $new->validateState(); + + return $new; + } + + public function withHost($host) + { + $host = $this->filterHost($host); + + if ($this->host === $host) { + return $this; + } + + $new = clone $this; + $new->host = $host; + $new->validateState(); + + return $new; + } + + public function withPort($port) + { + $port = $this->filterPort($port); + + if ($this->port === $port) { + return $this; + } + + $new = clone $this; + $new->port = $port; + $new->removeDefaultPort(); + $new->validateState(); + + return $new; + } + + public function withPath($path) + { + $path = $this->filterPath($path); + + if ($this->path === $path) { + return $this; + } + + $new = clone $this; + $new->path = $path; + $new->validateState(); + + return $new; + } + + public function withQuery($query) + { + $query = $this->filterQueryAndFragment($query); + + if ($this->query === $query) { + return $this; + } + + $new = clone $this; + $new->query = $query; + + return $new; + } + + public function withFragment($fragment) + { + $fragment = $this->filterQueryAndFragment($fragment); + + if ($this->fragment === $fragment) { + return $this; + } + + $new = clone $this; + $new->fragment = $fragment; + + return $new; + } + + /** + * Apply parse_url parts to a URI. + * + * @param array $parts Array of parse_url parts to apply. + */ + private function applyParts(array $parts) + { + $this->scheme = isset($parts['scheme']) + ? $this->filterScheme($parts['scheme']) + : ''; + $this->userInfo = isset($parts['user']) ? $parts['user'] : ''; + $this->host = isset($parts['host']) + ? $this->filterHost($parts['host']) + : ''; + $this->port = isset($parts['port']) + ? $this->filterPort($parts['port']) + : null; + $this->path = isset($parts['path']) + ? $this->filterPath($parts['path']) + : ''; + $this->query = isset($parts['query']) + ? $this->filterQueryAndFragment($parts['query']) + : ''; + $this->fragment = isset($parts['fragment']) + ? $this->filterQueryAndFragment($parts['fragment']) + : ''; + if (isset($parts['pass'])) { + $this->userInfo .= ':' . $parts['pass']; + } + + $this->removeDefaultPort(); + } + + /** + * @param string $scheme + * + * @return string + * + * @throws \InvalidArgumentException If the scheme is invalid. + */ + private function filterScheme($scheme) + { + if (!is_string($scheme)) { + throw new \InvalidArgumentException('Scheme must be a string'); + } + + return strtolower($scheme); + } + + /** + * @param string $host + * + * @return string + * + * @throws \InvalidArgumentException If the host is invalid. + */ + private function filterHost($host) + { + if (!is_string($host)) { + throw new \InvalidArgumentException('Host must be a string'); + } + + return strtolower($host); + } + + /** + * @param int|null $port + * + * @return int|null + * + * @throws \InvalidArgumentException If the port is invalid. + */ + private function filterPort($port) + { + if ($port === null) { + return null; + } + + $port = (int) $port; + if (1 > $port || 0xffff < $port) { + throw new \InvalidArgumentException( + sprintf('Invalid port: %d. Must be between 1 and 65535', $port) + ); + } + + return $port; + } + + private function removeDefaultPort() + { + if ($this->port !== null && self::isDefaultPort($this)) { + $this->port = null; + } + } + + /** + * Filters the path of a URI + * + * @param string $path + * + * @return string + * + * @throws \InvalidArgumentException If the path is invalid. + */ + private function filterPath($path) + { + if (!is_string($path)) { + throw new \InvalidArgumentException('Path must be a string'); + } + + return preg_replace_callback( + '/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\/]++|%(?![A-Fa-f0-9]{2}))/', + [$this, 'rawurlencodeMatchZero'], + $path + ); + } + + /** + * Filters the query string or fragment of a URI. + * + * @param string $str + * + * @return string + * + * @throws \InvalidArgumentException If the query or fragment is invalid. + */ + private function filterQueryAndFragment($str) + { + if (!is_string($str)) { + throw new \InvalidArgumentException('Query and fragment must be a string'); + } + + return preg_replace_callback( + '/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\/\?]++|%(?![A-Fa-f0-9]{2}))/', + [$this, 'rawurlencodeMatchZero'], + $str + ); + } + + private function rawurlencodeMatchZero(array $match) + { + return rawurlencode($match[0]); + } + + private function validateState() + { + if ($this->host === '' && ($this->scheme === 'http' || $this->scheme === 'https')) { + $this->host = self::HTTP_DEFAULT_HOST; + } + + if ($this->getAuthority() === '') { + if (0 === strpos($this->path, '//')) { + throw new \InvalidArgumentException('The path of a URI without an authority must not start with two slashes "//"'); + } + if ($this->scheme === '' && false !== strpos(explode('/', $this->path, 2)[0], ':')) { + throw new \InvalidArgumentException('A relative URI must not have a path beginning with a segment containing a colon'); + } + } elseif (isset($this->path[0]) && $this->path[0] !== '/') { + @trigger_error( + 'The path of a URI with an authority must start with a slash "/" or be empty. Automagically fixing the URI ' . + 'by adding a leading slash to the path is deprecated since version 1.4 and will throw an exception instead.', + E_USER_DEPRECATED + ); + $this->path = '/'. $this->path; + //throw new \InvalidArgumentException('The path of a URI with an authority must start with a slash "/" or be empty'); + } + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/UriNormalizer.php b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/UriNormalizer.php new file mode 100644 index 0000000..384c29e --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/UriNormalizer.php @@ -0,0 +1,216 @@ +<?php +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\UriInterface; + +/** + * Provides methods to normalize and compare URIs. + * + * @author Tobias Schultze + * + * @link https://tools.ietf.org/html/rfc3986#section-6 + */ +final class UriNormalizer +{ + /** + * Default normalizations which only include the ones that preserve semantics. + * + * self::CAPITALIZE_PERCENT_ENCODING | self::DECODE_UNRESERVED_CHARACTERS | self::CONVERT_EMPTY_PATH | + * self::REMOVE_DEFAULT_HOST | self::REMOVE_DEFAULT_PORT | self::REMOVE_DOT_SEGMENTS + */ + const PRESERVING_NORMALIZATIONS = 63; + + /** + * All letters within a percent-encoding triplet (e.g., "%3A") are case-insensitive, and should be capitalized. + * + * Example: http://example.org/a%c2%b1b → http://example.org/a%C2%B1b + */ + const CAPITALIZE_PERCENT_ENCODING = 1; + + /** + * Decodes percent-encoded octets of unreserved characters. + * + * For consistency, percent-encoded octets in the ranges of ALPHA (%41–%5A and %61–%7A), DIGIT (%30–%39), + * hyphen (%2D), period (%2E), underscore (%5F), or tilde (%7E) should not be created by URI producers and, + * when found in a URI, should be decoded to their corresponding unreserved characters by URI normalizers. + * + * Example: http://example.org/%7Eusern%61me/ → http://example.org/~username/ + */ + const DECODE_UNRESERVED_CHARACTERS = 2; + + /** + * Converts the empty path to "/" for http and https URIs. + * + * Example: http://example.org → http://example.org/ + */ + const CONVERT_EMPTY_PATH = 4; + + /** + * Removes the default host of the given URI scheme from the URI. + * + * Only the "file" scheme defines the default host "localhost". + * All of `file:/myfile`, `file:///myfile`, and `file://localhost/myfile` + * are equivalent according to RFC 3986. The first format is not accepted + * by PHPs stream functions and thus already normalized implicitly to the + * second format in the Uri class. See `GuzzleHttp\Psr7\Uri::composeComponents`. + * + * Example: file://localhost/myfile → file:///myfile + */ + const REMOVE_DEFAULT_HOST = 8; + + /** + * Removes the default port of the given URI scheme from the URI. + * + * Example: http://example.org:80/ → http://example.org/ + */ + const REMOVE_DEFAULT_PORT = 16; + + /** + * Removes unnecessary dot-segments. + * + * Dot-segments in relative-path references are not removed as it would + * change the semantics of the URI reference. + * + * Example: http://example.org/../a/b/../c/./d.html → http://example.org/a/c/d.html + */ + const REMOVE_DOT_SEGMENTS = 32; + + /** + * Paths which include two or more adjacent slashes are converted to one. + * + * Webservers usually ignore duplicate slashes and treat those URIs equivalent. + * But in theory those URIs do not need to be equivalent. So this normalization + * may change the semantics. Encoded slashes (%2F) are not removed. + * + * Example: http://example.org//foo///bar.html → http://example.org/foo/bar.html + */ + const REMOVE_DUPLICATE_SLASHES = 64; + + /** + * Sort query parameters with their values in alphabetical order. + * + * However, the order of parameters in a URI may be significant (this is not defined by the standard). + * So this normalization is not safe and may change the semantics of the URI. + * + * Example: ?lang=en&article=fred → ?article=fred&lang=en + * + * Note: The sorting is neither locale nor Unicode aware (the URI query does not get decoded at all) as the + * purpose is to be able to compare URIs in a reproducible way, not to have the params sorted perfectly. + */ + const SORT_QUERY_PARAMETERS = 128; + + /** + * Returns a normalized URI. + * + * The scheme and host component are already normalized to lowercase per PSR-7 UriInterface. + * This methods adds additional normalizations that can be configured with the $flags parameter. + * + * PSR-7 UriInterface cannot distinguish between an empty component and a missing component as + * getQuery(), getFragment() etc. always return a string. This means the URIs "/?#" and "/" are + * treated equivalent which is not necessarily true according to RFC 3986. But that difference + * is highly uncommon in reality. So this potential normalization is implied in PSR-7 as well. + * + * @param UriInterface $uri The URI to normalize + * @param int $flags A bitmask of normalizations to apply, see constants + * + * @return UriInterface The normalized URI + * @link https://tools.ietf.org/html/rfc3986#section-6.2 + */ + public static function normalize(UriInterface $uri, $flags = self::PRESERVING_NORMALIZATIONS) + { + if ($flags & self::CAPITALIZE_PERCENT_ENCODING) { + $uri = self::capitalizePercentEncoding($uri); + } + + if ($flags & self::DECODE_UNRESERVED_CHARACTERS) { + $uri = self::decodeUnreservedCharacters($uri); + } + + if ($flags & self::CONVERT_EMPTY_PATH && $uri->getPath() === '' && + ($uri->getScheme() === 'http' || $uri->getScheme() === 'https') + ) { + $uri = $uri->withPath('/'); + } + + if ($flags & self::REMOVE_DEFAULT_HOST && $uri->getScheme() === 'file' && $uri->getHost() === 'localhost') { + $uri = $uri->withHost(''); + } + + if ($flags & self::REMOVE_DEFAULT_PORT && $uri->getPort() !== null && Uri::isDefaultPort($uri)) { + $uri = $uri->withPort(null); + } + + if ($flags & self::REMOVE_DOT_SEGMENTS && !Uri::isRelativePathReference($uri)) { + $uri = $uri->withPath(UriResolver::removeDotSegments($uri->getPath())); + } + + if ($flags & self::REMOVE_DUPLICATE_SLASHES) { + $uri = $uri->withPath(preg_replace('#//++#', '/', $uri->getPath())); + } + + if ($flags & self::SORT_QUERY_PARAMETERS && $uri->getQuery() !== '') { + $queryKeyValues = explode('&', $uri->getQuery()); + sort($queryKeyValues); + $uri = $uri->withQuery(implode('&', $queryKeyValues)); + } + + return $uri; + } + + /** + * Whether two URIs can be considered equivalent. + * + * Both URIs are normalized automatically before comparison with the given $normalizations bitmask. The method also + * accepts relative URI references and returns true when they are equivalent. This of course assumes they will be + * resolved against the same base URI. If this is not the case, determination of equivalence or difference of + * relative references does not mean anything. + * + * @param UriInterface $uri1 An URI to compare + * @param UriInterface $uri2 An URI to compare + * @param int $normalizations A bitmask of normalizations to apply, see constants + * + * @return bool + * @link https://tools.ietf.org/html/rfc3986#section-6.1 + */ + public static function isEquivalent(UriInterface $uri1, UriInterface $uri2, $normalizations = self::PRESERVING_NORMALIZATIONS) + { + return (string) self::normalize($uri1, $normalizations) === (string) self::normalize($uri2, $normalizations); + } + + private static function capitalizePercentEncoding(UriInterface $uri) + { + $regex = '/(?:%[A-Fa-f0-9]{2})++/'; + + $callback = function (array $match) { + return strtoupper($match[0]); + }; + + return + $uri->withPath( + preg_replace_callback($regex, $callback, $uri->getPath()) + )->withQuery( + preg_replace_callback($regex, $callback, $uri->getQuery()) + ); + } + + private static function decodeUnreservedCharacters(UriInterface $uri) + { + $regex = '/%(?:2D|2E|5F|7E|3[0-9]|[46][1-9A-F]|[57][0-9A])/i'; + + $callback = function (array $match) { + return rawurldecode($match[0]); + }; + + return + $uri->withPath( + preg_replace_callback($regex, $callback, $uri->getPath()) + )->withQuery( + preg_replace_callback($regex, $callback, $uri->getQuery()) + ); + } + + private function __construct() + { + // cannot be instantiated + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/UriResolver.php b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/UriResolver.php new file mode 100644 index 0000000..c1cb8a2 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/UriResolver.php @@ -0,0 +1,219 @@ +<?php +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\UriInterface; + +/** + * Resolves a URI reference in the context of a base URI and the opposite way. + * + * @author Tobias Schultze + * + * @link https://tools.ietf.org/html/rfc3986#section-5 + */ +final class UriResolver +{ + /** + * Removes dot segments from a path and returns the new path. + * + * @param string $path + * + * @return string + * @link http://tools.ietf.org/html/rfc3986#section-5.2.4 + */ + public static function removeDotSegments($path) + { + if ($path === '' || $path === '/') { + return $path; + } + + $results = []; + $segments = explode('/', $path); + foreach ($segments as $segment) { + if ($segment === '..') { + array_pop($results); + } elseif ($segment !== '.') { + $results[] = $segment; + } + } + + $newPath = implode('/', $results); + + if ($path[0] === '/' && (!isset($newPath[0]) || $newPath[0] !== '/')) { + // Re-add the leading slash if necessary for cases like "/.." + $newPath = '/' . $newPath; + } elseif ($newPath !== '' && ($segment === '.' || $segment === '..')) { + // Add the trailing slash if necessary + // If newPath is not empty, then $segment must be set and is the last segment from the foreach + $newPath .= '/'; + } + + return $newPath; + } + + /** + * Converts the relative URI into a new URI that is resolved against the base URI. + * + * @param UriInterface $base Base URI + * @param UriInterface $rel Relative URI + * + * @return UriInterface + * @link http://tools.ietf.org/html/rfc3986#section-5.2 + */ + public static function resolve(UriInterface $base, UriInterface $rel) + { + if ((string) $rel === '') { + // we can simply return the same base URI instance for this same-document reference + return $base; + } + + if ($rel->getScheme() != '') { + return $rel->withPath(self::removeDotSegments($rel->getPath())); + } + + if ($rel->getAuthority() != '') { + $targetAuthority = $rel->getAuthority(); + $targetPath = self::removeDotSegments($rel->getPath()); + $targetQuery = $rel->getQuery(); + } else { + $targetAuthority = $base->getAuthority(); + if ($rel->getPath() === '') { + $targetPath = $base->getPath(); + $targetQuery = $rel->getQuery() != '' ? $rel->getQuery() : $base->getQuery(); + } else { + if ($rel->getPath()[0] === '/') { + $targetPath = $rel->getPath(); + } else { + if ($targetAuthority != '' && $base->getPath() === '') { + $targetPath = '/' . $rel->getPath(); + } else { + $lastSlashPos = strrpos($base->getPath(), '/'); + if ($lastSlashPos === false) { + $targetPath = $rel->getPath(); + } else { + $targetPath = substr($base->getPath(), 0, $lastSlashPos + 1) . $rel->getPath(); + } + } + } + $targetPath = self::removeDotSegments($targetPath); + $targetQuery = $rel->getQuery(); + } + } + + return new Uri(Uri::composeComponents( + $base->getScheme(), + $targetAuthority, + $targetPath, + $targetQuery, + $rel->getFragment() + )); + } + + /** + * Returns the target URI as a relative reference from the base URI. + * + * This method is the counterpart to resolve(): + * + * (string) $target === (string) UriResolver::resolve($base, UriResolver::relativize($base, $target)) + * + * One use-case is to use the current request URI as base URI and then generate relative links in your documents + * to reduce the document size or offer self-contained downloadable document archives. + * + * $base = new Uri('http://example.com/a/b/'); + * echo UriResolver::relativize($base, new Uri('http://example.com/a/b/c')); // prints 'c'. + * echo UriResolver::relativize($base, new Uri('http://example.com/a/x/y')); // prints '../x/y'. + * echo UriResolver::relativize($base, new Uri('http://example.com/a/b/?q')); // prints '?q'. + * echo UriResolver::relativize($base, new Uri('http://example.org/a/b/')); // prints '//example.org/a/b/'. + * + * This method also accepts a target that is already relative and will try to relativize it further. Only a + * relative-path reference will be returned as-is. + * + * echo UriResolver::relativize($base, new Uri('/a/b/c')); // prints 'c' as well + * + * @param UriInterface $base Base URI + * @param UriInterface $target Target URI + * + * @return UriInterface The relative URI reference + */ + public static function relativize(UriInterface $base, UriInterface $target) + { + if ($target->getScheme() !== '' && + ($base->getScheme() !== $target->getScheme() || $target->getAuthority() === '' && $base->getAuthority() !== '') + ) { + return $target; + } + + if (Uri::isRelativePathReference($target)) { + // As the target is already highly relative we return it as-is. It would be possible to resolve + // the target with `$target = self::resolve($base, $target);` and then try make it more relative + // by removing a duplicate query. But let's not do that automatically. + return $target; + } + + if ($target->getAuthority() !== '' && $base->getAuthority() !== $target->getAuthority()) { + return $target->withScheme(''); + } + + // We must remove the path before removing the authority because if the path starts with two slashes, the URI + // would turn invalid. And we also cannot set a relative path before removing the authority, as that is also + // invalid. + $emptyPathUri = $target->withScheme('')->withPath('')->withUserInfo('')->withPort(null)->withHost(''); + + if ($base->getPath() !== $target->getPath()) { + return $emptyPathUri->withPath(self::getRelativePath($base, $target)); + } + + if ($base->getQuery() === $target->getQuery()) { + // Only the target fragment is left. And it must be returned even if base and target fragment are the same. + return $emptyPathUri->withQuery(''); + } + + // If the base URI has a query but the target has none, we cannot return an empty path reference as it would + // inherit the base query component when resolving. + if ($target->getQuery() === '') { + $segments = explode('/', $target->getPath()); + $lastSegment = end($segments); + + return $emptyPathUri->withPath($lastSegment === '' ? './' : $lastSegment); + } + + return $emptyPathUri; + } + + private static function getRelativePath(UriInterface $base, UriInterface $target) + { + $sourceSegments = explode('/', $base->getPath()); + $targetSegments = explode('/', $target->getPath()); + array_pop($sourceSegments); + $targetLastSegment = array_pop($targetSegments); + foreach ($sourceSegments as $i => $segment) { + if (isset($targetSegments[$i]) && $segment === $targetSegments[$i]) { + unset($sourceSegments[$i], $targetSegments[$i]); + } else { + break; + } + } + $targetSegments[] = $targetLastSegment; + $relativePath = str_repeat('../', count($sourceSegments)) . implode('/', $targetSegments); + + // A reference to am empty last segment or an empty first sub-segment must be prefixed with "./". + // This also applies to a segment with a colon character (e.g., "file:colon") that cannot be used + // as the first segment of a relative-path reference, as it would be mistaken for a scheme name. + if ('' === $relativePath || false !== strpos(explode('/', $relativePath, 2)[0], ':')) { + $relativePath = "./$relativePath"; + } elseif ('/' === $relativePath[0]) { + if ($base->getAuthority() != '' && $base->getPath() === '') { + // In this case an extra slash is added by resolve() automatically. So we must not add one here. + $relativePath = ".$relativePath"; + } else { + $relativePath = "./$relativePath"; + } + } + + return $relativePath; + } + + private function __construct() + { + // cannot be instantiated + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/functions.php b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/functions.php new file mode 100644 index 0000000..e40348d --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/functions.php @@ -0,0 +1,828 @@ +<?php +namespace GuzzleHttp\Psr7; + +use Psr\Http\Message\MessageInterface; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\ServerRequestInterface; +use Psr\Http\Message\StreamInterface; +use Psr\Http\Message\UriInterface; + +/** + * Returns the string representation of an HTTP message. + * + * @param MessageInterface $message Message to convert to a string. + * + * @return string + */ +function str(MessageInterface $message) +{ + if ($message instanceof RequestInterface) { + $msg = trim($message->getMethod() . ' ' + . $message->getRequestTarget()) + . ' HTTP/' . $message->getProtocolVersion(); + if (!$message->hasHeader('host')) { + $msg .= "\r\nHost: " . $message->getUri()->getHost(); + } + } elseif ($message instanceof ResponseInterface) { + $msg = 'HTTP/' . $message->getProtocolVersion() . ' ' + . $message->getStatusCode() . ' ' + . $message->getReasonPhrase(); + } else { + throw new \InvalidArgumentException('Unknown message type'); + } + + foreach ($message->getHeaders() as $name => $values) { + $msg .= "\r\n{$name}: " . implode(', ', $values); + } + + return "{$msg}\r\n\r\n" . $message->getBody(); +} + +/** + * Returns a UriInterface for the given value. + * + * This function accepts a string or {@see Psr\Http\Message\UriInterface} and + * returns a UriInterface for the given value. If the value is already a + * `UriInterface`, it is returned as-is. + * + * @param string|UriInterface $uri + * + * @return UriInterface + * @throws \InvalidArgumentException + */ +function uri_for($uri) +{ + if ($uri instanceof UriInterface) { + return $uri; + } elseif (is_string($uri)) { + return new Uri($uri); + } + + throw new \InvalidArgumentException('URI must be a string or UriInterface'); +} + +/** + * Create a new stream based on the input type. + * + * Options is an associative array that can contain the following keys: + * - metadata: Array of custom metadata. + * - size: Size of the stream. + * + * @param resource|string|null|int|float|bool|StreamInterface|callable $resource Entity body data + * @param array $options Additional options + * + * @return Stream + * @throws \InvalidArgumentException if the $resource arg is not valid. + */ +function stream_for($resource = '', array $options = []) +{ + if (is_scalar($resource)) { + $stream = fopen('php://temp', 'r+'); + if ($resource !== '') { + fwrite($stream, $resource); + fseek($stream, 0); + } + return new Stream($stream, $options); + } + + switch (gettype($resource)) { + case 'resource': + return new Stream($resource, $options); + case 'object': + if ($resource instanceof StreamInterface) { + return $resource; + } elseif ($resource instanceof \Iterator) { + return new PumpStream(function () use ($resource) { + if (!$resource->valid()) { + return false; + } + $result = $resource->current(); + $resource->next(); + return $result; + }, $options); + } elseif (method_exists($resource, '__toString')) { + return stream_for((string) $resource, $options); + } + break; + case 'NULL': + return new Stream(fopen('php://temp', 'r+'), $options); + } + + if (is_callable($resource)) { + return new PumpStream($resource, $options); + } + + throw new \InvalidArgumentException('Invalid resource type: ' . gettype($resource)); +} + +/** + * Parse an array of header values containing ";" separated data into an + * array of associative arrays representing the header key value pair + * data of the header. When a parameter does not contain a value, but just + * contains a key, this function will inject a key with a '' string value. + * + * @param string|array $header Header to parse into components. + * + * @return array Returns the parsed header values. + */ +function parse_header($header) +{ + static $trimmed = "\"' \n\t\r"; + $params = $matches = []; + + foreach (normalize_header($header) as $val) { + $part = []; + foreach (preg_split('/;(?=([^"]*"[^"]*")*[^"]*$)/', $val) as $kvp) { + if (preg_match_all('/<[^>]+>|[^=]+/', $kvp, $matches)) { + $m = $matches[0]; + if (isset($m[1])) { + $part[trim($m[0], $trimmed)] = trim($m[1], $trimmed); + } else { + $part[] = trim($m[0], $trimmed); + } + } + } + if ($part) { + $params[] = $part; + } + } + + return $params; +} + +/** + * Converts an array of header values that may contain comma separated + * headers into an array of headers with no comma separated values. + * + * @param string|array $header Header to normalize. + * + * @return array Returns the normalized header field values. + */ +function normalize_header($header) +{ + if (!is_array($header)) { + return array_map('trim', explode(',', $header)); + } + + $result = []; + foreach ($header as $value) { + foreach ((array) $value as $v) { + if (strpos($v, ',') === false) { + $result[] = $v; + continue; + } + foreach (preg_split('/,(?=([^"]*"[^"]*")*[^"]*$)/', $v) as $vv) { + $result[] = trim($vv); + } + } + } + + return $result; +} + +/** + * Clone and modify a request with the given changes. + * + * The changes can be one of: + * - method: (string) Changes the HTTP method. + * - set_headers: (array) Sets the given headers. + * - remove_headers: (array) Remove the given headers. + * - body: (mixed) Sets the given body. + * - uri: (UriInterface) Set the URI. + * - query: (string) Set the query string value of the URI. + * - version: (string) Set the protocol version. + * + * @param RequestInterface $request Request to clone and modify. + * @param array $changes Changes to apply. + * + * @return RequestInterface + */ +function modify_request(RequestInterface $request, array $changes) +{ + if (!$changes) { + return $request; + } + + $headers = $request->getHeaders(); + + if (!isset($changes['uri'])) { + $uri = $request->getUri(); + } else { + // Remove the host header if one is on the URI + if ($host = $changes['uri']->getHost()) { + $changes['set_headers']['Host'] = $host; + + if ($port = $changes['uri']->getPort()) { + $standardPorts = ['http' => 80, 'https' => 443]; + $scheme = $changes['uri']->getScheme(); + if (isset($standardPorts[$scheme]) && $port != $standardPorts[$scheme]) { + $changes['set_headers']['Host'] .= ':'.$port; + } + } + } + $uri = $changes['uri']; + } + + if (!empty($changes['remove_headers'])) { + $headers = _caseless_remove($changes['remove_headers'], $headers); + } + + if (!empty($changes['set_headers'])) { + $headers = _caseless_remove(array_keys($changes['set_headers']), $headers); + $headers = $changes['set_headers'] + $headers; + } + + if (isset($changes['query'])) { + $uri = $uri->withQuery($changes['query']); + } + + if ($request instanceof ServerRequestInterface) { + return new ServerRequest( + isset($changes['method']) ? $changes['method'] : $request->getMethod(), + $uri, + $headers, + isset($changes['body']) ? $changes['body'] : $request->getBody(), + isset($changes['version']) + ? $changes['version'] + : $request->getProtocolVersion(), + $request->getServerParams() + ); + } + + return new Request( + isset($changes['method']) ? $changes['method'] : $request->getMethod(), + $uri, + $headers, + isset($changes['body']) ? $changes['body'] : $request->getBody(), + isset($changes['version']) + ? $changes['version'] + : $request->getProtocolVersion() + ); +} + +/** + * Attempts to rewind a message body and throws an exception on failure. + * + * The body of the message will only be rewound if a call to `tell()` returns a + * value other than `0`. + * + * @param MessageInterface $message Message to rewind + * + * @throws \RuntimeException + */ +function rewind_body(MessageInterface $message) +{ + $body = $message->getBody(); + + if ($body->tell()) { + $body->rewind(); + } +} + +/** + * Safely opens a PHP stream resource using a filename. + * + * When fopen fails, PHP normally raises a warning. This function adds an + * error handler that checks for errors and throws an exception instead. + * + * @param string $filename File to open + * @param string $mode Mode used to open the file + * + * @return resource + * @throws \RuntimeException if the file cannot be opened + */ +function try_fopen($filename, $mode) +{ + $ex = null; + set_error_handler(function () use ($filename, $mode, &$ex) { + $ex = new \RuntimeException(sprintf( + 'Unable to open %s using mode %s: %s', + $filename, + $mode, + func_get_args()[1] + )); + }); + + $handle = fopen($filename, $mode); + restore_error_handler(); + + if ($ex) { + /** @var $ex \RuntimeException */ + throw $ex; + } + + return $handle; +} + +/** + * Copy the contents of a stream into a string until the given number of + * bytes have been read. + * + * @param StreamInterface $stream Stream to read + * @param int $maxLen Maximum number of bytes to read. Pass -1 + * to read the entire stream. + * @return string + * @throws \RuntimeException on error. + */ +function copy_to_string(StreamInterface $stream, $maxLen = -1) +{ + $buffer = ''; + + if ($maxLen === -1) { + while (!$stream->eof()) { + $buf = $stream->read(1048576); + // Using a loose equality here to match on '' and false. + if ($buf == null) { + break; + } + $buffer .= $buf; + } + return $buffer; + } + + $len = 0; + while (!$stream->eof() && $len < $maxLen) { + $buf = $stream->read($maxLen - $len); + // Using a loose equality here to match on '' and false. + if ($buf == null) { + break; + } + $buffer .= $buf; + $len = strlen($buffer); + } + + return $buffer; +} + +/** + * Copy the contents of a stream into another stream until the given number + * of bytes have been read. + * + * @param StreamInterface $source Stream to read from + * @param StreamInterface $dest Stream to write to + * @param int $maxLen Maximum number of bytes to read. Pass -1 + * to read the entire stream. + * + * @throws \RuntimeException on error. + */ +function copy_to_stream( + StreamInterface $source, + StreamInterface $dest, + $maxLen = -1 +) { + $bufferSize = 8192; + + if ($maxLen === -1) { + while (!$source->eof()) { + if (!$dest->write($source->read($bufferSize))) { + break; + } + } + } else { + $remaining = $maxLen; + while ($remaining > 0 && !$source->eof()) { + $buf = $source->read(min($bufferSize, $remaining)); + $len = strlen($buf); + if (!$len) { + break; + } + $remaining -= $len; + $dest->write($buf); + } + } +} + +/** + * Calculate a hash of a Stream + * + * @param StreamInterface $stream Stream to calculate the hash for + * @param string $algo Hash algorithm (e.g. md5, crc32, etc) + * @param bool $rawOutput Whether or not to use raw output + * + * @return string Returns the hash of the stream + * @throws \RuntimeException on error. + */ +function hash( + StreamInterface $stream, + $algo, + $rawOutput = false +) { + $pos = $stream->tell(); + + if ($pos > 0) { + $stream->rewind(); + } + + $ctx = hash_init($algo); + while (!$stream->eof()) { + hash_update($ctx, $stream->read(1048576)); + } + + $out = hash_final($ctx, (bool) $rawOutput); + $stream->seek($pos); + + return $out; +} + +/** + * Read a line from the stream up to the maximum allowed buffer length + * + * @param StreamInterface $stream Stream to read from + * @param int $maxLength Maximum buffer length + * + * @return string|bool + */ +function readline(StreamInterface $stream, $maxLength = null) +{ + $buffer = ''; + $size = 0; + + while (!$stream->eof()) { + // Using a loose equality here to match on '' and false. + if (null == ($byte = $stream->read(1))) { + return $buffer; + } + $buffer .= $byte; + // Break when a new line is found or the max length - 1 is reached + if ($byte === "\n" || ++$size === $maxLength - 1) { + break; + } + } + + return $buffer; +} + +/** + * Parses a request message string into a request object. + * + * @param string $message Request message string. + * + * @return Request + */ +function parse_request($message) +{ + $data = _parse_message($message); + $matches = []; + if (!preg_match('/^[\S]+\s+([a-zA-Z]+:\/\/|\/).*/', $data['start-line'], $matches)) { + throw new \InvalidArgumentException('Invalid request string'); + } + $parts = explode(' ', $data['start-line'], 3); + $version = isset($parts[2]) ? explode('/', $parts[2])[1] : '1.1'; + + $request = new Request( + $parts[0], + $matches[1] === '/' ? _parse_request_uri($parts[1], $data['headers']) : $parts[1], + $data['headers'], + $data['body'], + $version + ); + + return $matches[1] === '/' ? $request : $request->withRequestTarget($parts[1]); +} + +/** + * Parses a response message string into a response object. + * + * @param string $message Response message string. + * + * @return Response + */ +function parse_response($message) +{ + $data = _parse_message($message); + // According to https://tools.ietf.org/html/rfc7230#section-3.1.2 the space + // between status-code and reason-phrase is required. But browsers accept + // responses without space and reason as well. + if (!preg_match('/^HTTP\/.* [0-9]{3}( .*|$)/', $data['start-line'])) { + throw new \InvalidArgumentException('Invalid response string'); + } + $parts = explode(' ', $data['start-line'], 3); + + return new Response( + $parts[1], + $data['headers'], + $data['body'], + explode('/', $parts[0])[1], + isset($parts[2]) ? $parts[2] : null + ); +} + +/** + * Parse a query string into an associative array. + * + * If multiple values are found for the same key, the value of that key + * value pair will become an array. This function does not parse nested + * PHP style arrays into an associative array (e.g., foo[a]=1&foo[b]=2 will + * be parsed into ['foo[a]' => '1', 'foo[b]' => '2']). + * + * @param string $str Query string to parse + * @param bool|string $urlEncoding How the query string is encoded + * + * @return array + */ +function parse_query($str, $urlEncoding = true) +{ + $result = []; + + if ($str === '') { + return $result; + } + + if ($urlEncoding === true) { + $decoder = function ($value) { + return rawurldecode(str_replace('+', ' ', $value)); + }; + } elseif ($urlEncoding == PHP_QUERY_RFC3986) { + $decoder = 'rawurldecode'; + } elseif ($urlEncoding == PHP_QUERY_RFC1738) { + $decoder = 'urldecode'; + } else { + $decoder = function ($str) { return $str; }; + } + + foreach (explode('&', $str) as $kvp) { + $parts = explode('=', $kvp, 2); + $key = $decoder($parts[0]); + $value = isset($parts[1]) ? $decoder($parts[1]) : null; + if (!isset($result[$key])) { + $result[$key] = $value; + } else { + if (!is_array($result[$key])) { + $result[$key] = [$result[$key]]; + } + $result[$key][] = $value; + } + } + + return $result; +} + +/** + * Build a query string from an array of key value pairs. + * + * This function can use the return value of parse_query() to build a query + * string. This function does not modify the provided keys when an array is + * encountered (like http_build_query would). + * + * @param array $params Query string parameters. + * @param int|false $encoding Set to false to not encode, PHP_QUERY_RFC3986 + * to encode using RFC3986, or PHP_QUERY_RFC1738 + * to encode using RFC1738. + * @return string + */ +function build_query(array $params, $encoding = PHP_QUERY_RFC3986) +{ + if (!$params) { + return ''; + } + + if ($encoding === false) { + $encoder = function ($str) { return $str; }; + } elseif ($encoding === PHP_QUERY_RFC3986) { + $encoder = 'rawurlencode'; + } elseif ($encoding === PHP_QUERY_RFC1738) { + $encoder = 'urlencode'; + } else { + throw new \InvalidArgumentException('Invalid type'); + } + + $qs = ''; + foreach ($params as $k => $v) { + $k = $encoder($k); + if (!is_array($v)) { + $qs .= $k; + if ($v !== null) { + $qs .= '=' . $encoder($v); + } + $qs .= '&'; + } else { + foreach ($v as $vv) { + $qs .= $k; + if ($vv !== null) { + $qs .= '=' . $encoder($vv); + } + $qs .= '&'; + } + } + } + + return $qs ? (string) substr($qs, 0, -1) : ''; +} + +/** + * Determines the mimetype of a file by looking at its extension. + * + * @param $filename + * + * @return null|string + */ +function mimetype_from_filename($filename) +{ + return mimetype_from_extension(pathinfo($filename, PATHINFO_EXTENSION)); +} + +/** + * Maps a file extensions to a mimetype. + * + * @param $extension string The file extension. + * + * @return string|null + * @link http://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x/conf/mime.types + */ +function mimetype_from_extension($extension) +{ + static $mimetypes = [ + '7z' => 'application/x-7z-compressed', + 'aac' => 'audio/x-aac', + 'ai' => 'application/postscript', + 'aif' => 'audio/x-aiff', + 'asc' => 'text/plain', + 'asf' => 'video/x-ms-asf', + 'atom' => 'application/atom+xml', + 'avi' => 'video/x-msvideo', + 'bmp' => 'image/bmp', + 'bz2' => 'application/x-bzip2', + 'cer' => 'application/pkix-cert', + 'crl' => 'application/pkix-crl', + 'crt' => 'application/x-x509-ca-cert', + 'css' => 'text/css', + 'csv' => 'text/csv', + 'cu' => 'application/cu-seeme', + 'deb' => 'application/x-debian-package', + 'doc' => 'application/msword', + 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'dvi' => 'application/x-dvi', + 'eot' => 'application/vnd.ms-fontobject', + 'eps' => 'application/postscript', + 'epub' => 'application/epub+zip', + 'etx' => 'text/x-setext', + 'flac' => 'audio/flac', + 'flv' => 'video/x-flv', + 'gif' => 'image/gif', + 'gz' => 'application/gzip', + 'htm' => 'text/html', + 'html' => 'text/html', + 'ico' => 'image/x-icon', + 'ics' => 'text/calendar', + 'ini' => 'text/plain', + 'iso' => 'application/x-iso9660-image', + 'jar' => 'application/java-archive', + 'jpe' => 'image/jpeg', + 'jpeg' => 'image/jpeg', + 'jpg' => 'image/jpeg', + 'js' => 'text/javascript', + 'json' => 'application/json', + 'latex' => 'application/x-latex', + 'log' => 'text/plain', + 'm4a' => 'audio/mp4', + 'm4v' => 'video/mp4', + 'mid' => 'audio/midi', + 'midi' => 'audio/midi', + 'mov' => 'video/quicktime', + 'mp3' => 'audio/mpeg', + 'mp4' => 'video/mp4', + 'mp4a' => 'audio/mp4', + 'mp4v' => 'video/mp4', + 'mpe' => 'video/mpeg', + 'mpeg' => 'video/mpeg', + 'mpg' => 'video/mpeg', + 'mpg4' => 'video/mp4', + 'oga' => 'audio/ogg', + 'ogg' => 'audio/ogg', + 'ogv' => 'video/ogg', + 'ogx' => 'application/ogg', + 'pbm' => 'image/x-portable-bitmap', + 'pdf' => 'application/pdf', + 'pgm' => 'image/x-portable-graymap', + 'png' => 'image/png', + 'pnm' => 'image/x-portable-anymap', + 'ppm' => 'image/x-portable-pixmap', + 'ppt' => 'application/vnd.ms-powerpoint', + 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'ps' => 'application/postscript', + 'qt' => 'video/quicktime', + 'rar' => 'application/x-rar-compressed', + 'ras' => 'image/x-cmu-raster', + 'rss' => 'application/rss+xml', + 'rtf' => 'application/rtf', + 'sgm' => 'text/sgml', + 'sgml' => 'text/sgml', + 'svg' => 'image/svg+xml', + 'swf' => 'application/x-shockwave-flash', + 'tar' => 'application/x-tar', + 'tif' => 'image/tiff', + 'tiff' => 'image/tiff', + 'torrent' => 'application/x-bittorrent', + 'ttf' => 'application/x-font-ttf', + 'txt' => 'text/plain', + 'wav' => 'audio/x-wav', + 'webm' => 'video/webm', + 'wma' => 'audio/x-ms-wma', + 'wmv' => 'video/x-ms-wmv', + 'woff' => 'application/x-font-woff', + 'wsdl' => 'application/wsdl+xml', + 'xbm' => 'image/x-xbitmap', + 'xls' => 'application/vnd.ms-excel', + 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'xml' => 'application/xml', + 'xpm' => 'image/x-xpixmap', + 'xwd' => 'image/x-xwindowdump', + 'yaml' => 'text/yaml', + 'yml' => 'text/yaml', + 'zip' => 'application/zip', + ]; + + $extension = strtolower($extension); + + return isset($mimetypes[$extension]) + ? $mimetypes[$extension] + : null; +} + +/** + * Parses an HTTP message into an associative array. + * + * The array contains the "start-line" key containing the start line of + * the message, "headers" key containing an associative array of header + * array values, and a "body" key containing the body of the message. + * + * @param string $message HTTP request or response to parse. + * + * @return array + * @internal + */ +function _parse_message($message) +{ + if (!$message) { + throw new \InvalidArgumentException('Invalid message'); + } + + // Iterate over each line in the message, accounting for line endings + $lines = preg_split('/(\\r?\\n)/', $message, -1, PREG_SPLIT_DELIM_CAPTURE); + $result = ['start-line' => array_shift($lines), 'headers' => [], 'body' => '']; + array_shift($lines); + + for ($i = 0, $totalLines = count($lines); $i < $totalLines; $i += 2) { + $line = $lines[$i]; + // If two line breaks were encountered, then this is the end of body + if (empty($line)) { + if ($i < $totalLines - 1) { + $result['body'] = implode('', array_slice($lines, $i + 2)); + } + break; + } + if (strpos($line, ':')) { + $parts = explode(':', $line, 2); + $key = trim($parts[0]); + $value = isset($parts[1]) ? trim($parts[1]) : ''; + $result['headers'][$key][] = $value; + } + } + + return $result; +} + +/** + * Constructs a URI for an HTTP request message. + * + * @param string $path Path from the start-line + * @param array $headers Array of headers (each value an array). + * + * @return string + * @internal + */ +function _parse_request_uri($path, array $headers) +{ + $hostKey = array_filter(array_keys($headers), function ($k) { + return strtolower($k) === 'host'; + }); + + // If no host is found, then a full URI cannot be constructed. + if (!$hostKey) { + return $path; + } + + $host = $headers[reset($hostKey)][0]; + $scheme = substr($host, -4) === ':443' ? 'https' : 'http'; + + return $scheme . '://' . $host . '/' . ltrim($path, '/'); +} + +/** @internal */ +function _caseless_remove($keys, array $data) +{ + $result = []; + + foreach ($keys as &$key) { + $key = strtolower($key); + } + + foreach ($data as $k => $v) { + if (!in_array(strtolower($k), $keys)) { + $result[$k] = $v; + } + } + + return $result; +} diff --git a/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/functions_include.php b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/functions_include.php new file mode 100644 index 0000000..96a4a83 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/guzzlehttp/psr7/src/functions_include.php @@ -0,0 +1,6 @@ +<?php + +// Don't redefine the functions if included multiple times. +if (!function_exists('GuzzleHttp\Psr7\str')) { + require __DIR__ . '/functions.php'; +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/CHANGELOG.md b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/CHANGELOG.md new file mode 100644 index 0000000..f66545c --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/CHANGELOG.md @@ -0,0 +1,174 @@ +# Change Log + +The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release. + +## 2.3.3 + +### Changed + +- Using stable version of `php-http/multipart-stream-builder` +- Improved tests + +## 2.3.2 + +### Fixed + +- When parsing an address in `MessageBuilder` we surround the recipient name with double quotes instead of single quotes. + +## 2.3.1 + +### Fixed + +- Make sure to reset the `MultipartStreamBuilder` after a stream is built. + +## 2.3.0 + +### Added + +- Support for sending messages with Mime. `$mailgun->messages()->sendMime()` + +## 2.2.0 + +This version contains a new way of using the API. Each endpoint return a domain object and the +endpoints are grouped like the API documentation. + +### Added + +- Api classes in Mailgun\Api\* +- Api models/responses in Mailgun\Model\* +- Added Hydrators to hydrate PSR-7 responses to arrays or domain objects. +- All exceptions extend `Mailgun\Exception`. +- New exceptions in `Mailgun\Exception` namespace. +- Added `HttpClientConfigurator` to configure the HTTP client. +- Added HttpClient plugins `History` and `ReplaceUriPlugin` +- Assertions with Webmozart\Assert +- `Mailgun\Mailgun::getLastResponse()` +- `Mailgun\Connection\RestClient::getAttachment($url)` +- Clear license information + +### Fixed + +- Fix disordered POST parameters. We do not use array syntax. +- Code styles + +### Deprecated + +The following classes will be removed in version 3.0. + +- `Mailgun\Connection\Exceptions\GenericHTTPError` +- `Mailgun\Connection\Exceptions\InvalidCredentials` +- `Mailgun\Connection\Exceptions\MissingEndpoint` +- `Mailgun\Connection\Exceptions\MissingRequiredParameters` +- `Mailgun\Connection\Exceptions\NoDomainsConfigured` +- `Mailgun\Connection\RestClient` +- `Mailgun\Constants\Api` +- `Mailgun\Constants\ExceptionMessages` +- `Mailgun\Mailgun::$resetClient` +- `Mailgun\Mailgun::sendMessage()` +- `Mailgun\Mailgun::verifyWebhookSignature()` +- `Mailgun\Mailgun::post()` +- `Mailgun\Mailgun::get()` +- `Mailgun\Mailgun::delete()` +- `Mailgun\Mailgun::put()` +- `Mailgun\Mailgun::setApiVersion()` +- `Mailgun\Mailgun::setSslEnabled()` +- `Mailgun\Mailgun::MessageBuilder()` +- `Mailgun\Mailgun::OptInHandler()` +- `Mailgun\Mailgun::BatchMessage()` + +## 2.1.2 + +- Bug fixes with multiple recipients, inline images and attachments. +- Added more tests +- Using PSR-2 code style + +## 2.1.1 + +- Require php-http/message (#142) +- Declare BatchMessage::endpointUrl (#112) + +## 2.1.0 + +- Strict comparison of hash (#117) +- No dependency on Guzzle/PSR7 (#139) +- Build URL string form an array (#138) +- Docblock update (#134) +- Minor fixes (#90, #121, #98) + +## 2.0 + +- Migrated to PHP-HTTP (#94) +- Dropped support for PHP 5.4. + +## 1.8.0 + +- Updated to Guzzle5 (#79) +- Updated default API version from v2 to v3 (#75) +- Show response message on 400, 401 and 404. (#72) +- PHP DocBlocks, Constants Changes, and Minor Refactors (#66) +- Added PHP 7.0 support for Travis-CI, removed PHP 5.3 support (#79) + +## 1.7.2 + +- Added webhook signature verification - (#50) +- Test PHP 5.6 and HHVM - (#51) +- Improved error handling - (#48) +- Fixed attachment handling in Message Builder - (#56) +- Allow any data type in custom data - (#57) +- Return non-JSON response data - (#60) +- Removed legacy closing braces - (#64) + +## 1.7.1 + +- Improved security of OptInHandler - (#31) +- Fixed typo for including an Exception - (#41) +- Fixed Mocks, removed unnecessary code, applied styling - (#44 & #42) +- Less restrictive Guzzle requirement - (#45) + +## 1.7 (2014-1-30) + +Bugfixes: + - patched bug for attachments related to duplicate aggregator bug in Guzzle (#32 @travelton) + +## 1.6 (2014-1-13) + +Enhancement: + - adjust file attachment/inline name (#21 @travelton) + +Bugfixes: + - fixed issue with unordered route actions (#23 @travelton) + +## 1.5 (2013-12-13) + +Enhancement: + - added ability to define non-https endpoint for debugging purposes (#23 @travelton) + +## 1.4 (2013-10-16) + +Bugfixes: + - template IDs were missing from recipient-variables (#15 @travelton) + - batch jobs trigger on to, cc, and bcc (#18 @travelton) + - batch jobs include recipient-variables for to, cc, and bcc (#18 @travelton) + - added method to return message-ids, for easier access (#19 @travelton) + +## 1.3 (2013-09-12) + +Bugfixes: + + - relaxed Guzzle requirement (#7 @travelton) + - fixed reply-to bug (#9 @travelton) + +## 1.2 (2013-09-05) + +Bugfixes: + + - fixed exception handling constants (@travelton) + - fixed MessageBuilder $baseAddress return (#1 @yoye) + - adjusted scope of recipient-variables (#3 @yoye) + - fixed misspellings of Exceptions (#2 @dboggus) + - undefined DEFAULT_TIME_ZONE (#4 @yoye) + - added message IDs to return for BatchMessage (@travelton) + +## 1.1 (2013-08-21) + +Initial Release! diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/LICENSE b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/LICENSE new file mode 100644 index 0000000..89de354 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/LICENSE @@ -0,0 +1,17 @@ +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/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/README.md b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/README.md new file mode 100644 index 0000000..d5bd5ed --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/README.md @@ -0,0 +1,197 @@ +# Mailgun PHP client + +This is the Mailgun PHP SDK. This SDK contains methods for easily interacting +with the Mailgun API. +Below are examples to get you started. For additional examples, please see our +official documentation +at http://documentation.mailgun.com + +[![Latest Version](https://img.shields.io/github/release/mailgun/mailgun-php.svg?style=flat-square)](https://github.com/mailgun/mailgun-php/releases) +[![Build Status](https://img.shields.io/travis/mailgun/mailgun-php/master.svg?style=flat-square)](https://travis-ci.org/mailgun/mailgun-php) +[![StyleCI](https://styleci.io/repos/11654443/shield?branch=master)](https://styleci.io/repos/11654443) +[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/mailgun/mailgun-php.svg?style=flat-square)](https://scrutinizer-ci.com/g/mailgun/mailgun-php) +[![Quality Score](https://img.shields.io/scrutinizer/g/mailgun/mailgun-php.svg?style=flat-square)](https://scrutinizer-ci.com/g/mailgun/mailgun-php) +[![Total Downloads](https://img.shields.io/packagist/dt/mailgun/mailgun-php.svg?style=flat-square)](https://packagist.org/packages/mailgun/mailgun-php) +[![Join the chat at https://gitter.im/mailgun/mailgun-php](https://badges.gitter.im/mailgun/mailgun-php.svg)](https://gitter.im/mailgun/mailgun-php?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + +**This is the documentation for dev-master. You find documentation for the latest stable +release [here](https://github.com/mailgun/mailgun-php/tree/v2.1.2).** + +## Installation + +To install the SDK, you will need to be using [Composer](http://getcomposer.org/) +in your project. +If you aren't using Composer yet, it's really simple! Here's how to install +composer: + +```bash +curl -sS https://getcomposer.org/installer | php +``` + +The Mailgun api client is not hard coupled to Guzzle or any other library that sends HTTP messages. It uses an abstraction +called HTTPlug. This will give you the flexibilty to choose what PSR-7 implementation and HTTP client to use. + +If you just want to get started quickly you should run the following command: + +```bash +php composer.phar require mailgun/mailgun-php php-http/curl-client guzzlehttp/psr7 +``` + +### Why requiring so many packages? + +Mailgun has a dependency on the virtual package +[php-http/client-implementation](https://packagist.org/providers/php-http/client-implementation) which requires to you install **an** adapter, but we do not care which one. That is an implementation detail in your application. We also need **a** PSR-7 implementation and **a** message factory. + +You do not have to use the `php-http/curl-client` if you do not want to. You may use the `php-http/guzzle6-adapter`. Read more about the virtual packages, why this is a good idea and about the flexibility it brings at the [HTTPlug docs](http://docs.php-http.org/en/latest/httplug/users.html). + +## Usage + +You should always use Composer's autoloader in your application to automatically load the your dependencies. All examples below assumes you've already included this in your file: + +```php +require 'vendor/autoload.php'; +use Mailgun\Mailgun; +``` + +Here's how to send a message using the SDK: + +```php +# First, instantiate the SDK with your API credentials +$mg = Mailgun::create('key-example'); + +# Now, compose and send your message. +$mg->messages()->send('example.com', [ + 'from' => 'bob@example.com', + 'to' => 'sally@example.com', + 'subject' => 'The PHP SDK is awesome!', + 'text' => 'It is so simple to send a message.' +]); +``` + +### All usage examples + +You find more detailed documentation at in [/doc](doc/index.md) and on +[https://documentation.mailgun.com](https://documentation.mailgun.com/api_reference.html). + +### Response + +The results of a API call is, by default, a domain object. This will make it easy +to understand the response without reading the documentation. One can just read the +doc blocks on the response classes. This provide an excellent IDE integration. + +```php +$mg = Mailgun::create('key-example'); +$dns = $mg->domains()->show('example.com')->getInboundDNSRecords(); + +foreach ($dns as $record) { + echo $record->getType(); +} +``` + +If you rather be working with array then object you can inject the `ArrayHydrator` +to the Mailgun class. + +```php +use Mailgun\Hydrator\ArrayHydrator; + +$configurator = new HttpClientConfigurator(); +$configurator->setApiKey('key-example'); + +$mg = Mailgun::configure($configurator, new ArrayHydrator()); +$data = $mg->domains()->show('example.com'); + +foreach ($data['receiving_dns_records'] as $record) { + echo isset($record['record_type']) ? $record['record_type'] : null; +} +``` + +You could also use the `NoopHydrator` to get a PSR7 Response returned from +the API calls. + +**Warning: When using `NoopHydrator` there will be no exceptions on a non-200 response.** + +### Debugging + +Debugging the PHP SDK can be really helpful when things aren't working quite right. +To debug the SDK, here are some suggestions: + +Set the endpoint to Mailgun's Postbin. A Postbin is a web service that allows you to +post data, which is then displayed through a browser. This allows you to quickly determine +what is actually being transmitted to Mailgun's API. + +**Step 1 - Create a new Postbin.** +Go to http://bin.mailgun.net. The Postbin will generate a special URL. Save that URL. + +**Step 2 - Instantiate the Mailgun client using Postbin.** + +*Tip: The bin id will be the URL part after bin.mailgun.net. It will be random generated letters and numbers. +For example, the bin id in this URL, http://bin.mailgun.net/aecf68de, is "aecf68de".* + +```php +$configurator = new HttpClientConfigurator(); +$configurator->setEndpoint('http://bin.mailgun.net/aecf68de'); +$configurator->setDebug(true); +$mg = Mailgun::configure($configurator); + +# Now, compose and send your message. +$mg->messages()->send('example.com', [ + 'from' => 'bob@example.com', + 'to' => 'sally@example.com', + 'subject' => 'The PHP SDK is awesome!', + 'text' => 'It is so simple to send a message.' +]); +``` +### Additional Info + +For usage examples on each API endpoint, head over to our official documentation +pages. + +This SDK includes a [Message Builder](src/Mailgun/Messages/README.md), +[Batch Message](src/Mailgun/Messages/README.md) and [Opt-In Handler](src/Mailgun/Lists/README.md) component. + +Message Builder allows you to quickly create the array of parameters, required +to send a message, by calling a methods for each parameter. +Batch Message is an extension of Message Builder, and allows you to easily send +a batch message job within a few seconds. The complexity of +batch messaging is eliminated! + +## Framework integration + +If you are using a framework you might consider these composer packages to make the framework integration easier. + +* [tehplague/swiftmailer-mailgun-bundle](https://github.com/tehplague/swiftmailer-mailgun-bundle) for Symfony +* [Bogardo/Mailgun](https://github.com/Bogardo/Mailgun) for Laravel +* [katanyoo/yii2-mailgun-mailer](https://github.com/katanyoo/yii2-mailgun-mailer) for Yii2 + +## Contribute + +We are currently building a new object oriented API client. Feel free to contribute in any way. As an example you may: +* Trying out dev-master the code +* Create issues if you find problems +* Reply to other people's issues +* Review PRs +* Write PR. You find our current milestone [here](https://github.com/mailgun/mailgun-php/milestone/1) + +### Running the test code + +If you want to run the tests you should run the following commands: + +```terminal +git clone git@github.com:mailgun/mailgun-php.git +cd mailgun-php +composer update +composer test +``` + +## Support and Feedback + +Be sure to visit the Mailgun official +[documentation website](http://documentation.mailgun.com/) for additional +information about our API. + +If you find a bug, please submit the issue in Github directly. +[Mailgun-PHP Issues](https://github.com/mailgun/mailgun-php/issues) + +As always, if you need additional assistance, drop us a note through your Control Panel at +[https://mailgun.com/cp/support](https://mailgun.com/cp/support). + diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/composer.json b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/composer.json new file mode 100644 index 0000000..c4290f7 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/composer.json @@ -0,0 +1,41 @@ +{ + "name": "mailgun/mailgun-php", + "description": "The Mailgun SDK provides methods for all API functions.", + "require": { + "php": "^5.5|^7.0", + "php-http/httplug": "^1.0", + "php-http/multipart-stream-builder": "^1.0", + "php-http/message": "^1.0", + "php-http/client-common": "^1.1", + "php-http/discovery": "^1.0", + "webmozart/assert": "^1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.8", + "php-http/guzzle6-adapter": "^1.0", + "guzzlehttp/psr7": "^1.4" + }, + "autoload": { + "psr-0": { + "Mailgun": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Mailgun\\Tests\\": "tests/" + } + }, + "license": "MIT", + "authors": [ + { + "name": "Travis Swientek", + "email": "travis@mailgunhq.com" + } + ], + "scripts": { + "test": "vendor/bin/phpunit --testsuite unit && vendor/bin/phpunit --testsuite functional", + "test-all": "vendor/bin/phpunit --testsuite all", + "test-integration": "vendor/bin/phpunit --testsuite integration", + "test-coverage": "vendor/bin/phpunit --testsuite all --coverage-text --coverage-clover=build/coverage.xml" + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/doc/attachments.md b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/doc/attachments.md new file mode 100644 index 0000000..92f5090 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/doc/attachments.md @@ -0,0 +1,47 @@ +# Attachments + +You may attach a file from memory or by a file path. + +## From file path + +```php +$mg->message()->send('example.com', [ + 'from' => 'bob@example.com', + 'to' => 'sally@example.com', + 'subject' => 'Test file path attachments', + 'text' => 'Test', + 'attachment' => [ + ['filePath'=>'/tmp/foo.jpg', 'filename'=>'test.jpg'] + ] +]); +``` +## From memory + +```php +// Some how load the file to memory +$binaryFile = '[Binary data]'; + +$mg->message()->send('example.com', [ + 'from' => 'bob@example.com', + 'to' => 'sally@example.com', + 'subject' => 'Test memory attachments', + 'text' => 'Test', + 'attachment' => [ + ['fileContent'=>$binaryFile, 'filename'=>'test.jpg'] + ] +]); +``` + +## Inline attachments + +```php +$mg->message()->send('example.com', [ + 'from' => 'bob@example.com', + 'to' => 'sally@example.com', + 'subject' => 'Test inline attachments', + 'text' => 'Test', + 'inline' => [ + ['filePath'=>'/tmp/foo.jpg', 'filename'=>'test.jpg'] + ] +]); +``` diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/doc/index.md b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/doc/index.md new file mode 100644 index 0000000..885d483 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/doc/index.md @@ -0,0 +1,330 @@ +# API documentation + +This page will document the API classes and ways to properly use the API. These resources will eventually move to +the official documentation at [https://documentation.mailgun.com](https://documentation.mailgun.com/api_reference.html). + +Other relevant documentation pages might be: + +* [Attachments](attachments.md) +* [Pagination](pagination.md) +* [Message Builder](src/Mailgun/Messages/README.md) (Legacy code) +* [Batch Message](src/Mailgun/Messages/README.md) (Legacy code) +* [Opt-In Handler](src/Mailgun/Lists/README.md) (Legacy code) + +## Domain API + +#### Get a list of all domains + +```php +$mailgun->domains()->index(); +``` + +#### Show a single domains + +```php +$mailgun->domains()->show('example.com'); +``` + +#### Create a new domain + +```php +$mailgun->domains()->create('new.example.com', 'password', 'disable', '*'); +``` + +#### Delete a domain + +```php +$mailgun->domains()->delete('example.com'); +``` + +#### Get credentials for a domain + +```php +$mailgun->domains()->credentials('example.com'); +``` + +#### Create credentials for a domain + +```php +$mailgun->domains()->createCredential('example.com', 'login', 'password'); +``` + +#### Update credentials for a domain + +```php +$mailgun->domains()->updateCredential('example.com', 'login', 'password'); +``` + +#### Delete credentials for a domain + +```php +$mailgun->domains()->deleteCredential('example.com', 'login'); +``` + +#### Get connection for a domain + +```php +$mailgun->domains()->connection('example.com'); +``` + +#### Update connection for a domain + +```php +$mailgun->domains()->updateConnection('example.com', true, false); +``` + +## Event API + +#### Get all events for a domain +```php +$mailgun->events()->get('example.com'); +``` + +## Message API + +#### Send a message +```php +$parameters = [ + 'from' => 'bob@example.com', + 'to' => 'sally@example.com', + 'subject' => 'The PHP SDK is awesome!', + 'text' => 'It is so simple to send a message.' +]; +$mailgun->messages()->send('example.com', $parameters); +``` +#### Send a message with Mime + +Below in an example how to create a Mime message with SwiftMailer. + +```php +$message = \Swift_Message::newInstance('Mail Subject'); +$message->setFrom(['from@exemple.com' => 'Example Inc']); +$message->setTo(['user0gmail.com' => 'User 0', 'user1@hotmail.com' => 'User 1']); +// $message->setBcc('admin@example.com'); Do not do this, BCC will be visible for all receipients if you do. +$message->setCc('invoice@example.com'); + +$messageBody = 'Look at the <b>fancy</b> HTML body.'; +$message->setBody($messageBody, 'text/html'); + +// We need all "tos". Incluce the BCC here. +$to = ['admin@example.com', 'user0gmail.com', 'user1@hotmail.com', 'invoice@example.com'] + +// Send the message +$mailgun->messages()->sendMime('example.com', $to, $message->toString()); +``` + +#### Show a stored message + +If you got an URL to a stored message you may get the details by: + +```php +$url = // ... +$mailgun->messages()->show($url); +``` + +## Route API + +#### Show all routes + +```php +$mailgun->routes()->index(); +``` + +#### Show a routes + +Get a route by its ID + +```php +$mailgun->routes()->show(4711); +``` +#### Create a route + +```php +$expression = "match_recipient('.*@gmail.com')"; +$actions = ["forward('alice@example.com')"]; +$description = 'Test route'; + +$mailgun->routes()->create($expression, $actions, $description); +``` + +#### Update a route + +```php +$expression = "match_recipient('.*@gmail.com')"; +$actions = ["forward('alice@example.com')"]; +$description = 'Test route'; + +$mailgun->routes()->update(4711, $expression, $actions, $description); +``` + +#### Delete a route +```php +$mailgun->routes()->delete(4711); +``` + +## Stats API + +#### Get total stats for a domain +```php +$mailgun->stats()->total('example.com'); +``` + +#### Get all stats for a domain +```php +$mailgun->stats()->all('example.com'); +``` + +## Suppression API + +The suppression API consists of 3 parts; `Bounce`, `Complaint` and `Unsubscribe`. + +### Bounce API +#### Get all bounces +```php +$mailgun->suppressions()->bounces()->index('example.com'); +``` + +#### Show bounces for a specific address +```php +$mailgun->suppressions()->bounces()->show('example.com', 'alice@gmail.com'); +``` + +#### Create a bounce +```php +$mailgun->suppressions()->bounces()->create('example.com', 'alice@gmail.com'); +``` + +#### Delete a bounce +```php +$mailgun->suppressions()->bounces()->delete('example.com', 'alice@gmail.com'); +``` + +#### Delete all bounces +```php +$mailgun->suppressions()->bounces()->deleteAll('example.com'); +``` + +### Complaint API +#### Get all complaints +```php +$mailgun->suppressions()->complaints->index('example.com'); +``` + +#### Show complaints for a specific address +```php +$mailgun->suppressions()->complaints()->show('example.com', 'alice@gmail.com'); +``` + +#### Create a complaint +```php +$mailgun->suppressions()->complaints()->create('example.com', 'alice@gmail.com'); +``` + +#### Delete a complaint +```php +$mailgun->suppressions()->complaints()->delete('example.com', 'alice@gmail.com'); +``` + +#### Delete all complaints +```php +$mailgun->suppressions()->complaints()->deleteAll('example.com'); +``` + +## Unsubscribe API + +#### Get all unsubscriptions +```php +$mailgun->suppressions()->unsubscribes()->index('example.com'); +``` + +#### Show unsubscriptions for a specific address +```php +$mailgun->suppressions()->unsubscribes()->show('example.com', 'alice@gmail.com'); +``` + +#### Create an unsubscription +```php +$mailgun->suppressions()->unsubscribes()->create('example.com', 'alice@gmail.com'); +``` + +#### Delete an unsubscription +```php +$mailgun->suppressions()->unsubscribes()->delete('example.com', 'alice@gmail.com'); +``` + +#### Delete all unsubscriptions +```php +$mailgun->suppressions()->unsubscribes()->deleteAll('example.com'); +``` + +## Tag API + +#### Show all tags +```php +$mailgun->tags()->index('example.com'); +``` + +#### Show a single tag +```php +$mailgun->tags()->show('example.com', 'foo'); +``` + +#### Update a tag +```php +$mailgun->tags()->update('example.com', 'foo', 'description'); +``` + +#### Show stats for a tag +```php +$mailgun->tags()->stats('example.com', 'foo'); +``` + +#### Delete a tag +```php +$mailgun->tags()->delete('example.com', 'foo'); +``` + +## Webhook API +#### Verify webhook signature +```php + +$timestamp = $_POST['timestamp']; +$token = $_POST['token']; +$signature = $_POST['signature']; + +$mailgun = Maingun::create('my_api_key'); +$valid = $mailgun->webhooks()->verifyWebhookSignature($timestamp, $token, $signature); + +if (!$valid) { + // Create a 403 response + + exit(); +} + +// The signature is valid +``` + +#### Show all webhooks +```php +$mailgun->webhooks()->index('example.com'); +``` + +#### Show a single webhooks +```php +$mailgun->webhooks()->show('example.com', 'accept'); +``` + +#### Create a webhooks +```php +$mailgun->webhooks()->create('example.com', 'accept', 'https://www.exmple.com/webhook'); +``` + +#### Update a webhooks +```php +$mailgun->webhooks()->update('example.com', 4711, 'https://www.exmple.com/webhook'); +``` + +#### Delete a webhooks +```php +$mailgun->webhooks()->delete('example.com', 4711); +``` diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/doc/pagination.md b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/doc/pagination.md new file mode 100644 index 0000000..2fbcd5d --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/doc/pagination.md @@ -0,0 +1,17 @@ +# Pagination + +Some API endpoints do support pagination. + +```php + +/** @var Mailgun\Model\Tag\IndexReponse $response */ +$reponse = $mailgun->tags()->index('example.com'); + +// Parse through the first response +// ... + +$nextResponse = $mailgun->tags()->nextPage($response); +$previousResponse = $mailgun->tags()->previousPage($response); +$firstResponse = $mailgun->tags()->firstPage($response); +$lastResponse = $mailgun->tags()->lastPage($response); +``` diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Domain.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Domain.php new file mode 100644 index 0000000..5f208c9 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Domain.php @@ -0,0 +1,266 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Api; + +use Mailgun\Assert; +use Mailgun\Model\Domain\ConnectionResponse; +use Mailgun\Model\Domain\CreateCredentialResponse; +use Mailgun\Model\Domain\CreateResponse; +use Mailgun\Model\Domain\CredentialResponse; +use Mailgun\Model\Domain\DeleteCredentialResponse; +use Mailgun\Model\Domain\DeleteResponse; +use Mailgun\Model\Domain\IndexResponse; +use Mailgun\Model\Domain\ShowResponse; +use Mailgun\Model\Domain\UpdateConnectionResponse; +use Mailgun\Model\Domain\UpdateCredentialResponse; +use Psr\Http\Message\ResponseInterface; + +/** + * {@link https://documentation.mailgun.com/api-domains.html}. + * + * @author Sean Johnson <sean@mailgun.com> + */ +class Domain extends HttpApi +{ + /** + * Returns a list of domains on the account. + * + * @param int $limit + * @param int $skip + * + * @return IndexResponse + */ + public function index($limit = 100, $skip = 0) + { + Assert::integer($limit); + Assert::integer($skip); + + $params = [ + 'limit' => $limit, + 'skip' => $skip, + ]; + + $response = $this->httpGet('/v3/domains', $params); + + return $this->hydrateResponse($response, IndexResponse::class); + } + + /** + * Returns a single domain. + * + * @param string $domain Name of the domain. + * + * @return ShowResponse|array|ResponseInterface + */ + public function show($domain) + { + Assert::stringNotEmpty($domain); + + $response = $this->httpGet(sprintf('/v3/domains/%s', $domain)); + + return $this->hydrateResponse($response, ShowResponse::class); + } + + /** + * Creates a new domain for the account. + * See below for spam filtering parameter information. + * {@link https://documentation.mailgun.com/user_manual.html#um-spam-filter}. + * + * @param string $domain Name of the domain. + * @param string $smtpPass Password for SMTP authentication. + * @param string $spamAction `disable` or `tag` - inbound spam filtering. + * @param bool $wildcard Domain will accept email for subdomains. + * + * @return CreateResponse|array|ResponseInterface + */ + public function create($domain, $smtpPass, $spamAction, $wildcard) + { + Assert::stringNotEmpty($domain); + Assert::stringNotEmpty($smtpPass); + // TODO(sean.johnson): Extended spam filter input validation. + Assert::stringNotEmpty($spamAction); + Assert::boolean($wildcard); + + $params = [ + 'name' => $domain, + 'smtp_password' => $smtpPass, + 'spam_action' => $spamAction, + 'wildcard' => $wildcard, + ]; + + $response = $this->httpPost('/v3/domains', $params); + + return $this->hydrateResponse($response, CreateResponse::class); + } + + /** + * Removes a domain from the account. + * WARNING: This action is irreversible! Be cautious! + * + * @param string $domain Name of the domain. + * + * @return DeleteResponse|array|ResponseInterface + */ + public function delete($domain) + { + Assert::stringNotEmpty($domain); + + $response = $this->httpDelete(sprintf('/v3/domains/%s', $domain)); + + return $this->hydrateResponse($response, DeleteResponse::class); + } + + /** + * Returns a list of SMTP credentials for the specified domain. + * + * @param string $domain Name of the domain. + * @param int $limit Number of credentials to return + * @param int $skip Number of credentials to omit from the list + * + * @return CredentialResponse + */ + public function credentials($domain, $limit = 100, $skip = 0) + { + Assert::stringNotEmpty($domain); + Assert::integer($limit); + Assert::integer($skip); + + $params = [ + 'limit' => $limit, + 'skip' => $skip, + ]; + + $response = $this->httpGet(sprintf('/v3/domains/%s/credentials', $domain), $params); + + return $this->hydrateResponse($response, CredentialResponse::class); + } + + /** + * Create a new SMTP credential pair for the specified domain. + * + * @param string $domain Name of the domain. + * @param string $login SMTP Username. + * @param string $password SMTP Password. Length min 5, max 32. + * + * @return CreateCredentialResponse|array|ResponseInterface + */ + public function createCredential($domain, $login, $password) + { + Assert::stringNotEmpty($domain); + Assert::stringNotEmpty($login); + Assert::stringNotEmpty($password); + Assert::lengthBetween($password, 5, 32, 'SMTP password must be between 5 and 32 characters.'); + + $params = [ + 'login' => $login, + 'password' => $password, + ]; + + $response = $this->httpPost(sprintf('/v3/domains/%s/credentials', $domain), $params); + + return $this->hydrateResponse($response, CreateCredentialResponse::class); + } + + /** + * Update a set of SMTP credentials for the specified domain. + * + * @param string $domain Name of the domain. + * @param string $login SMTP Username. + * @param string $pass New SMTP Password. Length min 5, max 32. + * + * @return UpdateCredentialResponse|array|ResponseInterface + */ + public function updateCredential($domain, $login, $pass) + { + Assert::stringNotEmpty($domain); + Assert::stringNotEmpty($login); + Assert::stringNotEmpty($pass); + Assert::lengthBetween($pass, 5, 32, 'SMTP password must be between 5 and 32 characters.'); + + $params = [ + 'password' => $pass, + ]; + + $response = $this->httpPut(sprintf('/v3/domains/%s/credentials/%s', $domain, $login), $params); + + return $this->hydrateResponse($response, UpdateCredentialResponse::class); + } + + /** + * Remove a set of SMTP credentials from the specified domain. + * + * @param string $domain Name of the domain. + * @param string $login SMTP Username. + * + * @return DeleteCredentialResponse|array|ResponseInterface + */ + public function deleteCredential($domain, $login) + { + Assert::stringNotEmpty($domain); + Assert::stringNotEmpty($login); + + $response = $this->httpDelete( + sprintf( + '/v3/domains/%s/credentials/%s', + $domain, + $login + ) + ); + + return $this->hydrateResponse($response, DeleteCredentialResponse::class); + } + + /** + * Returns delivery connection settings for the specified domain. + * + * @param string $domain Name of the domain. + * + * @return ConnectionResponse|ResponseInterface + */ + public function connection($domain) + { + Assert::stringNotEmpty($domain); + + $response = $this->httpGet(sprintf('/v3/domains/%s/connection', $domain)); + + return $this->hydrateResponse($response, ConnectionResponse::class); + } + + /** + * Updates the specified delivery connection settings for the specified domain. + * If a parameter is passed in as null, it will not be updated. + * + * @param string $domain Name of the domain. + * @param bool|null $requireTLS Enforces that messages are sent only over a TLS connection. + * @param bool|null $noVerify Disables TLS certificate and hostname verification. + * + * @return UpdateConnectionResponse|array|ResponseInterface + */ + public function updateConnection($domain, $requireTLS, $noVerify) + { + Assert::stringNotEmpty($domain); + Assert::nullOrBoolean($requireTLS); + Assert::nullOrBoolean($noVerify); + + $params = []; + + if (null !== $requireTLS) { + $params['require_tls'] = $requireTLS ? 'true' : 'false'; + } + + if (null !== $noVerify) { + $params['skip_verification'] = $noVerify ? 'true' : 'false'; + } + + $response = $this->httpPut(sprintf('/v3/domains/%s/connection', $domain), $params); + + return $this->hydrateResponse($response, UpdateConnectionResponse::class); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Event.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Event.php new file mode 100644 index 0000000..d49d4e7 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Event.php @@ -0,0 +1,38 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Api; + +use Mailgun\Assert; +use Mailgun\Model\Event\EventResponse; + +/** + * {@link https://documentation.mailgun.com/api-events.html}. + * + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +class Event extends HttpApi +{ + use Pagination; + + /** + * @param string $domain + * @param array $params + * + * @return EventResponse + */ + public function get($domain, array $params = []) + { + Assert::stringNotEmpty($domain); + + $response = $this->httpGet(sprintf('/v3/%s/events', $domain), $params); + + return $this->hydrateResponse($response, EventResponse::class); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/HttpApi.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/HttpApi.php new file mode 100644 index 0000000..0035479 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/HttpApi.php @@ -0,0 +1,235 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Api; + +use Http\Client\Exception as HttplugException; +use Http\Client\HttpClient; +use Mailgun\Exception\UnknownErrorException; +use Mailgun\Hydrator\Hydrator; +use Mailgun\Hydrator\NoopHydrator; +use Mailgun\Exception\HttpClientException; +use Mailgun\Exception\HttpServerException; +use Mailgun\RequestBuilder; +use Psr\Http\Message\ResponseInterface; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +abstract class HttpApi +{ + /** + * The HTTP client. + * + * @var HttpClient + */ + private $httpClient; + + /** + * @var Hydrator + */ + protected $hydrator; + + /** + * @var RequestBuilder + */ + protected $requestBuilder; + + /** + * @param HttpClient $httpClient + * @param RequestBuilder $requestBuilder + * @param Hydrator $hydrator + */ + public function __construct(HttpClient $httpClient, RequestBuilder $requestBuilder, Hydrator $hydrator) + { + $this->httpClient = $httpClient; + $this->requestBuilder = $requestBuilder; + if (!$hydrator instanceof NoopHydrator) { + $this->hydrator = $hydrator; + } + } + + /** + * @param ResponseInterface $response + * @param string $class + * + * @return mixed|ResponseInterface + * + * @throws \Exception + */ + protected function hydrateResponse(ResponseInterface $response, $class) + { + if (!$this->hydrator) { + return $response; + } + + if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 201) { + $this->handleErrors($response); + } + + return $this->hydrator->hydrate($response, $class); + } + + /** + * Throw the correct exception for this error. + * + * @param ResponseInterface $response + * + * @throws \Exception + */ + protected function handleErrors(ResponseInterface $response) + { + $statusCode = $response->getStatusCode(); + switch ($statusCode) { + case 400: + throw HttpClientException::badRequest($response); + case 401: + throw HttpClientException::unauthorized($response); + case 402: + throw HttpClientException::requestFailed($response); + case 404: + throw HttpClientException::notFound($response); + case 500 <= $statusCode: + throw HttpServerException::serverError($statusCode); + default: + throw new UnknownErrorException(); + } + } + + /** + * Send a GET request with query parameters. + * + * @param string $path Request path + * @param array $parameters GET parameters + * @param array $requestHeaders Request Headers + * + * @return ResponseInterface + */ + protected function httpGet($path, array $parameters = [], array $requestHeaders = []) + { + if (count($parameters) > 0) { + $path .= '?'.http_build_query($parameters); + } + + try { + $response = $this->httpClient->sendRequest( + $this->requestBuilder->create('GET', $path, $requestHeaders) + ); + } catch (HttplugException\NetworkException $e) { + throw HttpServerException::networkError($e); + } + + return $response; + } + + /** + * Send a POST request with parameters. + * + * @param string $path Request path + * @param array $parameters POST parameters + * @param array $requestHeaders Request headers + * + * @return ResponseInterface + */ + protected function httpPost($path, array $parameters = [], array $requestHeaders = []) + { + return $this->httpPostRaw($path, $this->createRequestBody($parameters), $requestHeaders); + } + + /** + * Send a POST request with raw data. + * + * @param string $path Request path + * @param array|string $body Request body + * @param array $requestHeaders Request headers + * + * @return ResponseInterface + */ + protected function httpPostRaw($path, $body, array $requestHeaders = []) + { + try { + $response = $this->httpClient->sendRequest( + $this->requestBuilder->create('POST', $path, $requestHeaders, $body) + ); + } catch (HttplugException\NetworkException $e) { + throw HttpServerException::networkError($e); + } + + return $response; + } + + /** + * Send a PUT request. + * + * @param string $path Request path + * @param array $parameters PUT parameters + * @param array $requestHeaders Request headers + * + * @return ResponseInterface + */ + protected function httpPut($path, array $parameters = [], array $requestHeaders = []) + { + try { + $response = $this->httpClient->sendRequest( + $this->requestBuilder->create('PUT', $path, $requestHeaders, $this->createRequestBody($parameters)) + ); + } catch (HttplugException\NetworkException $e) { + throw HttpServerException::networkError($e); + } + + return $response; + } + + /** + * Send a DELETE request. + * + * @param string $path Request path + * @param array $parameters DELETE parameters + * @param array $requestHeaders Request headers + * + * @return ResponseInterface + */ + protected function httpDelete($path, array $parameters = [], array $requestHeaders = []) + { + try { + $response = $this->httpClient->sendRequest( + $this->requestBuilder->create('DELETE', $path, $requestHeaders, $this->createRequestBody($parameters)) + ); + } catch (HttplugException\NetworkException $e) { + throw HttpServerException::networkError($e); + } + + return $response; + } + + /** + * Prepare a set of key-value-pairs to be encoded as multipart/form-data. + * + * @param array $parameters Request parameters + * + * @return array + */ + protected function createRequestBody(array $parameters) + { + $resources = []; + foreach ($parameters as $key => $values) { + if (!is_array($values)) { + $values = [$values]; + } + foreach ($values as $value) { + $resources[] = [ + 'name' => $key, + 'content' => $value, + ]; + } + } + + return $resources; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Message.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Message.php new file mode 100644 index 0000000..cdbfd87 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Message.php @@ -0,0 +1,170 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Api; + +use Mailgun\Assert; +use Mailgun\Exception\InvalidArgumentException; +use Mailgun\Model\Message\SendResponse; +use Mailgun\Model\Message\ShowResponse; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +class Message extends HttpApi +{ + /** + * @param string $domain + * @param array $params + * + * @return SendResponse + */ + public function send($domain, array $params) + { + Assert::string($domain); + Assert::notEmpty($domain); + Assert::notEmpty($params); + + $postDataMultipart = []; + $fields = ['attachment', 'inline']; + foreach ($fields as $fieldName) { + if (!isset($params[$fieldName])) { + continue; + } + + Assert::isArray($params[$fieldName]); + foreach ($params[$fieldName] as $file) { + $postDataMultipart[] = $this->prepareFile($fieldName, $file); + } + + unset($params[$fieldName]); + } + + $postDataMultipart = array_merge($this->prepareMultipartParameters($params), $postDataMultipart); + $response = $this->httpPostRaw(sprintf('/v3/%s/messages', $domain), $postDataMultipart); + + return $this->hydrateResponse($response, SendResponse::class); + } + + /** + * @param string $domain + * @param array $recipients with all you send emails to. Including bcc and cc + * @param string $message Message filepath or content + * @param array $params + */ + public function sendMime($domain, array $recipients, $message, array $params) + { + Assert::string($domain); + Assert::notEmpty($domain); + Assert::notEmpty($recipients); + Assert::notEmpty($message); + Assert::nullOrIsArray($params); + + $params['to'] = $recipients; + $postDataMultipart = $this->prepareMultipartParameters($params); + + if (is_file($message)) { + $fileData = ['filePath' => $message]; + } else { + $fileData = [ + 'fileContent' => $message, + 'filename' => 'message', + ]; + } + $postDataMultipart[] = $this->prepareFile('message', $fileData); + $response = $this->httpPostRaw(sprintf('/v3/%s/messages.mime', $domain), $postDataMultipart); + + return $this->hydrateResponse($response, SendResponse::class); + } + + /** + * Get stored message. + * + * @param string $url + * @param bool $rawMessage if true we will use "Accept: message/rfc2822" header + * + * @return ShowResponse + */ + public function show($url, $rawMessage = false) + { + Assert::notEmpty($url); + + $headers = []; + if ($rawMessage) { + $headers['Accept'] = 'message/rfc2822'; + } + + $response = $this->httpGet($url, [], $headers); + + return $this->hydrateResponse($response, ShowResponse::class); + } + + /** + * Prepare a file. + * + * @param string $fieldName + * @param array $filePath array('fileContent' => 'content') or array('filePath' => '/foo/bar') + * + * @return array + * + * @throws InvalidArgumentException + */ + private function prepareFile($fieldName, array $filePath) + { + $filename = isset($filePath['filename']) ? $filePath['filename'] : null; + + if (isset($filePath['fileContent'])) { + // File from memory + $resource = fopen('php://temp', 'r+'); + fwrite($resource, $filePath['fileContent']); + rewind($resource); + } elseif (isset($filePath['filePath'])) { + // File form path + $path = $filePath['filePath']; + + // Remove leading @ symbol + if (strpos($path, '@') === 0) { + $path = substr($path, 1); + } + + $resource = fopen($path, 'r'); + } else { + throw new InvalidArgumentException('When using a file you need to specify parameter "fileContent" or "filePath"'); + } + + return [ + 'name' => $fieldName, + 'content' => $resource, + 'filename' => $filename, + ]; + } + + /** + * Prepare multipart parameters. Make sure each POST parameter is splitted into an array with 'name' and 'content' keys. + * + * @param array $params + * + * @return array + */ + private function prepareMultipartParameters(array $params) + { + $postDataMultipart = []; + foreach ($params as $key => $value) { + // If $value is not an array we cast it to an array + foreach ((array) $value as $subValue) { + $postDataMultipart[] = [ + 'name' => $key, + 'content' => $subValue, + ]; + } + } + + return $postDataMultipart; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Pagination.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Pagination.php new file mode 100644 index 0000000..335a8b0 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Pagination.php @@ -0,0 +1,83 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Api; + +use Mailgun\Assert; +use Mailgun\Model\PagingProvider; +use Psr\Http\Message\ResponseInterface; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +trait Pagination +{ + abstract protected function httpGet($path, array $parameters = [], array $requestHeaders = []); + + abstract protected function hydrateResponse(ResponseInterface $response, $className); + + /** + * @param PagingProvider $response + * + * @return PagingProvider|null + */ + public function nextPage(PagingProvider $response) + { + return $this->getPaginationUrl($response->getNextUrl(), get_class($response)); + } + + /** + * @param PagingProvider $response + * + * @return PagingProvider|null + */ + public function previousPage(PagingProvider $response) + { + return $this->getPaginationUrl($response->getPreviousUrl(), get_class($response)); + } + + /** + * @param PagingProvider $response + * + * @return PagingProvider|null + */ + public function firstPage(PagingProvider $response) + { + return $this->getPaginationUrl($response->getFirstUrl(), get_class($response)); + } + + /** + * @param PagingProvider $response + * + * @return PagingProvider|null + */ + public function lastPage(PagingProvider $response) + { + return $this->getPaginationUrl($response->getLastUrl(), get_class($response)); + } + + /** + * @param string $url + * @param string $class + * + * @return PagingProvider|null + */ + private function getPaginationUrl($url, $class) + { + Assert::stringNotEmpty($class); + + if (empty($url)) { + return; + } + + $response = $this->httpGet($url); + + return $this->hydrateResponse($response, $class); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Route.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Route.php new file mode 100644 index 0000000..561550f --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Route.php @@ -0,0 +1,157 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Api; + +use Mailgun\Assert; +use Mailgun\Model\Route\Response\CreateResponse; +use Mailgun\Model\Route\Response\DeleteResponse; +use Mailgun\Model\Route\Response\IndexResponse; +use Mailgun\Model\Route\Response\ShowResponse; +use Mailgun\Model\Route\Response\UpdateResponse; + +/** + * {@link https://documentation.mailgun.com/api-routes.html}. + * + * @author David Garcia <me@davidgarcia.cat> + */ +class Route extends HttpApi +{ + /** + * Fetches the list of Routes. + * + * @param int $limit Maximum number of records to return. (100 by default) + * @param int $skip Number of records to skip. (0 by default) + * + * @return IndexResponse + */ + public function index($limit = 100, $skip = 0) + { + Assert::integer($limit); + Assert::integer($skip); + Assert::greaterThan($limit, 0); + Assert::greaterThanEq($skip, 0); + + $params = [ + 'limit' => $limit, + 'skip' => $skip, + ]; + + $response = $this->httpGet('/v3/routes', $params); + + return $this->hydrateResponse($response, IndexResponse::class); + } + + /** + * Returns a single Route object based on its ID. + * + * @param string $routeId Route ID returned by the Routes::index() method + * + * @return ShowResponse + */ + public function show($routeId) + { + Assert::stringNotEmpty($routeId); + + $response = $this->httpGet(sprintf('/v3/routes/%s', $routeId)); + + return $this->hydrateResponse($response, ShowResponse::class); + } + + /** + * Creates a new Route. + * + * @param string $expression A filter expression like "match_recipient('.*@gmail.com')" + * @param array $actions Route action. This action is executed when the expression evaluates to True. Example: "forward('alice@example.com')" + * @param string $description An arbitrary string + * @param int $priority Integer: smaller number indicates higher priority. Higher priority routes are handled first. Defaults to 0. + * + * @return CreateResponse + */ + public function create($expression, array $actions, $description, $priority = 0) + { + Assert::string($expression); + Assert::isArray($actions); + Assert::string($description); + Assert::integer($priority); + + $params = [ + 'priority' => $priority, + 'expression' => $expression, + 'action' => $actions, + 'description' => $description, + ]; + + $response = $this->httpPost('/v3/routes', $params); + + return $this->hydrateResponse($response, CreateResponse::class); + } + + /** + * Updates a given Route by ID. All parameters are optional. + * This API call only updates the specified fields leaving others unchanged. + * + * @param string $routeId Route ID returned by the Routes::index() method + * @param string|null $expression A filter expression like "match_recipient('.*@gmail.com')" + * @param array|null $actions Route action. This action is executed when the expression evaluates to True. Example: "forward('alice@example.com')" + * @param string|null $description An arbitrary string + * @param int|null $priority Integer: smaller number indicates higher priority. Higher priority routes are handled first. Defaults to 0. + * + * @return UpdateResponse + */ + public function update($routeId, $expression = null, array $actions = [], $description = null, $priority = null) + { + Assert::stringNotEmpty($routeId); + Assert::nullOrString($expression); + Assert::isArray($actions); + Assert::nullOrString($description); + Assert::nullOrInteger($priority); + + $params = []; + + if (!empty($expression)) { + $params['expression'] = trim($expression); + } + + foreach ($actions as $action) { + Assert::stringNotEmpty($action); + + $params['action'] = isset($params['action']) ? $params['action'] : []; + $params['action'][] = $action; + } + + if (!empty($description)) { + $params['description'] = trim($description); + } + + if (!empty($priority)) { + $params['priority'] = $priority; + } + + $response = $this->httpPut(sprintf('/v3/routes/%s', $routeId), $params); + + return $this->hydrateResponse($response, UpdateResponse::class); + } + + /** + * Deletes a Route based on the ID. + * + * @param string $routeId Route ID returned by the Routes::index() method + * + * @return DeleteResponse + */ + public function delete($routeId) + { + Assert::stringNotEmpty($routeId); + + $response = $this->httpDelete(sprintf('/v3/routes/%s', $routeId)); + + return $this->hydrateResponse($response, DeleteResponse::class); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Stats.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Stats.php new file mode 100644 index 0000000..cd7b947 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Stats.php @@ -0,0 +1,52 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Api; + +use Mailgun\Assert; +use Mailgun\Model\Stats\AllResponse; +use Mailgun\Model\Stats\TotalResponse; + +/** + * {@link https://documentation.mailgun.com/api-stats.html}. + * + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +class Stats extends HttpApi +{ + /** + * @param string $domain + * @param array $params + * + * @return TotalResponse|array + */ + public function total($domain, array $params = []) + { + Assert::stringNotEmpty($domain); + + $response = $this->httpGet(sprintf('/v3/%s/stats/total', rawurlencode($domain)), $params); + + return $this->hydrateResponse($response, TotalResponse::class); + } + + /** + * @param $domain + * @param array $params + * + * @return AllResponse|array + */ + public function all($domain, array $params = []) + { + Assert::stringNotEmpty($domain); + + $response = $this->httpGet(sprintf('/v3/%s/stats', rawurlencode($domain)), $params); + + return $this->hydrateResponse($response, AllResponse::class); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Suppression.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Suppression.php new file mode 100644 index 0000000..db35bfe --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Suppression.php @@ -0,0 +1,76 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Api; + +use Http\Client\HttpClient; +use Mailgun\Api\Suppression\Bounce; +use Mailgun\Api\Suppression\Complaint; +use Mailgun\Api\Suppression\Unsubscribe; +use Mailgun\Hydrator\Hydrator; +use Mailgun\RequestBuilder; + +/** + * @see https://documentation.mailgun.com/api-suppressions.html + * + * @author Sean Johnson <sean@mailgun.com> + */ +class Suppression +{ + /** + * @var HttpClient + */ + private $httpClient; + + /** + * @var RequestBuilder + */ + private $requestBuilder; + + /** + * @var Hydrator + */ + private $hydrator; + + /** + * @param HttpClient $httpClient + * @param RequestBuilder $requestBuilder + * @param Hydrator $hydrator + */ + public function __construct(HttpClient $httpClient, RequestBuilder $requestBuilder, Hydrator $hydrator) + { + $this->httpClient = $httpClient; + $this->requestBuilder = $requestBuilder; + $this->hydrator = $hydrator; + } + + /** + * @return Bounce + */ + public function bounces() + { + return new Bounce($this->httpClient, $this->requestBuilder, $this->hydrator); + } + + /** + * @return Complaint + */ + public function complaints() + { + return new Complaint($this->httpClient, $this->requestBuilder, $this->hydrator); + } + + /** + * @return Unsubscribe + */ + public function unsubscribes() + { + return new Unsubscribe($this->httpClient, $this->requestBuilder, $this->hydrator); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Suppression/Bounce.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Suppression/Bounce.php new file mode 100644 index 0000000..b734c3c --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Suppression/Bounce.php @@ -0,0 +1,113 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Api\Suppression; + +use Mailgun\Api\HttpApi; +use Mailgun\Api\Pagination; +use Mailgun\Assert; +use Mailgun\Model\Suppression\Bounce\CreateResponse; +use Mailgun\Model\Suppression\Bounce\DeleteResponse; +use Mailgun\Model\Suppression\Bounce\IndexResponse; +use Mailgun\Model\Suppression\Bounce\ShowResponse; + +/** + * @see https://documentation.mailgun.com/api-suppressions.html#bounces + * + * @author Sean Johnson <sean@mailgun.com> + */ +class Bounce extends HttpApi +{ + use Pagination; + + /** + * @param string $domain Domain to list bounces for + * @param int $limit optional + * + * @return IndexResponse + */ + public function index($domain, $limit = 100) + { + Assert::stringNotEmpty($domain); + Assert::range($limit, 1, 10000, '"Limit" parameter must be between 1 and 10000'); + + $params = [ + 'limit' => $limit, + ]; + + $response = $this->httpGet(sprintf('/v3/%s/bounces', $domain), $params); + + return $this->hydrateResponse($response, IndexResponse::class); + } + + /** + * @param string $domain Domain to show bounce from + * @param string $address Bounce address to show + * + * @return ShowResponse + */ + public function show($domain, $address) + { + Assert::stringNotEmpty($domain); + Assert::stringNotEmpty($address); + + $response = $this->httpGet(sprintf('/v3/%s/bounces/%s', $domain, $address)); + + return $this->hydrateResponse($response, ShowResponse::class); + } + + /** + * @param string $domain Domain to create a bounce for + * @param string $address Address to create a bounce for + * @param array $params optional + * + * @return CreateResponse + */ + public function create($domain, $address, array $params = []) + { + Assert::stringNotEmpty($domain); + Assert::stringNotEmpty($address); + + $params['address'] = $address; + + $response = $this->httpPost(sprintf('/v3/%s/bounces', $domain), $params); + + return $this->hydrateResponse($response, CreateResponse::class); + } + + /** + * @param string $domain Domain to delete a bounce for + * @param string $address Bounce address to delete + * + * @return DeleteResponse + */ + public function delete($domain, $address) + { + Assert::stringNotEmpty($domain); + Assert::stringNotEmpty($address); + + $response = $this->httpDelete(sprintf('/v3/%s/bounces/%s', $domain, $address)); + + return $this->hydrateResponse($response, DeleteResponse::class); + } + + /** + * @param string $domain Domain to delete all bounces for + * + * @return DeleteResponse + */ + public function deleteAll($domain) + { + Assert::stringNotEmpty($domain); + + $response = $this->httpDelete(sprintf('/v3/%s/bounces', $domain)); + + return $this->hydrateResponse($response, DeleteResponse::class); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Suppression/Complaint.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Suppression/Complaint.php new file mode 100644 index 0000000..902d0a5 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Suppression/Complaint.php @@ -0,0 +1,116 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Api\Suppression; + +use Mailgun\Api\HttpApi; +use Mailgun\Api\Pagination; +use Mailgun\Assert; +use Mailgun\Model\Suppression\Complaint\CreateResponse; +use Mailgun\Model\Suppression\Complaint\DeleteResponse; +use Mailgun\Model\Suppression\Complaint\IndexResponse; +use Mailgun\Model\Suppression\Complaint\ShowResponse; + +/** + * @see https://documentation.mailgun.com/api-suppressions.html#complaints + * + * @author Sean Johnson <sean@mailgun.com> + */ +class Complaint extends HttpApi +{ + use Pagination; + + /** + * @param string $domain Domain to get complaints for + * @param int $limit optional + * + * @return IndexResponse + */ + public function index($domain, $limit = 100) + { + Assert::stringNotEmpty($domain); + Assert::range($limit, 1, 10000, 'Limit parameter must be between 1 and 10000'); + + $params = [ + 'limit' => $limit, + ]; + + $response = $this->httpGet(sprintf('/v3/%s/complaints', $domain), $params); + + return $this->hydrateResponse($response, IndexResponse::class); + } + + /** + * @param string $domain Domain to show complaint for + * @param string $address Complaint address + * + * @return ShowResponse + */ + public function show($domain, $address) + { + Assert::stringNotEmpty($domain); + Assert::stringNotEmpty($address); + $response = $this->httpGet(sprintf('/v3/%s/complaints/%s', $domain, $address)); + + return $this->hydrateResponse($response, ShowResponse::class); + } + + /** + * @param string $domain Domain to create complaint for + * @param string $address Complaint address + * @param string $createdAt (optional) rfc2822 compliant format. (new \DateTime())->format('r') + * + * @return CreateResponse + */ + public function create($domain, $address, $createdAt = null) + { + Assert::stringNotEmpty($domain); + Assert::stringNotEmpty($address); + Assert::stringNotEmpty($createdAt); + + $params['address'] = $address; + if (null !== $createdAt) { + $params['created_at'] = $createdAt; + } + + $response = $this->httpPost(sprintf('/v3/%s/complaints', $domain), $params); + + return $this->hydrateResponse($response, CreateResponse::class); + } + + /** + * @param string $domain Domain to delete complaint for + * @param string $address Complaint address + * + * @return DeleteResponse + */ + public function delete($domain, $address) + { + Assert::stringNotEmpty($domain); + Assert::stringNotEmpty($address); + + $response = $this->httpDelete(sprintf('/v3/%s/complaints/%s', $domain, $address)); + + return $this->hydrateResponse($response, DeleteResponse::class); + } + + /** + * @param string $domain Domain to delete all bounces for + * + * @return DeleteResponse + */ + public function deleteAll($domain) + { + Assert::stringNotEmpty($domain); + + $response = $this->httpDelete(sprintf('/v3/%s/complaints', $domain)); + + return $this->hydrateResponse($response, DeleteResponse::class); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Suppression/Unsubscribe.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Suppression/Unsubscribe.php new file mode 100644 index 0000000..72d894e --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Suppression/Unsubscribe.php @@ -0,0 +1,113 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Api\Suppression; + +use Mailgun\Api\HttpApi; +use Mailgun\Api\Pagination; +use Mailgun\Assert; +use Mailgun\Model\Suppression\Unsubscribe\CreateResponse; +use Mailgun\Model\Suppression\Unsubscribe\DeleteResponse; +use Mailgun\Model\Suppression\Unsubscribe\IndexResponse; +use Mailgun\Model\Suppression\Unsubscribe\ShowResponse; + +/** + * @see https://documentation.mailgun.com/api-suppressions.html#unsubscribes + * + * @author Sean Johnson <sean@mailgun.com> + */ +class Unsubscribe extends HttpApi +{ + use Pagination; + + /** + * @param string $domain Domain to get unsubscribes for + * @param int $limit optional + * + * @return IndexResponse + */ + public function index($domain, $limit = 100) + { + Assert::stringNotEmpty($domain); + Assert::range($limit, 1, 10000, 'Limit parameter must be between 1 and 10000'); + + $params = [ + 'limit' => $limit, + ]; + + $response = $this->httpGet(sprintf('/v3/%s/unsubscribes', $domain), $params); + + return $this->hydrateResponse($response, IndexResponse::class); + } + + /** + * @param string $domain Domain to show unsubscribe for + * @param string $address Unsubscribe address + * + * @return ShowResponse + */ + public function show($domain, $address) + { + Assert::stringNotEmpty($domain); + Assert::stringNotEmpty($address); + + $response = $this->httpGet(sprintf('/v3/%s/unsubscribes/%s', $domain, $address)); + + return $this->hydrateResponse($response, ShowResponse::class); + } + + /** + * @param string $domain Domain to create unsubscribe for + * @param string $address Unsubscribe address + * @param array $params optional + * + * @return CreateResponse + */ + public function create($domain, $address, array $params = []) + { + Assert::stringNotEmpty($domain); + Assert::stringNotEmpty($address); + + $params['address'] = $address; + + $response = $this->httpPost(sprintf('/v3/%s/unsubscribes', $domain), $params); + + return $this->hydrateResponse($response, CreateResponse::class); + } + + /** + * @param string $domain Domain to delete unsubscribe for + * @param string $address Unsubscribe address + * + * @return DeleteResponse + */ + public function delete($domain, $address) + { + Assert::stringNotEmpty($domain); + Assert::stringNotEmpty($address); + + $response = $this->httpDelete(sprintf('/v3/%s/unsubscribes/%s', $domain, $address)); + + return $this->hydrateResponse($response, DeleteResponse::class); + } + + /** + * @param string $domain Domain to delete all unsubscribes for + * + * @return DeleteResponse + */ + public function deleteAll($domain) + { + Assert::stringNotEmpty($domain); + + $response = $this->httpDelete(sprintf('/v3/%s/unsubscribes', $domain)); + + return $this->hydrateResponse($response, DeleteResponse::class); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Tag.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Tag.php new file mode 100644 index 0000000..625274e --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Tag.php @@ -0,0 +1,128 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Api; + +use Mailgun\Assert; +use Mailgun\Model\Tag\DeleteResponse; +use Mailgun\Model\Tag\IndexResponse; +use Mailgun\Model\Tag\ShowResponse; +use Mailgun\Model\Tag\StatisticsResponse; +use Mailgun\Model\Tag\UpdateResponse; +use Psr\Http\Message\ResponseInterface; + +/** + * {@link https://documentation.mailgun.com/api-tags.html#tags}. + * + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +class Tag extends HttpApi +{ + /** + * Returns a list of tags. + * + * @param string $domain + * @param int $limit + * + * @return IndexResponse|ResponseInterface + */ + public function index($domain, $limit = 100) + { + Assert::stringNotEmpty($domain); + Assert::integer($limit); + + $params = [ + 'limit' => $limit, + ]; + + $response = $this->httpGet(sprintf('/v3/%s/tags', $domain), $params); + + return $this->hydrateResponse($response, IndexResponse::class); + } + + /** + * Returns a single tag. + * + * @param string $domain Name of the domain + * @param string $tag + * + * @return ShowResponse|ResponseInterface + */ + public function show($domain, $tag) + { + Assert::stringNotEmpty($domain); + Assert::stringNotEmpty($tag); + + $response = $this->httpGet(sprintf('/v3/%s/tags/%s', $domain, $tag)); + + return $this->hydrateResponse($response, ShowResponse::class); + } + + /** + * Update a tag. + * + * @param string $domain + * @param string $tag + * @param string $description + * + * @return UpdateResponse|ResponseInterface + */ + public function update($domain, $tag, $description) + { + Assert::stringNotEmpty($domain); + Assert::stringNotEmpty($tag); + Assert::string($description); + + $params = [ + 'description' => $description, + ]; + + $response = $this->httpPut(sprintf('/v3/%s/tags/%s', $domain, $tag), $params); + + return $this->hydrateResponse($response, UpdateResponse::class); + } + + /** + * Returns statistics for a single tag. + * + * @param string $domain Name of the domain + * @param string $tag + * @param array $params + * + * @return StatisticsResponse|ResponseInterface + */ + public function stats($domain, $tag, array $params) + { + Assert::stringNotEmpty($domain); + Assert::stringNotEmpty($tag); + Assert::isArray($params); + + $response = $this->httpGet(sprintf('/v3/%s/tags/%s/stats', $domain, $tag), $params); + + return $this->hydrateResponse($response, StatisticsResponse::class); + } + + /** + * Removes a tag from the account. + * + * @param string $domain Name of the domain + * @param string $tag + * + * @return DeleteResponse|ResponseInterface + */ + public function delete($domain, $tag) + { + Assert::stringNotEmpty($domain); + Assert::stringNotEmpty($tag); + + $response = $this->httpDelete(sprintf('/v3/%s/tags/%s', $domain, $tag)); + + return $this->hydrateResponse($response, DeleteResponse::class); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Webhook.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Webhook.php new file mode 100644 index 0000000..0dd1f18 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Api/Webhook.php @@ -0,0 +1,160 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Api; + +use Http\Client\HttpClient; +use Mailgun\Assert; +use Mailgun\Hydrator\Hydrator; +use Mailgun\Model\Webhook\CreateResponse; +use Mailgun\Model\Webhook\DeleteResponse; +use Mailgun\Model\Webhook\IndexResponse; +use Mailgun\Model\Webhook\ShowResponse; +use Mailgun\Model\Webhook\UpdateResponse; +use Mailgun\RequestBuilder; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +class Webhook extends HttpApi +{ + /** + * @var string + */ + private $apiKey; + + /** + * @param HttpClient $httpClient + * @param RequestBuilder $requestBuilder + * @param Hydrator $hydrator + * @param string $apiKey + */ + public function __construct(HttpClient $httpClient, RequestBuilder $requestBuilder, Hydrator $hydrator, $apiKey) + { + parent::__construct($httpClient, $requestBuilder, $hydrator); + $this->apiKey = $apiKey; + } + + /** + * This function verifies the webhook signature with your API key to to see if it is authentic. + * + * If this function returns FALSE, you must not process the request. + * You should reject the request with status code 403 Forbidden. + * + * @param int $timestamp + * @param string $token + * @param string $signature + * + * @return bool + */ + public function verifyWebhookSignature($timestamp, $token, $signature) + { + if (empty($timestamp) || empty($token) || empty($signature)) { + return false; + } + + $hmac = hash_hmac('sha256', $timestamp.$token, $this->apiKey); + + if (function_exists('hash_equals')) { + // hash_equals is constant time, but will not be introduced until PHP 5.6 + return hash_equals($hmac, $signature); + } else { + return $hmac === $signature; + } + } + + /** + * @param string $domain + * + * @return IndexResponse + */ + public function index($domain) + { + Assert::notEmpty($domain); + $response = $this->httpGet(sprintf('/v3/domains/%s/webhooks', $domain)); + + return $this->hydrateResponse($response, IndexResponse::class); + } + + /** + * @param string $domain + * @param string $webhook + * + * @return ShowResponse + */ + public function show($domain, $webhook) + { + Assert::notEmpty($domain); + Assert::notEmpty($webhook); + $response = $this->httpGet(sprintf('/v3/domains/%s/webhooks/%s', $domain, $webhook)); + + return $this->hydrateResponse($response, ShowResponse::class); + } + + /** + * @param string $domain + * @param string $id + * @param string $url + * + * @return CreateResponse + */ + public function create($domain, $id, $url) + { + Assert::notEmpty($domain); + Assert::notEmpty($id); + Assert::notEmpty($url); + + $params = [ + 'id' => $id, + 'url' => $url, + ]; + + $response = $this->httpPost(sprintf('/v3/domains/%s/webhooks', $domain), $params); + + return $this->hydrateResponse($response, CreateResponse::class); + } + + /** + * @param string $domain + * @param string $id + * @param string $url + * + * @return UpdateResponse + */ + public function update($domain, $id, $url) + { + Assert::notEmpty($domain); + Assert::notEmpty($id); + Assert::notEmpty($url); + + $params = [ + 'url' => $url, + ]; + + $response = $this->httpPut(sprintf('/v3/domains/%s/webhooks/%s', $domain, $id), $params); + + return $this->hydrateResponse($response, UpdateResponse::class); + } + + /** + * @param string $domain + * @param string $id + * + * @return DeleteResponse + */ + public function delete($domain, $id) + { + Assert::notEmpty($domain); + Assert::notEmpty($id); + + $response = $this->httpDelete(sprintf('/v3/domains/%s/webhooks/%s', $domain, $id)); + + return $this->hydrateResponse($response, DeleteResponse::class); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Assert.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Assert.php new file mode 100644 index 0000000..e5cbf6d --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Assert.php @@ -0,0 +1,25 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun; + +use Mailgun\Exception\InvalidArgumentException; + +/** + * We need to override Webmozart\Assert because we want to throw our own Exception. + * + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +final class Assert extends \Webmozart\Assert\Assert +{ + protected static function reportInvalidArgument($message) + { + throw new InvalidArgumentException($message); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Connection/Exceptions/GenericHTTPError.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Connection/Exceptions/GenericHTTPError.php new file mode 100644 index 0000000..fc9560e --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Connection/Exceptions/GenericHTTPError.php @@ -0,0 +1,39 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Connection\Exceptions; + +use Mailgun\Exception; + +/** + * @deprecated Will be removed in 3.0 + */ +class GenericHTTPError extends \Exception implements Exception +{ + protected $httpResponseCode; + protected $httpResponseBody; + + public function __construct($message = null, $response_code = null, $response_body = null, $code = 0, \Exception $previous = null) + { + parent::__construct($message, $code, $previous); + + $this->httpResponseCode = $response_code; + $this->httpResponseBody = $response_body; + } + + public function getHttpResponseCode() + { + return $this->httpResponseCode; + } + + public function getHttpResponseBody() + { + return $this->httpResponseBody; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Connection/Exceptions/InvalidCredentials.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Connection/Exceptions/InvalidCredentials.php new file mode 100644 index 0000000..fad86fe --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Connection/Exceptions/InvalidCredentials.php @@ -0,0 +1,19 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Connection\Exceptions; + +use Mailgun\Exception; + +/** + * @deprecated Will be removed in 3.0 + */ +class InvalidCredentials extends \Exception implements Exception +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Connection/Exceptions/MissingEndpoint.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Connection/Exceptions/MissingEndpoint.php new file mode 100644 index 0000000..d2ce149 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Connection/Exceptions/MissingEndpoint.php @@ -0,0 +1,19 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Connection\Exceptions; + +use Mailgun\Exception; + +/** + * @deprecated Will be removed in 3.0 + */ +class MissingEndpoint extends \Exception implements Exception +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Connection/Exceptions/MissingRequiredParameters.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Connection/Exceptions/MissingRequiredParameters.php new file mode 100644 index 0000000..939c761 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Connection/Exceptions/MissingRequiredParameters.php @@ -0,0 +1,19 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Connection\Exceptions; + +use Mailgun\Exception; + +/** + * @deprecated Will be removed in 3.0 + */ +class MissingRequiredParameters extends \Exception implements Exception +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Connection/Exceptions/NoDomainsConfigured.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Connection/Exceptions/NoDomainsConfigured.php new file mode 100644 index 0000000..4ee6a3b --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Connection/Exceptions/NoDomainsConfigured.php @@ -0,0 +1,19 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Connection\Exceptions; + +use Mailgun\Exception; + +/** + * @deprecated Will be removed in 3.0 + */ +class NoDomainsConfigured extends \Exception implements Exception +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Connection/RestClient.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Connection/RestClient.php new file mode 100644 index 0000000..b9533f9 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Connection/RestClient.php @@ -0,0 +1,379 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Connection; + +use Http\Client\HttpClient; +use Http\Discovery\HttpClientDiscovery; +use Http\Discovery\MessageFactoryDiscovery; +use Http\Message\MultipartStream\MultipartStreamBuilder; +use Mailgun\Connection\Exceptions\GenericHTTPError; +use Mailgun\Connection\Exceptions\InvalidCredentials; +use Mailgun\Connection\Exceptions\MissingEndpoint; +use Mailgun\Connection\Exceptions\MissingRequiredParameters; +use Mailgun\Constants\Api; +use Mailgun\Constants\ExceptionMessages; +use Psr\Http\Message\ResponseInterface; + +/** + * This class is a wrapper for the HTTP client. + * + * @deprecated Will be removed in 3.0 + */ +class RestClient +{ + /** + * Your API key. + * + * @var string + */ + private $apiKey; + + /** + * @var HttpClient + */ + protected $httpClient; + + /** + * @var string + */ + protected $apiHost; + + /** + * The version of the API to use. + * + * @var string + */ + protected $apiVersion = 'v2'; + + /** + * If we should use SSL or not. + * + * @var bool + * + * @deprecated To be removed in 3.0 + */ + protected $sslEnabled = true; + + /** + * @param string $apiKey + * @param string $apiHost + * @param HttpClient $httpClient + */ + public function __construct($apiKey, $apiHost, HttpClient $httpClient = null) + { + $this->apiKey = $apiKey; + $this->apiHost = $apiHost; + $this->httpClient = $httpClient; + } + + /** + * @param string $method + * @param string $uri + * @param mixed $body + * @param array $files + * @param array $headers + * + * @throws GenericHTTPError + * @throws InvalidCredentials + * @throws MissingEndpoint + * @throws MissingRequiredParameters + * + * @return \stdClass + */ + protected function send($method, $uri, $body = null, $files = [], array $headers = []) + { + $headers['User-Agent'] = Api::SDK_USER_AGENT.'/'.Api::SDK_VERSION; + $headers['Authorization'] = 'Basic '.base64_encode(sprintf('%s:%s', Api::API_USER, $this->apiKey)); + + if (!empty($files)) { + $builder = new MultipartStreamBuilder(); + foreach ($files as $file) { + $builder->addResource($file['name'], $file['contents'], $file); + } + $body = $builder->build(); + $headers['Content-Type'] = 'multipart/form-data; boundary="'.$builder->getBoundary().'"'; + } elseif (is_array($body)) { + $body = http_build_query($body); + $headers['Content-Type'] = 'application/x-www-form-urlencoded'; + } + + $request = MessageFactoryDiscovery::find()->createRequest($method, $this->getApiUrl($uri), $headers, $body); + $response = $this->getHttpClient()->sendRequest($request); + + return $this->responseHandler($response); + } + + /** + * @param string $url + * + * @throws GenericHTTPError + * @throws InvalidCredentials + * @throws MissingEndpoint + * @throws MissingRequiredParameters + * + * @return \stdClass + */ + public function getAttachment($url) + { + $headers['User-Agent'] = Api::SDK_USER_AGENT.'/'.Api::SDK_VERSION; + $headers['Authorization'] = 'Basic '.base64_encode(sprintf('%s:%s', Api::API_USER, $this->apiKey)); + $request = MessageFactoryDiscovery::find()->createRequest('get', $url, $headers); + $response = HttpClientDiscovery::find()->sendRequest($request); + + return $this->responseHandler($response); + } + + /** + * @param string $endpointUrl + * @param array $postData + * @param array $files + * + * @throws GenericHTTPError + * @throws InvalidCredentials + * @throws MissingEndpoint + * @throws MissingRequiredParameters + * + * @return \stdClass + */ + public function post($endpointUrl, array $postData = [], $files = []) + { + $postFiles = []; + + $fields = ['message', 'attachment', 'inline']; + foreach ($fields as $fieldName) { + if (isset($files[$fieldName])) { + if (is_array($files[$fieldName])) { + foreach ($files[$fieldName] as $file) { + $postFiles[] = $this->prepareFile($fieldName, $file); + } + } else { + $postFiles[] = $this->prepareFile($fieldName, $files[$fieldName]); + } + } + } + + $postDataMultipart = []; + foreach ($postData as $key => $value) { + if (is_array($value)) { + foreach ($value as $subValue) { + $postDataMultipart[] = [ + 'name' => $key, + 'contents' => $subValue, + ]; + } + } else { + $postDataMultipart[] = [ + 'name' => $key, + 'contents' => $value, + ]; + } + } + + return $this->send('POST', $endpointUrl, [], array_merge($postDataMultipart, $postFiles)); + } + + /** + * @param string $endpointUrl + * @param array $queryString + * + * @throws GenericHTTPError + * @throws InvalidCredentials + * @throws MissingEndpoint + * @throws MissingRequiredParameters + * + * @return \stdClass + */ + public function get($endpointUrl, $queryString = []) + { + return $this->send('GET', $endpointUrl.'?'.http_build_query($queryString)); + } + + /** + * @param string $endpointUrl + * + * @throws GenericHTTPError + * @throws InvalidCredentials + * @throws MissingEndpoint + * @throws MissingRequiredParameters + * + * @return \stdClass + */ + public function delete($endpointUrl) + { + return $this->send('DELETE', $endpointUrl); + } + + /** + * @param string $endpointUrl + * @param mixed $putData + * + * @throws GenericHTTPError + * @throws InvalidCredentials + * @throws MissingEndpoint + * @throws MissingRequiredParameters + * + * @return \stdClass + */ + public function put($endpointUrl, $putData) + { + return $this->send('PUT', $endpointUrl, $putData); + } + + /** + * @param ResponseInterface $responseObj + * + * @throws GenericHTTPError + * @throws InvalidCredentials + * @throws MissingEndpoint + * @throws MissingRequiredParameters + * + * @return \stdClass + */ + public function responseHandler(ResponseInterface $responseObj) + { + $httpResponseCode = (int) $responseObj->getStatusCode(); + + switch ($httpResponseCode) { + case 200: + $data = (string) $responseObj->getBody(); + $jsonResponseData = json_decode($data, false); + $result = new \stdClass(); + // return response data as json if possible, raw if not + $result->http_response_body = $data && $jsonResponseData === null ? $data : $jsonResponseData; + $result->http_response_code = $httpResponseCode; + + return $result; + case 400: + throw new MissingRequiredParameters(ExceptionMessages::EXCEPTION_MISSING_REQUIRED_PARAMETERS.$this->getResponseExceptionMessage($responseObj)); + case 401: + throw new InvalidCredentials(ExceptionMessages::EXCEPTION_INVALID_CREDENTIALS); + case 404: + throw new MissingEndpoint(ExceptionMessages::EXCEPTION_MISSING_ENDPOINT.$this->getResponseExceptionMessage($responseObj)); + default: + throw new GenericHTTPError(ExceptionMessages::EXCEPTION_GENERIC_HTTP_ERROR, $httpResponseCode, $responseObj->getBody()); + } + } + + /** + * @param ResponseInterface $responseObj + * + * @return string + */ + protected function getResponseExceptionMessage(ResponseInterface $responseObj) + { + $body = (string) $responseObj->getBody(); + $response = json_decode($body); + if (json_last_error() == JSON_ERROR_NONE && isset($response->message)) { + return ' '.$response->message; + } + + return ''; + } + + /** + * Prepare a file for the postBody. + * + * @param string $fieldName + * @param string|array $filePath + * + * @return array + */ + protected function prepareFile($fieldName, $filePath) + { + $filename = null; + + if (is_array($filePath) && isset($filePath['fileContent'])) { + // File from memory + $filename = $filePath['filename']; + $resource = fopen('php://temp', 'r+'); + fwrite($resource, $filePath['fileContent']); + rewind($resource); + } else { + // Backward compatibility code + if (is_array($filePath) && isset($filePath['filePath'])) { + $filename = $filePath['remoteName']; + $filePath = $filePath['filePath']; + } + + // Remove leading @ symbol + if (strpos($filePath, '@') === 0) { + $filePath = substr($filePath, 1); + } + + $resource = fopen($filePath, 'r'); + } + + return [ + 'name' => $fieldName, + 'contents' => $resource, + 'filename' => $filename, + ]; + } + + /** + * @return HttpClient + */ + protected function getHttpClient() + { + if ($this->httpClient === null) { + $this->httpClient = HttpClientDiscovery::find(); + } + + return $this->httpClient; + } + + /** + * @param string $uri + * + * @return string + */ + private function getApiUrl($uri) + { + return $this->generateEndpoint($this->apiHost, $this->apiVersion, $this->sslEnabled).$uri; + } + + /** + * @param string $apiEndpoint + * @param string $apiVersion + * @param bool $ssl + * + * @return string + */ + private function generateEndpoint($apiEndpoint, $apiVersion, $ssl) + { + return ($ssl ? 'https://' : 'http://').$apiEndpoint.'/'.$apiVersion.'/'; + } + + /** + * @param string $apiVersion + * + * @return RestClient + */ + public function setApiVersion($apiVersion) + { + $this->apiVersion = $apiVersion; + + return $this; + } + + /** + * @param bool $sslEnabled + * + * @return RestClient + * + * @deprecated To be removed in 3.0 + */ + public function setSslEnabled($sslEnabled) + { + $this->sslEnabled = $sslEnabled; + + return $this; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Constants/Api.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Constants/Api.php new file mode 100644 index 0000000..16eadd8 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Constants/Api.php @@ -0,0 +1,24 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Constants; + +/** + * @deprecated Will be removed in 3.0 + */ +class Api +{ + const API_USER = 'api'; + const SDK_VERSION = '1.7'; + const SDK_USER_AGENT = 'mailgun-sdk-php'; + const RECIPIENT_COUNT_LIMIT = 1000; + const CAMPAIGN_ID_LIMIT = 3; + const TAG_LIMIT = 3; + const DEFAULT_TIME_ZONE = 'UTC'; +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Constants/ExceptionMessages.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Constants/ExceptionMessages.php new file mode 100644 index 0000000..ab370aa --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Constants/ExceptionMessages.php @@ -0,0 +1,29 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Constants; + +/** + * @deprecated Will be removed in 3.0 + */ +class ExceptionMessages +{ + const EXCEPTION_INVALID_CREDENTIALS = 'Your credentials are incorrect.'; + const EXCEPTION_GENERIC_HTTP_ERROR = 'An HTTP Error has occurred! Check your network connection and try again.'; + const EXCEPTION_MISSING_REQUIRED_PARAMETERS = 'The parameters passed to the API were invalid. Check your inputs!'; + const EXCEPTION_MISSING_REQUIRED_MIME_PARAMETERS = 'The parameters passed to the API were invalid. Check your inputs!'; + const EXCEPTION_MISSING_ENDPOINT = "The endpoint you've tried to access does not exist. Check your URL."; + const TOO_MANY_RECIPIENTS = "You've exceeded the maximum recipient count (1,000) on the to field with autosend disabled."; + const INVALID_PARAMETER_NON_ARRAY = "The parameter you've passed in position 2 must be an array."; + const INVALID_PARAMETER_ATTACHMENT = 'Attachments must be passed with an "@" preceding the file path. Web resources not supported.'; + const INVALID_PARAMETER_INLINE = 'Inline images must be passed with an "@" preceding the file path. Web resources not supported.'; + const TOO_MANY_PARAMETERS_CAMPAIGNS = "You've exceeded the maximum (3) campaigns for a single message."; + const TOO_MANY_PARAMETERS_TAGS = "You've exceeded the maximum (3) tags for a single message."; + const TOO_MANY_PARAMETERS_RECIPIENT = "You've exceeded the maximum recipient count (1,000) on the to field with autosend disabled."; +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Exception.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Exception.php new file mode 100644 index 0000000..5c41307 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Exception.php @@ -0,0 +1,19 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun; + +/** + * All Mailgun exception implements this exception. + * + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +interface Exception +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Exception/HttpClientException.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Exception/HttpClientException.php new file mode 100644 index 0000000..1dedffc --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Exception/HttpClientException.php @@ -0,0 +1,85 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Exception; + +use Mailgun\Exception; +use Psr\Http\Message\ResponseInterface; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +final class HttpClientException extends \RuntimeException implements Exception +{ + /** + * @var ResponseInterface|null + */ + private $response; + + /** + * @var array + */ + private $responseBody; + + /** + * @param string $message + * @param int $code + * @param ResponseInterface|null $response + */ + public function __construct($message, $code, ResponseInterface $response = null) + { + parent::__construct($message, $code); + + if ($response) { + $this->response = $response; + $body = $response->getBody()->__toString(); + if (strpos($response->getHeaderLine('Content-Type'), 'application/json') !== 0) { + $this->responseBody['message'] = $body; + } else { + $this->responseBody = json_decode($body, true); + } + } + } + + public static function badRequest(ResponseInterface $response = null) + { + return new self('The parameters passed to the API were invalid. Check your inputs!', 400, $response); + } + + public static function unauthorized(ResponseInterface $response = null) + { + return new self('Your credentials are incorrect.', 401, $response); + } + + public static function requestFailed(ResponseInterface $response = null) + { + return new self('Parameters were valid but request failed. Try again.', 402, $response); + } + + public static function notFound(ResponseInterface $response = null) + { + return new self('The endpoint you tried to access does not exist. Check your URL.', 404, $response); + } + + /** + * @return ResponseInterface + */ + public function getResponse() + { + return $this->response; + } + + /** + * @return array + */ + public function getResponseBody() + { + return $this->responseBody; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Exception/HttpServerException.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Exception/HttpServerException.php new file mode 100644 index 0000000..3d5aa27 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Exception/HttpServerException.php @@ -0,0 +1,33 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Exception; + +use Mailgun\Exception; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +final class HttpServerException extends \RuntimeException implements Exception +{ + public static function serverError($httpStatus = 500) + { + return new self('An unexpected error occurred at Mailgun\'s servers. Try again later and contact support of the error sill exists.', $httpStatus); + } + + public static function networkError(\Exception $previous) + { + return new self('Mailgun\'s servers was unreachable.', 0, $previous); + } + + public static function unknownHttpResponseCode($code) + { + return new self(sprintf('Unknown HTTP response code ("%d") received from the API server', $code)); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Exception/HydrationException.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Exception/HydrationException.php new file mode 100644 index 0000000..0647a01 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Exception/HydrationException.php @@ -0,0 +1,16 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Exception; + +use Mailgun\Exception; + +final class HydrationException extends \RuntimeException implements Exception +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Exception/InvalidArgumentException.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Exception/InvalidArgumentException.php new file mode 100644 index 0000000..3b3e6d7 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Exception/InvalidArgumentException.php @@ -0,0 +1,19 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Exception; + +use Mailgun\Exception; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +final class InvalidArgumentException extends \InvalidArgumentException implements Exception +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Exception/UnknownErrorException.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Exception/UnknownErrorException.php new file mode 100644 index 0000000..23b3a21 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Exception/UnknownErrorException.php @@ -0,0 +1,19 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Exception; + +use Mailgun\Exception; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +final class UnknownErrorException extends \Exception implements Exception +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/HttpClient/Plugin/History.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/HttpClient/Plugin/History.php new file mode 100644 index 0000000..53105b8 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/HttpClient/Plugin/History.php @@ -0,0 +1,45 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\HttpClient\Plugin; + +use Http\Client\Common\Plugin\Journal; +use Http\Client\Exception; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; + +/** + * A plugin to remember the last response. + * + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +final class History implements Journal +{ + /** + * @var ResponseInterface + */ + private $lastResponse; + + /** + * @return ResponseInterface|null + */ + public function getLastResponse() + { + return $this->lastResponse; + } + + public function addSuccess(RequestInterface $request, ResponseInterface $response) + { + $this->lastResponse = $response; + } + + public function addFailure(RequestInterface $request, Exception $exception) + { + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/HttpClient/Plugin/ReplaceUriPlugin.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/HttpClient/Plugin/ReplaceUriPlugin.php new file mode 100644 index 0000000..0ed1106 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/HttpClient/Plugin/ReplaceUriPlugin.php @@ -0,0 +1,45 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\HttpClient\Plugin; + +use Http\Client\Common\Plugin; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\UriInterface; + +/** + * Replaces a URI with a new one. Good for debugging. + * + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +final class ReplaceUriPlugin implements Plugin +{ + /** + * @var UriInterface + */ + private $uri; + + /** + * @param UriInterface $uri + */ + public function __construct(UriInterface $uri) + { + $this->uri = $uri; + } + + /** + * {@inheritdoc} + */ + public function handleRequest(RequestInterface $request, callable $next, callable $first) + { + $request = $request->withUri($this->uri); + + return $next($request); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/HttpClientConfigurator.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/HttpClientConfigurator.php new file mode 100644 index 0000000..d156738 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/HttpClientConfigurator.php @@ -0,0 +1,185 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun; + +use Http\Client\HttpClient; +use Http\Client\Common\PluginClient; +use Http\Discovery\HttpClientDiscovery; +use Http\Discovery\UriFactoryDiscovery; +use Http\Message\UriFactory; +use Http\Client\Common\Plugin; +use Mailgun\HttpClient\Plugin\History; +use Mailgun\HttpClient\Plugin\ReplaceUriPlugin; + +/** + * Configure a HTTP client. + * + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +final class HttpClientConfigurator +{ + /** + * @var string + */ + private $endpoint = 'https://api.mailgun.net'; + + /** + * If debug is true we will send all the request to the endpoint without appending any path. + * + * @var bool + */ + private $debug = false; + + /** + * @var string + */ + private $apiKey; + + /** + * @var UriFactory + */ + private $uriFactory; + + /** + * @var HttpClient + */ + private $httpClient; + + /** + * @var History + */ + private $responseHistory; + + public function __construct() + { + $this->responseHistory = new History(); + } + + /** + * @return PluginClient + */ + public function createConfiguredClient() + { + $plugins = [ + new Plugin\AddHostPlugin($this->getUriFactory()->createUri($this->endpoint)), + new Plugin\HeaderDefaultsPlugin([ + 'User-Agent' => 'mailgun-sdk-php/v2 (https://github.com/mailgun/mailgun-php)', + 'Authorization' => 'Basic '.base64_encode(sprintf('api:%s', $this->getApiKey())), + ]), + new Plugin\HistoryPlugin($this->responseHistory), + ]; + + if ($this->debug) { + $plugins[] = new ReplaceUriPlugin($this->getUriFactory()->createUri($this->endpoint)); + } + + return new PluginClient($this->getHttpClient(), $plugins); + } + + /** + * @param bool $debug + * + * @return HttpClientConfigurator + */ + public function setDebug($debug) + { + $this->debug = $debug; + + return $this; + } + + /** + * @param string $endpoint + * + * @return HttpClientConfigurator + */ + public function setEndpoint($endpoint) + { + $this->endpoint = $endpoint; + + return $this; + } + + /** + * @return string + */ + public function getApiKey() + { + return $this->apiKey; + } + + /** + * @param string $apiKey + * + * @return HttpClientConfigurator + */ + public function setApiKey($apiKey) + { + $this->apiKey = $apiKey; + + return $this; + } + + /** + * @return UriFactory + */ + private function getUriFactory() + { + if ($this->uriFactory === null) { + $this->uriFactory = UriFactoryDiscovery::find(); + } + + return $this->uriFactory; + } + + /** + * @param UriFactory $uriFactory + * + * @return HttpClientConfigurator + */ + public function setUriFactory(UriFactory $uriFactory) + { + $this->uriFactory = $uriFactory; + + return $this; + } + + /** + * @return HttpClient + */ + private function getHttpClient() + { + if ($this->httpClient === null) { + $this->httpClient = HttpClientDiscovery::find(); + } + + return $this->httpClient; + } + + /** + * @param HttpClient $httpClient + * + * @return HttpClientConfigurator + */ + public function setHttpClient(HttpClient $httpClient) + { + $this->httpClient = $httpClient; + + return $this; + } + + /** + * @return History + */ + public function getResponseHistory() + { + return $this->responseHistory; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Hydrator/ArrayHydrator.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Hydrator/ArrayHydrator.php new file mode 100644 index 0000000..4174a5e --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Hydrator/ArrayHydrator.php @@ -0,0 +1,42 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Hydrator; + +use Mailgun\Exception\HydrationException; +use Psr\Http\Message\ResponseInterface; + +/** + * Serialize an HTTP response to array. + * + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +final class ArrayHydrator implements Hydrator +{ + /** + * @param ResponseInterface $response + * @param string $class + * + * @return array + */ + public function hydrate(ResponseInterface $response, $class) + { + $body = $response->getBody()->__toString(); + if (strpos($response->getHeaderLine('Content-Type'), 'application/json') !== 0) { + throw new HydrationException('The ArrayHydrator cannot hydrate response with Content-Type:'.$response->getHeaderLine('Content-Type')); + } + + $content = json_decode($body, true); + if (JSON_ERROR_NONE !== json_last_error()) { + throw new HydrationException(sprintf('Error (%d) when trying to json_decode response', json_last_error())); + } + + return $content; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Hydrator/Hydrator.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Hydrator/Hydrator.php new file mode 100644 index 0000000..ac03eb0 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Hydrator/Hydrator.php @@ -0,0 +1,29 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Hydrator; + +use Mailgun\Exception\HydrationException; +use Psr\Http\Message\ResponseInterface; + +/** + * Deserialize a PSR-7 response to something else. + */ +interface Hydrator +{ + /** + * @param ResponseInterface $response + * @param string $class + * + * @return mixed + * + * @throws HydrationException + */ + public function hydrate(ResponseInterface $response, $class); +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Hydrator/ModelHydrator.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Hydrator/ModelHydrator.php new file mode 100644 index 0000000..83836c3 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Hydrator/ModelHydrator.php @@ -0,0 +1,50 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Hydrator; + +use Mailgun\Exception\HydrationException; +use Mailgun\Model\ApiResponse; +use Psr\Http\Message\ResponseInterface; + +/** + * Serialize an HTTP response to domain object. + * + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +final class ModelHydrator implements Hydrator +{ + /** + * @param ResponseInterface $response + * @param string $class + * + * @return ResponseInterface + */ + public function hydrate(ResponseInterface $response, $class) + { + $body = $response->getBody()->__toString(); + $contentType = $response->getHeaderLine('Content-Type'); + if (strpos($contentType, 'application/json') !== 0 && strpos($contentType, 'application/octet-stream') !== 0) { + throw new HydrationException('The ModelHydrator cannot hydrate response with Content-Type: '.$contentType); + } + + $data = json_decode($body, true); + if (JSON_ERROR_NONE !== json_last_error()) { + throw new HydrationException(sprintf('Error (%d) when trying to json_decode response', json_last_error())); + } + + if (is_subclass_of($class, ApiResponse::class)) { + $object = call_user_func($class.'::create', $data); + } else { + $object = new $class($data); + } + + return $object; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Hydrator/NoopHydrator.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Hydrator/NoopHydrator.php new file mode 100644 index 0000000..f5d8c43 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Hydrator/NoopHydrator.php @@ -0,0 +1,31 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Hydrator; + +use Psr\Http\Message\ResponseInterface; + +/** + * Do not serialize at all. Just return a PSR-7 response. + * + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +final class NoopHydrator implements Hydrator +{ + /** + * @param ResponseInterface $response + * @param string $class + * + * @throws \LogicException + */ + public function hydrate(ResponseInterface $response, $class) + { + throw new \LogicException('The NoopHydrator should never be called'); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Lists/OptInHandler.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Lists/OptInHandler.php new file mode 100644 index 0000000..a263563 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Lists/OptInHandler.php @@ -0,0 +1,60 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Lists; + +/** + * This class is used for creating a unique hash for + * mailing list subscription double-opt in requests. + * + * @see https://github.com/mailgun/mailgun-php/blob/master/src/Mailgun/Lists/README.md + */ +class OptInHandler +{ + /** + * @param string $mailingList + * @param string $secretAppId + * @param string $recipientAddress + * + * @return string + */ + public function generateHash($mailingList, $secretAppId, $recipientAddress) + { + $innerPayload = ['r' => $recipientAddress, 'l' => $mailingList]; + $encodedInnerPayload = base64_encode(json_encode($innerPayload)); + + $innerHash = hash_hmac('sha1', $encodedInnerPayload, $secretAppId); + $outerPayload = ['h' => $innerHash, 'p' => $encodedInnerPayload]; + + return urlencode(base64_encode(json_encode($outerPayload))); + } + + /** + * @param string $secretAppId + * @param string $uniqueHash + * + * @return array|bool + */ + public function validateHash($secretAppId, $uniqueHash) + { + $decodedOuterPayload = json_decode(base64_decode(urldecode($uniqueHash)), true); + + $decodedHash = $decodedOuterPayload['h']; + $innerPayload = $decodedOuterPayload['p']; + + $decodedInnerPayload = json_decode(base64_decode($innerPayload), true); + $computedInnerHash = hash_hmac('sha1', $innerPayload, $secretAppId); + + if ($computedInnerHash == $decodedHash) { + return ['recipientAddress' => $decodedInnerPayload['r'], 'mailingList' => $decodedInnerPayload['l']]; + } + + return false; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Lists/README.md b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Lists/README.md new file mode 100644 index 0000000..940e4be --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Lists/README.md @@ -0,0 +1,116 @@ +Mailgun - Lists +==================== + +This is the Mailgun PHP *Lists* utilities. + +The below assumes you've already installed the Mailgun PHP SDK in to your project. +If not, go back to the master README for instructions. + +There is currently one utility provided. + +OptInHandler: Provides methods for authenticating an OptInRequest. + +The typical flow for using this utility would be as follows: +**Recipient Requests Subscribe** -> [Validate Recipient Address] -> [Generate Opt In Link] -> [Email Recipient Opt In Link] +**Recipient Clicks Opt In Link** -> [Validate Opt In Link] -> [Subscribe User] -> [Send final confirmation] + +The above flow is modeled below. + +Usage - Opt-In Handler (Recipient Requests Subscribe) +----------------------------------------------------- +Here's how to use Opt-In Handler to validate Opt-In requests. + +```php +# First, instantiate the SDK with your API credentials, domain, and required parameters for example. +$mg = new Mailgun('key-example'); +$mgValidate = new Mailgun('pub-key-example'); + +$domain = 'example.com'; +$mailingList = 'youlist@example.com'; +$secretPassphrase = 'a_secret_passphrase'; +$recipientAddress = 'recipient@example.com'; + +# Let's validate the customer's email address, using Mailgun's validation endpoint. +$result = $mgValidate->get('address/validate', array('address' => $recipientAddress)); + +if($result->http_response_body->is_valid == true){ + # Next, instantiate an OptInHandler object from the SDK. + $optInHandler = $mg->OptInHandler(); + + # Next, generate a hash. + $generatedHash = $optInHandler->generateHash($mailingList, $secretPassphrase, $recipientAddress); + + # Now, let's send a confirmation to the recipient with our link. + $mg->sendMessage($domain, array('from' => 'bob@example.com', + 'to' => $recipientAddress, + 'subject' => 'Please Confirm!', + 'html' => "<html><body>Hello,<br><br>You have requested to be subscribed + to the mailing list $mailingList. Please <a + href=\"http://yourdomain.com/subscribe.php?hash=$generatedHash\"> + confirm</a> your subscription.<br><br>Thank you!</body></html>")); + + # Finally, let's add the subscriber to a Mailing List, as unsubscribed, so we can track non-conversions. + $mg->post("lists/$mailingList/members", array('address' => $recipientAddress, + 'subscribed' => 'no', + 'upsert' => 'yes')); +} +``` + +Usage - Opt-In Handler (Recipient Clicks Opt In Link) +----------------------------------------------------- +Here's how to use Opt-In Handler to validate an Opt-In Hash. + +```php +# First, instantiate the SDK with your API credentials and domain. +$mg = new Mailgun('key-example'); +$domain = 'example.com'; + +# Next, instantiate an OptInHandler object from the SDK. +$optInHandler = $mg->OptInHandler(); + +# Next, grab the hash. +$inboundHash = $_GET['hash']; +$secretPassphrase = 'a_secret_passphrase'; + +# Now, validate the captured hash. +$hashValidation = $optInHandler->validateHash($secretPassphrase, $inboundHash); + +# Lastly, check to see if we have results, parse, subscribe, and send confirmation. +if($hashValidation){ + $validatedList = $hashValidation['mailingList']; + $validatedRecipient = $hashValidation['recipientAddress']; + + $mg->put("lists/$validatedList/members/$validatedRecipient", + array('address' => $validatedRecipient, + 'subscribed' => 'yes')); + + $mg->sendMessage($domain, array('from' => 'bob@example.com', + 'to' => $validatedRecipient, + 'subject' => 'Confirmation Received!', + 'html' => "<html><body>Hello,<br><br>We've successfully subscribed + you to the list, $validatedList!<br><br>Thank you! + </body></html>")); +} +``` + +A few notes: +1. 'a_secret_passphrase' can be anything. It's used as the *key* in hashing, +since your email address will vary. +2. validateHash() will return an array containing the recipient address and list +address. +3. You should *always* send an email confirmation before and after the +subscription request. +4. WARNING: On $_GET['hash'], you need to sanitize this value to prevent +malicious attempts to inject code. + +Available Functions +----------------------------------------------------- + +`string generateHash(string $mailingList, string $secretAppId, string $recipientAddress)` + +`array validateHash(string $secretAppId, string $uniqueHash)` + +More Documentation +------------------ +See the official [Mailgun Docs](http://documentation.mailgun.com/api-sending.html) +for more information. diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Mailgun.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Mailgun.php new file mode 100644 index 0000000..a81ae2d --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Mailgun.php @@ -0,0 +1,381 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun; + +use Http\Client\Common\HttpMethodsClient; +use Http\Client\HttpClient; +use Mailgun\Connection\RestClient; +use Mailgun\Constants\ExceptionMessages; +use Mailgun\HttpClient\Plugin\History; +use Mailgun\Lists\OptInHandler; +use Mailgun\Messages\BatchMessage; +use Mailgun\Messages\Exceptions; +use Mailgun\Messages\MessageBuilder; +use Mailgun\Hydrator\ModelHydrator; +use Mailgun\Hydrator\Hydrator; +use Psr\Http\Message\ResponseInterface; + +/** + * This class is the base class for the Mailgun SDK. + */ +class Mailgun +{ + /** + * @var RestClient + * + * @depracated Will be removed in 3.0 + */ + protected $restClient; + + /** + * @var null|string + */ + protected $apiKey; + + /** + * @var HttpMethodsClient + */ + private $httpClient; + + /** + * @var Hydrator + */ + private $hydrator; + + /** + * @var RequestBuilder + */ + private $requestBuilder; + + /** + * This is a object that holds the last response from the API. + * + * @var History + */ + private $responseHistory = null; + + /** + * @param string|null $apiKey + * @param HttpClient|null $httpClient + * @param string $apiEndpoint + * @param Hydrator|null $hydrator + * @param RequestBuilder|null $requestBuilder + * + * @internal Use Mailgun::configure or Mailgun::create instead. + */ + public function __construct( + $apiKey = null, /* Deprecated, will be removed in 3.0 */ + HttpClient $httpClient = null, + $apiEndpoint = 'api.mailgun.net', /* Deprecated, will be removed in 3.0 */ + Hydrator $hydrator = null, + RequestBuilder $requestBuilder = null + ) { + $this->apiKey = $apiKey; + $this->restClient = new RestClient($apiKey, $apiEndpoint, $httpClient); + + $this->httpClient = $httpClient; + $this->requestBuilder = $requestBuilder ?: new RequestBuilder(); + $this->hydrator = $hydrator ?: new ModelHydrator(); + } + + /** + * @param HttpClientConfigurator $configurator + * @param Hydrator|null $hydrator + * @param RequestBuilder|null $requestBuilder + * + * @return Mailgun + */ + public static function configure( + HttpClientConfigurator $configurator, + Hydrator $hydrator = null, + RequestBuilder $requestBuilder = null + ) { + $httpClient = $configurator->createConfiguredClient(); + + return new self($configurator->getApiKey(), $httpClient, 'api.mailgun.net', $hydrator, $requestBuilder); + } + + /** + * @param string $apiKey + * + * @return Mailgun + */ + public static function create($apiKey) + { + $httpClientConfigurator = (new HttpClientConfigurator())->setApiKey($apiKey); + + return self::configure($httpClientConfigurator); + } + + /** + * This function allows the sending of a fully formed message OR a custom + * MIME string. If sending MIME, the string must be passed in to the 3rd + * position of the function call. + * + * @param string $workingDomain + * @param array $postData + * @param array $postFiles + * + * @throws Exceptions\MissingRequiredMIMEParameters + * + * @return \stdClass + * + * @deprecated Use Mailgun->message() instead. Will be removed in 3.0 + */ + public function sendMessage($workingDomain, $postData, $postFiles = []) + { + if (is_array($postFiles)) { + return $this->post("$workingDomain/messages", $postData, $postFiles); + } elseif (is_string($postFiles)) { + $tempFile = tempnam(sys_get_temp_dir(), 'MG_TMP_MIME'); + $fileHandle = fopen($tempFile, 'w'); + fwrite($fileHandle, $postFiles); + + $result = $this->post("$workingDomain/messages.mime", $postData, ['message' => $tempFile]); + fclose($fileHandle); + unlink($tempFile); + + return $result; + } else { + throw new Exceptions\MissingRequiredMIMEParameters(ExceptionMessages::EXCEPTION_MISSING_REQUIRED_MIME_PARAMETERS); + } + } + + /** + * This function checks the signature in a POST request to see if it is + * authentic. + * + * Pass an array of parameters. If you pass nothing, $_POST will be + * used instead. + * + * If this function returns FALSE, you must not process the request. + * You should reject the request with status code 403 Forbidden. + * + * @param array|null $postData + * + * @return bool + * + * @deprecated Use Mailgun->webhook() instead. Will be removed in 3.0 + */ + public function verifyWebhookSignature($postData = null) + { + if ($postData === null) { + $postData = $_POST; + } + if (!isset($postData['timestamp']) || !isset($postData['token']) || !isset($postData['signature'])) { + return false; + } + $hmac = hash_hmac('sha256', "{$postData['timestamp']}{$postData['token']}", $this->apiKey); + $sig = $postData['signature']; + if (function_exists('hash_equals')) { + // hash_equals is constant time, but will not be introduced until PHP 5.6 + return hash_equals($hmac, $sig); + } else { + return $hmac === $sig; + } + } + + /** + * @return ResponseInterface|null + */ + public function getLastResponse() + { + return $this->responseHistory->getLastResponse(); + } + + /** + * @param string $endpointUrl + * @param array $postData + * @param array $files + * + * @return \stdClass + * + * @deprecated Will be removed in 3.0 + */ + public function post($endpointUrl, $postData = [], $files = []) + { + return $this->restClient->post($endpointUrl, $postData, $files); + } + + /** + * @param string $endpointUrl + * @param array $queryString + * + * @return \stdClass + * + * @deprecated Will be removed in 3.0 + */ + public function get($endpointUrl, $queryString = []) + { + return $this->restClient->get($endpointUrl, $queryString); + } + + /** + * @param string $url + * + * @return \stdClass + * + * @deprecated Will be removed in 3.0 + */ + public function getAttachment($url) + { + return $this->restClient->getAttachment($url); + } + + /** + * @param string $endpointUrl + * + * @return \stdClass + * + * @deprecated Will be removed in 3.0 + */ + public function delete($endpointUrl) + { + return $this->restClient->delete($endpointUrl); + } + + /** + * @param string $endpointUrl + * @param array $putData + * + * @return \stdClass + * + * @deprecated Will be removed in 3.0 + */ + public function put($endpointUrl, $putData) + { + return $this->restClient->put($endpointUrl, $putData); + } + + /** + * @param string $apiVersion + * + * @return Mailgun + * + * @deprecated Will be removed in 3.0 + */ + public function setApiVersion($apiVersion) + { + $this->restClient->setApiVersion($apiVersion); + + return $this; + } + + /** + * @param bool $sslEnabled + * + * @return Mailgun + * + * @deprecated This will be removed in 3.0. Mailgun does not support non-secure connections to their API. + */ + public function setSslEnabled($sslEnabled) + { + $this->restClient->setSslEnabled($sslEnabled); + + return $this; + } + + /** + * @return MessageBuilder + * + * @deprecated Will be removed in 3.0 + */ + public function MessageBuilder() + { + return new MessageBuilder(); + } + + /** + * @return OptInHandler + * + * @deprecated Will be removed in 3.0 + */ + public function OptInHandler() + { + return new OptInHandler(); + } + + /** + * @param string $workingDomain + * @param bool $autoSend + * + * @return BatchMessage + * + * @deprecated Will be removed in 3.0 + */ + public function BatchMessage($workingDomain, $autoSend = true) + { + return new BatchMessage($this->restClient, $workingDomain, $autoSend); + } + + /** + * @return Api\Stats + */ + public function stats() + { + return new Api\Stats($this->httpClient, $this->requestBuilder, $this->hydrator); + } + + /** + * @return Api\Domain + */ + public function domains() + { + return new Api\Domain($this->httpClient, $this->requestBuilder, $this->hydrator); + } + + /** + * @return Api\Tag + */ + public function tags() + { + return new Api\Tag($this->httpClient, $this->requestBuilder, $this->hydrator); + } + + /** + * @return Api\Event + */ + public function events() + { + return new Api\Event($this->httpClient, $this->requestBuilder, $this->hydrator); + } + + /** + * @return Api\Route + */ + public function routes() + { + return new Api\Route($this->httpClient, $this->requestBuilder, $this->hydrator); + } + + /** + * @return Api\Webhook + */ + public function webhooks() + { + return new Api\Webhook($this->httpClient, $this->requestBuilder, $this->hydrator, $this->apiKey); + } + + /** + * @return Api\Message + */ + public function messages() + { + return new Api\Message($this->httpClient, $this->requestBuilder, $this->hydrator); + } + + /** + * @return Api\Suppression + */ + public function suppressions() + { + return new Api\Suppression($this->httpClient, $this->requestBuilder, $this->hydrator); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Messages/BatchMessage.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Messages/BatchMessage.php new file mode 100644 index 0000000..36de030 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Messages/BatchMessage.php @@ -0,0 +1,154 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Messages; + +use Mailgun\Constants\Api; +use Mailgun\Constants\ExceptionMessages; +use Mailgun\Messages\Exceptions\MissingRequiredMIMEParameters; +use Mailgun\Messages\Exceptions\TooManyParameters; + +/** + * This class is used for batch sending. See the official documentation (link below) + * for usage instructions. + * + * @see https://github.com/mailgun/mailgun-php/blob/master/src/Mailgun/Messages/README.md + */ +class BatchMessage extends MessageBuilder +{ + /** + * @var array + */ + private $batchRecipientAttributes; + + /** + * @var bool + */ + private $autoSend; + + /** + * @var \Mailgun\Connection\RestClient + */ + private $restClient; + + /** + * @var string + */ + private $workingDomain; + + /** + * @var array + */ + private $messageIds = []; + + /** + * @var string + */ + private $endpointUrl; + + /** + * @param \Mailgun\Connection\RestClient $restClient + * @param string $workingDomain + * @param bool $autoSend + */ + public function __construct($restClient, $workingDomain, $autoSend) + { + $this->batchRecipientAttributes = []; + $this->autoSend = $autoSend; + $this->restClient = $restClient; + $this->workingDomain = $workingDomain; + $this->endpointUrl = $workingDomain.'/messages'; + } + + /** + * @param string $headerName + * @param string $address + * @param array $variables + * + * @throws MissingRequiredMIMEParameters + * @throws TooManyParameters + */ + protected function addRecipient($headerName, $address, $variables) + { + if (array_key_exists($headerName, $this->counters['recipients'])) { + if ($this->counters['recipients'][$headerName] == Api::RECIPIENT_COUNT_LIMIT) { + if (false === $this->autoSend) { + throw new TooManyParameters(ExceptionMessages::TOO_MANY_RECIPIENTS); + } + $this->sendMessage(); + } + } + + $compiledAddress = $this->parseAddress($address, $variables); + + if (isset($this->message[$headerName])) { + array_push($this->message[$headerName], $compiledAddress); + } elseif ($headerName == 'h:reply-to') { + $this->message[$headerName] = $compiledAddress; + } else { + $this->message[$headerName] = [$compiledAddress]; + } + + if (array_key_exists($headerName, $this->counters['recipients'])) { + $this->counters['recipients'][$headerName] += 1; + if (is_array($variables) && !array_key_exists('id', $variables)) { + $variables['id'] = $this->counters['recipients'][$headerName]; + } + } + $this->batchRecipientAttributes["$address"] = $variables; + } + + /** + * @param array $message + * @param array $files + * + * @throws MissingRequiredMIMEParameters + */ + public function sendMessage($message = [], $files = []) + { + if (count($message) < 1) { + $message = $this->message; + $files = $this->files; + } + if (!array_key_exists('from', $message)) { + throw new MissingRequiredMIMEParameters(ExceptionMessages::EXCEPTION_MISSING_REQUIRED_MIME_PARAMETERS); + } elseif (!array_key_exists('to', $message)) { + throw new MissingRequiredMIMEParameters(ExceptionMessages::EXCEPTION_MISSING_REQUIRED_MIME_PARAMETERS); + } elseif (!array_key_exists('subject', $message)) { + throw new MissingRequiredMIMEParameters(ExceptionMessages::EXCEPTION_MISSING_REQUIRED_MIME_PARAMETERS); + } elseif ((!array_key_exists('text', $message) && !array_key_exists('html', $message))) { + throw new MissingRequiredMIMEParameters(ExceptionMessages::EXCEPTION_MISSING_REQUIRED_MIME_PARAMETERS); + } else { + $message['recipient-variables'] = json_encode($this->batchRecipientAttributes); + $response = $this->restClient->post($this->endpointUrl, $message, $files); + $this->batchRecipientAttributes = []; + $this->counters['recipients']['to'] = 0; + $this->counters['recipients']['cc'] = 0; + $this->counters['recipients']['bcc'] = 0; + unset($this->message['to']); + array_push($this->messageIds, $response->http_response_body->id); + } + } + + /** + * @throws MissingRequiredMIMEParameters + */ + public function finalize() + { + $this->sendMessage(); + } + + /** + * @return string[] + */ + public function getMessageIds() + { + return $this->messageIds; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Messages/Exceptions/InvalidParameter.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Messages/Exceptions/InvalidParameter.php new file mode 100644 index 0000000..9520e41 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Messages/Exceptions/InvalidParameter.php @@ -0,0 +1,16 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Messages\Exceptions; + +use Mailgun\Exception; + +class InvalidParameter extends \Exception implements Exception +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Messages/Exceptions/InvalidParameterType.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Messages/Exceptions/InvalidParameterType.php new file mode 100644 index 0000000..c06cbf5 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Messages/Exceptions/InvalidParameterType.php @@ -0,0 +1,16 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Messages\Exceptions; + +use Mailgun\Exception; + +class InvalidParameterType extends \Exception implements Exception +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Messages/Exceptions/MissingRequiredMIMEParameters.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Messages/Exceptions/MissingRequiredMIMEParameters.php new file mode 100644 index 0000000..9eb1df5 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Messages/Exceptions/MissingRequiredMIMEParameters.php @@ -0,0 +1,16 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Messages\Exceptions; + +use Mailgun\Exception; + +class MissingRequiredMIMEParameters extends \Exception implements Exception +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Messages/Exceptions/TooManyParameters.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Messages/Exceptions/TooManyParameters.php new file mode 100644 index 0000000..5982bc2 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Messages/Exceptions/TooManyParameters.php @@ -0,0 +1,16 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Messages\Exceptions; + +use Mailgun\Exception; + +class TooManyParameters extends \Exception implements Exception +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Messages/MessageBuilder.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Messages/MessageBuilder.php new file mode 100644 index 0000000..67aea07 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Messages/MessageBuilder.php @@ -0,0 +1,529 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Messages; + +use Mailgun\Constants\Api; +use Mailgun\Constants\ExceptionMessages; +use Mailgun\Messages\Exceptions\InvalidParameter; +use Mailgun\Messages\Exceptions\TooManyParameters; + +/** + * This class is used for composing a properly formed + * message object. Dealing with arrays can be cumbersome, + * this class makes the process easier. See the official + * documentation (link below) for usage instructions. + * + * @see https://github.com/mailgun/mailgun-php/blob/master/src/Mailgun/Messages/README.md + */ +class MessageBuilder +{ + /** + * @var array + */ + protected $message = []; + + /** + * @var array + */ + protected $variables = []; + + /** + * @var array + */ + protected $files = []; + + /** + * @var array + */ + protected $counters = [ + 'recipients' => [ + 'to' => 0, + 'cc' => 0, + 'bcc' => 0, + ], + 'attributes' => [ + 'attachment' => 0, + 'campaign_id' => 0, + 'custom_option' => 0, + 'tag' => 0, + ], + ]; + + /** + * @param array $params + * @param string $key + * @param mixed $default + * + * @return mixed + */ + protected function safeGet($params, $key, $default) + { + if (array_key_exists($key, $params)) { + return $params[$key]; + } + + return $default; + } + + /** + * @param array $params + * + * @return mixed|string + */ + protected function getFullName($params) + { + if (array_key_exists('first', $params)) { + $first = $this->safeGet($params, 'first', ''); + $last = $this->safeGet($params, 'last', ''); + + return trim("$first $last"); + } + + return $this->safeGet($params, 'full_name', ''); + } + + /** + * @param string $address + * @param array $variables + * + * @return string + */ + protected function parseAddress($address, $variables) + { + if (!is_array($variables)) { + return $address; + } + $fullName = $this->getFullName($variables); + if ($fullName != null) { + return sprintf('"%s" <%s>', $fullName, $address); + } + + return $address; + } + + /** + * @param string $headerName + * @param string $address + * @param array $variables + */ + protected function addRecipient($headerName, $address, $variables) + { + $compiledAddress = $this->parseAddress($address, $variables); + + if ($headerName === 'h:reply-to') { + $this->message[$headerName] = $compiledAddress; + } elseif (isset($this->message[$headerName])) { + array_push($this->message[$headerName], $compiledAddress); + } else { + $this->message[$headerName] = [$compiledAddress]; + } + if (array_key_exists($headerName, $this->counters['recipients'])) { + $this->counters['recipients'][$headerName] += 1; + } + } + + /** + * @param string $address + * @param array|null $variables + * + * @throws TooManyParameters + * + * @return mixed + */ + public function addToRecipient($address, $variables = null) + { + if ($this->counters['recipients']['to'] > Api::RECIPIENT_COUNT_LIMIT) { + throw new TooManyParameters(ExceptionMessages::TOO_MANY_PARAMETERS_RECIPIENT); + } + + $variables = is_array($variables) ? $variables : []; + + $this->addRecipient('to', $address, $variables); + + return end($this->message['to']); + } + + /** + * @param string $address + * @param array|null $variables + * + * @throws TooManyParameters + * + * @return mixed + */ + public function addCcRecipient($address, $variables = null) + { + if ($this->counters['recipients']['cc'] > Api::RECIPIENT_COUNT_LIMIT) { + throw new TooManyParameters(ExceptionMessages::TOO_MANY_PARAMETERS_RECIPIENT); + } + + $variables = is_array($variables) ? $variables : []; + + $this->addRecipient('cc', $address, $variables); + + return end($this->message['cc']); + } + + /** + * @param string $address + * @param array|null $variables + * + * @throws TooManyParameters + * + * @return mixed + */ + public function addBccRecipient($address, $variables = null) + { + if ($this->counters['recipients']['bcc'] > Api::RECIPIENT_COUNT_LIMIT) { + throw new TooManyParameters(ExceptionMessages::TOO_MANY_PARAMETERS_RECIPIENT); + } + + $variables = is_array($variables) ? $variables : []; + + $this->addRecipient('bcc', $address, $variables); + + return end($this->message['bcc']); + } + + /** + * @param string $address + * @param array|null $variables + * + * @return mixed + */ + public function setFromAddress($address, $variables = null) + { + $variables = is_array($variables) ? $variables : []; + + $this->addRecipient('from', $address, $variables); + + return $this->message['from']; + } + + /** + * @param string $address + * @param array|null $variables + * + * @return mixed + */ + public function setReplyToAddress($address, $variables = null) + { + $variables = is_array($variables) ? $variables : []; + + $this->addRecipient('h:reply-to', $address, $variables); + + return $this->message['h:reply-to']; + } + + /** + * @param string $subject + * + * @return mixed + */ + public function setSubject($subject = '') + { + if ($subject == null || $subject == '') { + $subject = ' '; + } + $this->message['subject'] = $subject; + + return $this->message['subject']; + } + + /** + * @param string $headerName + * @param mixed $headerData + * + * @return mixed + */ + public function addCustomHeader($headerName, $headerData) + { + if (!preg_match('/^h:/i', $headerName)) { + $headerName = 'h:'.$headerName; + } + + if (array_key_exists($headerName, $this->message)) { + if (is_array($this->message[$headerName])) { + $this->message[$headerName][] = $headerData; + } else { + $this->message[$headerName] = [$this->message[$headerName], $headerData]; + } + } else { + $this->message[$headerName] = $headerData; + } + + return $this->message[$headerName]; + } + + /** + * @param string $textBody + * + * @return string + */ + public function setTextBody($textBody) + { + if ($textBody == null || $textBody == '') { + $textBody = ' '; + } + $this->message['text'] = $textBody; + + return $this->message['text']; + } + + /** + * @param string $htmlBody + * + * @return string + */ + public function setHtmlBody($htmlBody) + { + if ($htmlBody == null || $htmlBody == '') { + $htmlBody = ' '; + } + $this->message['html'] = $htmlBody; + + return $this->message['html']; + } + + /** + * @param string $attachmentPath + * @param string|null $attachmentName + * + * @return bool + */ + public function addAttachment($attachmentPath, $attachmentName = null) + { + if (isset($this->files['attachment'])) { + $attachment = [ + 'filePath' => $attachmentPath, + 'remoteName' => $attachmentName, + ]; + array_push($this->files['attachment'], $attachment); + } else { + $this->files['attachment'] = [ + [ + 'filePath' => $attachmentPath, + 'remoteName' => $attachmentName, + ], + ]; + } + + return true; + } + + /** + * @param string $inlineImagePath + * @param string|null $inlineImageName + * + * @throws InvalidParameter + * + * @return bool + */ + public function addInlineImage($inlineImagePath, $inlineImageName = null) + { + if (strpos($inlineImagePath, '@') !== 0) { + throw new InvalidParameter(ExceptionMessages::INVALID_PARAMETER_INLINE); + } + + $this->files['inline'][] = [ + 'filePath' => $inlineImagePath, + 'remoteName' => $inlineImageName, + ]; + + return true; + } + + /** + * @param bool $testMode + * + * @return string + */ + public function setTestMode($testMode) + { + if (filter_var($testMode, FILTER_VALIDATE_BOOLEAN)) { + $testMode = 'yes'; + } else { + $testMode = 'no'; + } + $this->message['o:testmode'] = $testMode; + + return $this->message['o:testmode']; + } + + /** + * @param string|int $campaignId + * + * @throws TooManyParameters + * + * @return string|int + */ + public function addCampaignId($campaignId) + { + if ($this->counters['attributes']['campaign_id'] < Api::CAMPAIGN_ID_LIMIT) { + if (isset($this->message['o:campaign'])) { + array_push($this->message['o:campaign'], $campaignId); + } else { + $this->message['o:campaign'] = [$campaignId]; + } + $this->counters['attributes']['campaign_id'] += 1; + + return $this->message['o:campaign']; + } else { + throw new TooManyParameters(ExceptionMessages::TOO_MANY_PARAMETERS_CAMPAIGNS); + } + } + + /** + * @param string $tag + * + * @throws TooManyParameters + */ + public function addTag($tag) + { + if ($this->counters['attributes']['tag'] < Api::TAG_LIMIT) { + if (isset($this->message['o:tag'])) { + array_push($this->message['o:tag'], $tag); + } else { + $this->message['o:tag'] = [$tag]; + } + $this->counters['attributes']['tag'] += 1; + + return $this->message['o:tag']; + } else { + throw new TooManyParameters(ExceptionMessages::TOO_MANY_PARAMETERS_TAGS); + } + } + + /** + * @param bool $enabled + * + * @return mixed + */ + public function setDkim($enabled) + { + if (filter_var($enabled, FILTER_VALIDATE_BOOLEAN)) { + $enabled = 'yes'; + } else { + $enabled = 'no'; + } + $this->message['o:dkim'] = $enabled; + + return $this->message['o:dkim']; + } + + /** + * @param bool $enabled + * + * @return string + */ + public function setOpenTracking($enabled) + { + if (filter_var($enabled, FILTER_VALIDATE_BOOLEAN)) { + $enabled = 'yes'; + } else { + $enabled = 'no'; + } + $this->message['o:tracking-opens'] = $enabled; + + return $this->message['o:tracking-opens']; + } + + /** + * @param bool $enabled + * + * @return string + */ + public function setClickTracking($enabled) + { + if (filter_var($enabled, FILTER_VALIDATE_BOOLEAN)) { + $enabled = 'yes'; + } elseif ($enabled == 'html') { + $enabled = 'html'; + } else { + $enabled = 'no'; + } + $this->message['o:tracking-clicks'] = $enabled; + + return $this->message['o:tracking-clicks']; + } + + /** + * @param string $timeDate + * @param string|null $timeZone + * + * @return string + */ + public function setDeliveryTime($timeDate, $timeZone = null) + { + if (isset($timeZone)) { + $timeZoneObj = new \DateTimeZone("$timeZone"); + } else { + $timeZoneObj = new \DateTimeZone(Api::DEFAULT_TIME_ZONE); + } + + $dateTimeObj = new \DateTime($timeDate, $timeZoneObj); + $formattedTimeDate = $dateTimeObj->format(\DateTime::RFC2822); + $this->message['o:deliverytime'] = $formattedTimeDate; + + return $this->message['o:deliverytime']; + } + + /** + * @param string $customName + * @param mixed $data + */ + public function addCustomData($customName, $data) + { + $this->message['v:'.$customName] = json_encode($data); + } + + /** + * @param string $parameterName + * @param mixed $data + * + * @return mixed + */ + public function addCustomParameter($parameterName, $data) + { + if (isset($this->message[$parameterName])) { + array_push($this->message[$parameterName], $data); + + return $this->message[$parameterName]; + } else { + $this->message[$parameterName] = [$data]; + + return $this->message[$parameterName]; + } + } + + /** + * @param array $message + */ + public function setMessage($message) + { + $this->message = $message; + } + + /** + * @return array + */ + public function getMessage() + { + return $this->message; + } + + /** + * @return array + */ + public function getFiles() + { + return $this->files; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Messages/README.md b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Messages/README.md new file mode 100644 index 0000000..34cab45 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Messages/README.md @@ -0,0 +1,138 @@ +Mailgun - Messages +==================== + +This is the Mailgun PHP *Message* utilities. + +The below assumes you've already installed the Mailgun PHP SDK in to your +project. If not, go back to the master README for instructions. + +There are two utilities included, Message Builder and Batch Message. + +Message Builder: Allows you to build a message object by calling methods for +each MIME attribute. +Batch Message: Inherits Message Builder and allows you to iterate through +recipients from a list. Messages will fire after the 1,000th recipient has been +added. + +Usage - Message Builder +----------------------- +Here's how to use Message Builder to build your Message. + +```php +# First, instantiate the SDK with your API credentials and define your domain. +$mg = new Mailgun("key-example"); +$domain = "example.com"; + +# Next, instantiate a Message Builder object from the SDK. +$messageBldr = $mg->MessageBuilder(); + +# Define the from address. +$messageBldr->setFromAddress("me@example.com", array("first"=>"PHP", "last" => "SDK")); +# Define a to recipient. +$messageBldr->addToRecipient("john.doe@example.com", array("first" => "John", "last" => "Doe")); +# Define a cc recipient. +$messageBldr->addCcRecipient("sally.doe@example.com", array("first" => "Sally", "last" => "Doe")); +# Define the subject. +$messageBldr->setSubject("A message from the PHP SDK using Message Builder!"); +# Define the body of the message. +$messageBldr->setTextBody("This is the text body of the message!"); + +# Other Optional Parameters. +$messageBldr->addCampaignId("My-Awesome-Campaign"); +$messageBldr->addCustomHeader("Customer-Id", "12345"); +$messageBldr->addAttachment("@/tron.jpg"); +$messageBldr->setDeliveryTime("tomorrow 8:00AM", "PST"); +$messageBldr->setClickTracking(true); + +# Finally, send the message. +$mg->post("{$domain}/messages", $messageBldr->getMessage(), $messageBldr->getFiles()); +``` + +Available Functions +----------------------------------------------------- + +`string addToRecipient(string $address, array $attributes)` + +`string addCcRecipient(string $address, array $attributes)` + +`string addBccRecipient(string $address, array $attributes)` + +`string setFromAddress(string $address, array $attributes)` + +`string setSubject(string $subject)` + +`string setTextBody(string $textBody)` + +`string setHtmlBody(string $htmlBody)` + +`bool addAttachment(string $attachmentPath, $attachmentName = null)` + +`bool addInlineImage(string $inlineImagePath)` + +`string setTestMode(bool $testMode)` + +`string addCampaignId(string $campaignId)` + +`string setDkim(bool $enabled)` + +`string setOpenTracking($enabled)` + +`string setClickTracking($enabled)` + +`string setDeliveryTime(string $timeDate, string $timeZone)` + +`string addCustomData(string $optionName, string $data)` + +`string addCustomParameter(string $parameterName, string $data)` + +`array getMessage()` + +`array getFiles()` + + +Usage - Batch Message +--------------------- +Here's how to use Batch Message to easily handle batch sending jobs. + +```php +# First, instantiate the SDK with your API credentials and define your domain. +$mg = new Mailgun("key-example"); +$domain = "example.com"; + +# Next, instantiate a Message Builder object from the SDK, pass in your sending +domain. +$batchMsg = $mg->BatchMessage($domain); + +# Define the from address. +$batchMsg->setFromAddress("me@example.com", array("first"=>"PHP", "last" => "SDK")); +# Define the subject. +$batchMsg->setSubject("A Batch Message from the PHP SDK!"); +# Define the body of the message. +$batchMsg->setTextBody("This is the text body of the message!"); + +# Next, let's add a few recipients to the batch job. +$batchMsg->addToRecipient("john.doe@example.com", array("first" => "John", "last" => "Doe")); +$batchMsg->addToRecipient("sally.doe@example.com", array("first" => "Sally", "last" => "Doe")); +$batchMsg->addToRecipient("mike.jones@example.com", array("first" => "Mike", "last" => "Jones")); +... +// After 1,000 recipients, Batch Message will automatically post your message to +the messages endpoint. + +// Call finalize() to send any remaining recipients still in the buffer. +$batchMsg->finalize(); + +``` + +Available Functions (Inherits all Batch Message and Messages Functions) +----------------------------------------------------------------------- + +`addToRecipient(string $address, string $attributes)` + +`sendMessage(array $message, array $files)` + +`array finalize()` + +More Documentation +------------------ +See the official [Mailgun Docs](http://documentation.mailgun.com/api-sending.html) +for more information. diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/ApiResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/ApiResponse.php new file mode 100644 index 0000000..b176214 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/ApiResponse.php @@ -0,0 +1,25 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +interface ApiResponse +{ + /** + * Create an API response object from the HTTP response from the API server. + * + * @param array $data + * + * @return self + */ + public static function create(array $data); +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/ConnectionResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/ConnectionResponse.php new file mode 100644 index 0000000..a145d73 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/ConnectionResponse.php @@ -0,0 +1,72 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Domain; + +use Mailgun\Model\ApiResponse; + +/** + * @author Sean Johnson <sean@mailgun.com> + */ +final class ConnectionResponse implements ApiResponse +{ + /** + * @var bool + */ + private $noVerify; + + /** + * @var bool + */ + private $requireTLS; + + /** + * @param array $data + * + * @return self + */ + public static function create(array $data) + { + if (!isset($data['connection'])) { + return; + } + $connSettings = $data['connection']; + + return new self( + isset($connSettings['skip_verification']) ? $connSettings['skip_verification'] : null, + isset($connSettings['require_tls']) ? $connSettings['require_tls'] : null + ); + } + + /** + * @param bool $noVerify Disable remote TLS certificate verification + * @param bool $requireTLS Requires TLS for all outbound communication + */ + private function __construct($noVerify, $requireTLS) + { + $this->noVerify = $noVerify; + $this->requireTLS = $requireTLS; + } + + /** + * @return bool + */ + public function getSkipVerification() + { + return $this->noVerify; + } + + /** + * @return bool + */ + public function getRequireTLS() + { + return $this->requireTLS; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/CreateCredentialResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/CreateCredentialResponse.php new file mode 100644 index 0000000..1e6afe6 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/CreateCredentialResponse.php @@ -0,0 +1,49 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Domain; + +use Mailgun\Model\ApiResponse; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +final class CreateCredentialResponse implements ApiResponse +{ + /** + * @var string + */ + private $message; + + /** + * @param string $message + */ + private function __construct($message) + { + $this->message = $message; + } + + /** + * @param array $data + * + * @return self + */ + public static function create(array $data) + { + return new self(isset($data['message']) ? $data['message'] : null); + } + + /** + * @return string + */ + public function getMessage() + { + return $this->message; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/CreateResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/CreateResponse.php new file mode 100644 index 0000000..7fa1f4d --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/CreateResponse.php @@ -0,0 +1,119 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Domain; + +use Mailgun\Model\ApiResponse; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +final class CreateResponse implements ApiResponse +{ + /** + * @var string + */ + private $message; + + /** + * @var Domain + */ + private $domain; + + /** + * @var DnsRecord[] + */ + private $inboundDnsRecords; + + /** + * @var DnsRecord[] + */ + private $outboundDnsRecords; + + /** + * @param array $data + * + * @return self + */ + public static function create(array $data) + { + $rx = []; + $tx = []; + $domain = null; + $message = null; + + if (isset($data['domain'])) { + $domain = Domain::create($data['domain']); + } + + if (isset($data['message'])) { + $message = $data['message']; + } + + if (isset($data['receiving_dns_records'])) { + foreach ($data['receiving_dns_records'] as $item) { + $rx[] = DnsRecord::create($item); + } + } + + if (isset($data['sending_dns_records'])) { + foreach ($data['sending_dns_records'] as $item) { + $tx[] = DnsRecord::create($item); + } + } + + return new self($domain, $rx, $tx, $message); + } + + /** + * @param Domain $domainInfo + * @param DnsRecord[] $rxRecords + * @param DnsRecord[] $txRecords + * @param string $message + */ + private function __construct(Domain $domainInfo, array $rxRecords, array $txRecords, $message) + { + $this->domain = $domainInfo; + $this->inboundDnsRecords = $rxRecords; + $this->outboundDnsRecords = $txRecords; + $this->message = $message; + } + + /** + * @return Domain + */ + public function getDomain() + { + return $this->domain; + } + + /** + * @return DnsRecord[] + */ + public function getInboundDNSRecords() + { + return $this->inboundDnsRecords; + } + + /** + * @return DnsRecord[] + */ + public function getOutboundDNSRecords() + { + return $this->outboundDnsRecords; + } + + /** + * @return string + */ + public function getMessage() + { + return $this->message; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/CredentialResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/CredentialResponse.php new file mode 100644 index 0000000..5706572 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/CredentialResponse.php @@ -0,0 +1,77 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Domain; + +use Mailgun\Model\ApiResponse; + +/** + * @author Sean Johnson <sean@mailgun.com> + */ +final class CredentialResponse implements ApiResponse +{ + /** + * @var int + */ + private $totalCount; + + /** + * @var CredentialResponseItem[] + */ + private $items; + + /** + * @param array $data + * + * @return self + */ + public static function create(array $data) + { + $items = []; + if (isset($data['items'])) { + foreach ($data['items'] as $item) { + $items[] = CredentialResponseItem::create($item); + } + } + + if (isset($data['total_count'])) { + $count = $data['total_count']; + } else { + $count = count($items); + } + + return new self($count, $items); + } + + /** + * @param int $totalCount + * @param CredentialResponseItem[] $items + */ + private function __construct($totalCount, array $items) + { + $this->totalCount = $totalCount; + $this->items = $items; + } + + /** + * @return int + */ + public function getTotalCount() + { + return $this->totalCount; + } + + /** + * @return CredentialResponseItem[] + */ + public function getCredentials() + { + return $this->items; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/CredentialResponseItem.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/CredentialResponseItem.php new file mode 100644 index 0000000..c19a85a --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/CredentialResponseItem.php @@ -0,0 +1,97 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Domain; + +/** + * @author Sean Johnson <sean@mailgun.com> + */ +final class CredentialResponseItem +{ + /** + * @var int|null + */ + private $sizeBytes; + + /** + * @var \DateTime + */ + private $createdAt; + + /** + * @var string + */ + private $mailbox; + + /** + * @var string + */ + private $login; + + /** + * @param array $data + * + * @return self + */ + public static function create(array $data) + { + $sizeBytes = isset($data['size_bytes']) ? $data['size_bytes'] : null; + $mailbox = isset($data['mailbox']) ? $data['mailbox'] : null; + $login = isset($data['login']) ? $data['login'] : null; + $createdAt = isset($data['created_at']) ? new \DateTime($data['created_at']) : null; + + return new self($sizeBytes, $createdAt, $mailbox, $login); + } + + /** + * @param int $sizeBytes + * @param \DateTime $createdAt + * @param string $mailbox + * @param string $login + */ + private function __construct($sizeBytes, \DateTime $createdAt, $mailbox, $login) + { + $this->sizeBytes = $sizeBytes; + $this->createdAt = $createdAt; + $this->mailbox = $mailbox; + $this->login = $login; + } + + /** + * @return int|null + */ + public function getSizeBytes() + { + return $this->sizeBytes; + } + + /** + * @return \DateTime + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + * @return string + */ + public function getMailbox() + { + return $this->mailbox; + } + + /** + * @return string + */ + public function getLogin() + { + return $this->login; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/DeleteCredentialResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/DeleteCredentialResponse.php new file mode 100644 index 0000000..2cd8625 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/DeleteCredentialResponse.php @@ -0,0 +1,83 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Domain; + +use Mailgun\Model\ApiResponse; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +final class DeleteCredentialResponse implements ApiResponse +{ + /** + * @var string + */ + private $message; + + /** + * @var string + */ + private $error; + + /** + * @var string + */ + private $spec; + + /** + * @param string $message + * @param string $error + * @param string $spec + */ + private function __construct($message, $error, $spec) + { + $this->message = $message; + $this->error = $error; + $this->spec = $spec; + } + + /** + * @param array $data + * + * @return self + */ + public static function create(array $data) + { + return new self( + isset($data['message']) ? $data['message'] : null, + isset($data['error']) ? $data['error'] : null, + isset($data['spec']) ? $data['spec'] : null + ); + } + + /** + * @return string + */ + public function getMessage() + { + return $this->message; + } + + /** + * @return string + */ + public function getError() + { + return $this->error; + } + + /** + * @return string + */ + public function getSpec() + { + return $this->spec; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/DeleteResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/DeleteResponse.php new file mode 100644 index 0000000..e48fc61 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/DeleteResponse.php @@ -0,0 +1,67 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Domain; + +use Mailgun\Model\ApiResponse; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +final class DeleteResponse implements ApiResponse +{ + /** + * @var string + */ + private $message; + + /** + * @var string + */ + private $error; + + /** + * @param string $message + * @param string $error + */ + private function __construct($message, $error) + { + $this->message = $message; + $this->error = $error; + } + + /** + * @param array $data + * + * @return self + */ + public static function create(array $data) + { + return new self( + isset($data['message']) ? $data['message'] : null, + isset($data['error']) ? $data['error'] : null + ); + } + + /** + * @return string + */ + public function getMessage() + { + return $this->message; + } + + /** + * @return string + */ + public function getError() + { + return $this->error; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/DnsRecord.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/DnsRecord.php new file mode 100644 index 0000000..b6eb914 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/DnsRecord.php @@ -0,0 +1,123 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Domain; + +/** + * Represents a single DNS record for a domain. + * + * @author Sean Johnson <sean@mailgun.com> + */ +final class DnsRecord +{ + /** + * @var string|null + */ + private $name; + + /** + * @var string + */ + private $type; + + /** + * @var string + */ + private $value; + + /** + * @var string|null + */ + private $priority; + + /** + * @var string + */ + private $valid; + + /** + * @param array $data + * + * @return self + */ + public static function create(array $data) + { + $name = isset($data['name']) ? $data['name'] : null; + $priority = isset($data['priority']) ? $data['priority'] : null; + $recordType = isset($data['record_type']) ? $data['record_type'] : null; + $value = isset($data['value']) ? $data['value'] : null; + $valid = isset($data['valid']) ? $data['valid'] : null; + + return new self($name, $recordType, $value, $priority, $valid); + } + + /** + * @param string|null $name Name of the record, as used in CNAME, etc. + * @param string $type DNS record type + * @param string $value DNS record value + * @param string|null $priority Record priority, used for MX + * @param string $valid DNS record has been added to domain DNS? + */ + private function __construct($name, $type, $value, $priority, $valid) + { + $this->name = $name; + $this->type = $type; + $this->value = $value; + $this->priority = $priority; + $this->valid = $valid; + } + + /** + * @return string|null + */ + public function getName() + { + return $this->name; + } + + /** + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * @return string|null + */ + public function getPriority() + { + return $this->priority; + } + + /** + * @return bool + */ + public function isValid() + { + return 'valid' === $this->valid; + } + + /** + * @return string + */ + public function getValidity() + { + return $this->valid; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/Domain.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/Domain.php new file mode 100644 index 0000000..2182b39 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/Domain.php @@ -0,0 +1,147 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Domain; + +/** + * Represents domain information in its simplest form. + * + * @author Sean Johnson <sean@ramcloud.io> + */ +final class Domain +{ + /** + * @var \DateTime + */ + private $createdAt; + + /** + * @var string + */ + private $smtpLogin; + + /** + * @var string + */ + private $name; + + /** + * @var string + */ + private $smtpPassword; + + /** + * @var bool + */ + private $wildcard; + + /** + * @var string + */ + private $spamAction; + + /** + * @var string + */ + private $state; + + /** + * @param array $data + * + * @return self + */ + public static function create(array $data) + { + return new self( + isset($data['name']) ? $data['name'] : null, + isset($data['smtp_login']) ? $data['smtp_login'] : null, + isset($data['smtp_password']) ? $data['smtp_password'] : null, + isset($data['wildcard']) ? $data['wildcard'] : null, + isset($data['spam_action']) ? $data['spam_action'] : null, + isset($data['state']) ? $data['state'] : null, + isset($data['created_at']) ? new \DateTime($data['created_at']) : null + ); + } + + /** + * @param string $name + * @param string $smtpLogin + * @param string $smtpPassword + * @param bool $wildcard + * @param string $spamAction + * @param string $state + * @param \DateTime $createdAt + */ + private function __construct($name, $smtpLogin, $smtpPassword, $wildcard, $spamAction, $state, \DateTime $createdAt) + { + $this->name = $name; + $this->smtpLogin = $smtpLogin; + $this->smtpPassword = $smtpPassword; + $this->wildcard = $wildcard; + $this->spamAction = $spamAction; + $this->state = $state; + $this->createdAt = $createdAt; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @return string + */ + public function getSmtpUsername() + { + return $this->smtpLogin; + } + + /** + * @return string + */ + public function getSmtpPassword() + { + return $this->smtpPassword; + } + + /** + * @return bool + */ + public function isWildcard() + { + return $this->wildcard; + } + + /** + * @return string + */ + public function getSpamAction() + { + return $this->spamAction; + } + + /** + * @return string + */ + public function getState() + { + return $this->state; + } + + /** + * @return \DateTime + */ + public function getCreatedAt() + { + return $this->createdAt; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/IndexResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/IndexResponse.php new file mode 100644 index 0000000..abd2cdc --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/IndexResponse.php @@ -0,0 +1,78 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Domain; + +use Mailgun\Model\ApiResponse; + +/** + * @author Sean Johnson <sean@mailgun.com> + */ +final class IndexResponse implements ApiResponse +{ + /** + * @var int + */ + private $totalCount; + + /** + * @var Domain[] + */ + private $items; + + /** + * @param array $data + * + * @return self + */ + public static function create(array $data) + { + $items = []; + + if (isset($data['items'])) { + foreach ($data['items'] as $item) { + $items[] = Domain::create($item); + } + } + + if (isset($data['total_count'])) { + $count = $data['total_count']; + } else { + $count = count($items); + } + + return new self($count, $items); + } + + /** + * @param int $totalCount + * @param Domain[] $items + */ + private function __construct($totalCount, array $items) + { + $this->totalCount = $totalCount; + $this->items = $items; + } + + /** + * @return int + */ + public function getTotalCount() + { + return $this->totalCount; + } + + /** + * @return Domain[] + */ + public function getDomains() + { + return $this->items; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/ShowResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/ShowResponse.php new file mode 100644 index 0000000..52e5c98 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/ShowResponse.php @@ -0,0 +1,99 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Domain; + +use Mailgun\Model\ApiResponse; + +/** + * @author Sean Johnson <sean@mailgun.com> + */ +final class ShowResponse implements ApiResponse +{ + /** + * @var Domain + */ + private $domain; + + /** + * @var DnsRecord[] + */ + private $inboundDnsRecords; + + /** + * @var DnsRecord[] + */ + private $outboundDnsRecords; + + /** + * @param array $data + * + * @return self + */ + public static function create(array $data) + { + $rx = []; + $tx = []; + $domain = null; + + if (isset($data['domain'])) { + $domain = Domain::create($data['domain']); + } + + if (isset($data['receiving_dns_records'])) { + foreach ($data['receiving_dns_records'] as $item) { + $rx[] = DnsRecord::create($item); + } + } + + if (isset($data['sending_dns_records'])) { + foreach ($data['sending_dns_records'] as $item) { + $tx[] = DnsRecord::create($item); + } + } + + return new self($domain, $rx, $tx); + } + + /** + * @param Domain $domainInfo + * @param DnsRecord[] $rxRecords + * @param DnsRecord[] $txRecords + */ + private function __construct(Domain $domainInfo, array $rxRecords, array $txRecords) + { + $this->domain = $domainInfo; + $this->inboundDnsRecords = $rxRecords; + $this->outboundDnsRecords = $txRecords; + } + + /** + * @return Domain + */ + public function getDomain() + { + return $this->domain; + } + + /** + * @return DnsRecord[] + */ + public function getInboundDNSRecords() + { + return $this->inboundDnsRecords; + } + + /** + * @return DnsRecord[] + */ + public function getOutboundDNSRecords() + { + return $this->outboundDnsRecords; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/UpdateConnectionResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/UpdateConnectionResponse.php new file mode 100644 index 0000000..49f4fc6 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/UpdateConnectionResponse.php @@ -0,0 +1,83 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Domain; + +use Mailgun\Model\ApiResponse; + +/** + * @author Sean Johnson <sean@mailgun.com> + */ +final class UpdateConnectionResponse implements ApiResponse +{ + /** + * @var string + */ + private $message; + + /** + * @var bool + */ + private $noVerify; + + /** + * @var bool + */ + private $requireTLS; + + /** + * @param array $data + * + * @return self + */ + public static function create(array $data) + { + $message = isset($data['message']) ? $data['message'] : null; + $noVerify = isset($data['skip_verification']) ? $data['skip_verification'] : null; + $requireTLS = isset($data['require_tls']) ? $data['require_tls'] : null; + + return new self($message, $noVerify, $requireTLS); + } + + /** + * @param string $message + * @param bool $noVerify + * @param bool $requireTLS + */ + private function __construct($message, $noVerify, $requireTLS) + { + $this->message = $message; + $this->noVerify = $noVerify; + $this->requireTLS = $requireTLS; + } + + /** + * @return string + */ + public function getMessage() + { + return $this->message; + } + + /** + * @return bool + */ + public function getSkipVerification() + { + return $this->noVerify; + } + + /** + * @return bool + */ + public function getRequireTLS() + { + return $this->requireTLS; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/UpdateCredentialResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/UpdateCredentialResponse.php new file mode 100644 index 0000000..8053a1b --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Domain/UpdateCredentialResponse.php @@ -0,0 +1,49 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Domain; + +use Mailgun\Model\ApiResponse; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +final class UpdateCredentialResponse implements ApiResponse +{ + /** + * @var string + */ + private $message; + + /** + * @param string $message + */ + private function __construct($message) + { + $this->message = $message; + } + + /** + * @param array $data + * + * @return self + */ + public static function create(array $data) + { + return new self(isset($data['message']) ? $data['message'] : null); + } + + /** + * @return string + */ + public function getMessage() + { + return $this->message; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Event/Event.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Event/Event.php new file mode 100644 index 0000000..71fcdcd --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Event/Event.php @@ -0,0 +1,505 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Event; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +class Event +{ + /** + * @var string status + */ + private $event; + + /** + * @var string + */ + private $id; + + /** + * @var float + */ + private $timestamp; + + /** + * A \DateTime representation of $timestamp. + * + * @var \DateTime + */ + private $eventDate; + + /** + * @var array|string[] + */ + private $tags = []; + + /** + * @var string + */ + private $url; + + /** + * @var string + */ + private $severity; + + /** + * @var array + */ + private $envelope = []; + + /** + * @var array + */ + private $deliveryStatus; + + /** + * @var array|string[] + */ + private $campaigns = []; + + /** + * @var string + */ + private $ip; + + /** + * @var array + */ + private $clientInfo = []; + + /** + * @var string + */ + private $reason; + + /** + * @var array + */ + private $userVariables = []; + + /** + * @var array key=>bool + */ + private $flags = []; + + /** + * @var array multi dimensions + */ + private $routes = []; + + /** + * @var array multi dimensions + */ + private $message = []; + + /** + * @var string + */ + private $recipient; + + /** + * @var array + */ + private $geolocation = []; + + /** + * @var array + */ + private $storage = []; + + /** + * @var string + */ + private $method; + + /** + * @param string $event + * @param string $id + * @param float $timestamp + */ + public function __construct($event, $id, $timestamp) + { + $this->event = $event; + $this->id = $id; + $this->timestamp = $timestamp; + $this->eventDate = new \DateTime(); + $this->eventDate->setTimestamp((int) $timestamp); + } + + /** + * @param array $data + * + * @return Event + */ + public static function create(array $data) + { + $event = new self($data['event'], $data['id'], $data['timestamp']); + + if (isset($data['tags'])) { + $event->setTags($data['tags']); + } + if (isset($data['envelope'])) { + $event->setEnvelope($data['envelope']); + } + if (isset($data['campaigns'])) { + $event->setCampaigns($data['campaigns']); + } + if (isset($data['user-variables'])) { + $event->setUserVariables($data['user-variables']); + } + if (isset($data['flags'])) { + $event->setFlags($data['flags']); + } + if (isset($data['routes'])) { + $event->setRoutes($data['routes']); + } + if (isset($data['message'])) { + $event->setMessage($data['message']); + } + if (isset($data['recipient'])) { + $event->setRecipient($data['recipient']); + } + if (isset($data['method'])) { + $event->setMethod($data['method']); + } + if (isset($data['delivery-status'])) { + $event->setDeliveryStatus($data['delivery-status']); + } + if (isset($data['severity'])) { + $event->setSeverity($data['severity']); + } + if (isset($data['reason'])) { + $event->setReason($data['reason']); + } + if (isset($data['geolocation'])) { + $event->setGeolocation($data['geolocation']); + } + if (isset($data['ip'])) { + $event->setIp($data['ip']); + } + if (isset($data['client-info'])) { + $event->setClientInfo($data['client-info']); + } + if (isset($data['url'])) { + $event->setUrl($data['url']); + } + if (isset($data['storage'])) { + $event->setStorage($data['storage']); + } + + return $event; + } + + /** + * @return string + */ + public function getEvent() + { + return $this->event; + } + + /** + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * @return float + */ + public function getTimestamp() + { + return $this->timestamp; + } + + /** + * @return \DateTime + */ + public function getEventDate() + { + return $this->eventDate; + } + + /** + * @return array|\string[] + */ + public function getTags() + { + return $this->tags; + } + + /** + * @param array|\string[] $tags + */ + private function setTags($tags) + { + $this->tags = $tags; + } + + /** + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * @param string $url + */ + private function setUrl($url) + { + $this->url = $url; + } + + /** + * @return array + */ + public function getEnvelope() + { + return $this->envelope; + } + + /** + * @param array $envelope + */ + private function setEnvelope($envelope) + { + $this->envelope = $envelope; + } + + /** + * @return array + */ + public function getDeliveryStatus() + { + return $this->deliveryStatus; + } + + /** + * @param array $deliveryStatus + */ + private function setDeliveryStatus($deliveryStatus) + { + $this->deliveryStatus = $deliveryStatus; + } + + /** + * @return array|\string[] + */ + public function getCampaigns() + { + return $this->campaigns; + } + + /** + * @param array|\string[] $campaigns + */ + private function setCampaigns($campaigns) + { + $this->campaigns = $campaigns; + } + + /** + * @return string + */ + public function getIp() + { + return $this->ip; + } + + /** + * @param string $ip + */ + private function setIp($ip) + { + $this->ip = $ip; + } + + /** + * @return array + */ + public function getClientInfo() + { + return $this->clientInfo; + } + + /** + * @param array $clientInfo + */ + private function setClientInfo($clientInfo) + { + $this->clientInfo = $clientInfo; + } + + /** + * @return string + */ + public function getReason() + { + return $this->reason; + } + + /** + * @param string $reason + */ + private function setReason($reason) + { + $this->reason = $reason; + } + + /** + * @return array + */ + public function getUserVariables() + { + return $this->userVariables; + } + + /** + * @param array $userVariables + */ + private function setUserVariables($userVariables) + { + $this->userVariables = $userVariables; + } + + /** + * @return array + */ + public function getFlags() + { + return $this->flags; + } + + /** + * @param array $flags + */ + private function setFlags($flags) + { + $this->flags = $flags; + } + + /** + * @return array + */ + public function getRoutes() + { + return $this->routes; + } + + /** + * @param array $routes + */ + private function setRoutes($routes) + { + $this->routes = $routes; + } + + /** + * @return array + */ + public function getMessage() + { + return $this->message; + } + + /** + * @param array $message + */ + private function setMessage($message) + { + $this->message = $message; + } + + /** + * @return string + */ + public function getRecipient() + { + return $this->recipient; + } + + /** + * @param string $recipient + */ + private function setRecipient($recipient) + { + $this->recipient = $recipient; + } + + /** + * @return array + */ + public function getGeolocation() + { + return $this->geolocation; + } + + /** + * @param array $geolocation + */ + private function setGeolocation($geolocation) + { + $this->geolocation = $geolocation; + } + + /** + * @return array + */ + public function getStorage() + { + return $this->storage; + } + + /** + * @param array $storage + */ + private function setStorage($storage) + { + $this->storage = $storage; + } + + /** + * @return string + */ + public function getMethod() + { + return $this->method; + } + + /** + * @param string $method + */ + private function setMethod($method) + { + $this->method = $method; + } + + /** + * @return string + */ + public function getSeverity() + { + return $this->severity; + } + + /** + * @param string $severity + */ + private function setSeverity($severity) + { + $this->severity = $severity; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Event/EventResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Event/EventResponse.php new file mode 100644 index 0000000..6cb9d5b --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Event/EventResponse.php @@ -0,0 +1,57 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Event; + +use Mailgun\Model\PagingProvider; +use Mailgun\Model\PaginationResponse; +use Mailgun\Model\ApiResponse; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +class EventResponse implements ApiResponse, PagingProvider +{ + use PaginationResponse; + + /** + * @var Event[] + */ + private $items; + + /** + * @param Event[] $items + * @param array $paging + */ + public function __construct(array $items, array $paging) + { + $this->items = $items; + $this->paging = $paging; + } + + public static function create(array $data) + { + $events = []; + if (isset($data['items'])) { + foreach ($data['items'] as $item) { + $events[] = Event::create($item); + } + } + + return new self($events, $data['paging']); + } + + /** + * @return Event[] + */ + public function getItems() + { + return $this->items; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Message/SendResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Message/SendResponse.php new file mode 100644 index 0000000..2295804 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Message/SendResponse.php @@ -0,0 +1,74 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Message; + +use Mailgun\Model\ApiResponse; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +class SendResponse implements ApiResponse +{ + /** + * @var string + */ + private $id; + + /** + * @var string + */ + private $message; + + /** + * @param string $id + * @param string $message + */ + private function __construct($id, $message) + { + $this->id = $id; + $this->message = $message; + } + + /** + * @param array $data + * + * @return SendResponse + */ + public static function create(array $data) + { + $id = ''; + $message = ''; + + if (isset($data['id'])) { + $id = $data['id']; + } + if (isset($data['message'])) { + $message = $data['message']; + } + + return new self($id, $message); + } + + /** + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * @return string + */ + public function getMessage() + { + return $this->message; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Message/ShowResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Message/ShowResponse.php new file mode 100644 index 0000000..6be7c84 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Message/ShowResponse.php @@ -0,0 +1,402 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Message; + +use Mailgun\Model\ApiResponse; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +class ShowResponse implements ApiResponse +{ + /** + * Only available with message/rfc2822. + * + * @var string + */ + private $recipient; + + /** + * Only available with message/rfc2822. + * + * @var string + */ + private $bodyMime; + + /** + * @var string + */ + private $recipients; + + /** + * @var string + */ + private $sender; + + /** + * @var string + */ + private $from; + + /** + * @var string + */ + private $subject; + + /** + * @var string + */ + private $bodyPlain; + + /** + * @var string + */ + private $strippedText; + + /** + * @var string + */ + private $strippedSignature; + + /** + * @var string + */ + private $bodyHtml; + + /** + * @var string + */ + private $strippedHtml; + + /** + * @var array + */ + private $attachments; + + /** + * @var string + */ + private $messageUrl; + + /** + * @var string + */ + private $contentIdMap; + + /** + * @var array + */ + private $messageHeaders; + + /** + * Do not let this object be creted without the ::create. + */ + private function __construct() + { + } + + /** + * @param array $data + * + * @return SendResponse + */ + public static function create(array $data) + { + $response = new self(); + + if (isset($data['recipients'])) { + $response->setRecipients($data['recipients']); + } + if (isset($data['sender'])) { + $response->setSender($data['sender']); + } + if (isset($data['from'])) { + $response->setFrom($data['from']); + } + if (isset($data['subject'])) { + $response->setSubject($data['subject']); + } + if (isset($data['body-plain'])) { + $response->setBodyPlain($data['body-plain']); + } + if (isset($data['stripped-text'])) { + $response->setStrippedText($data['stripped-text']); + } + if (isset($data['stripped-signature'])) { + $response->setStrippedSignature($data['stripped-signature']); + } + if (isset($data['body-html'])) { + $response->setBodyHtml($data['body-html']); + } + if (isset($data['stripped-html'])) { + $response->setStrippedHtml($data['stripped-html']); + } + if (isset($data['message-url'])) { + $response->setMessageUrl($data['message-url']); + } + if (isset($data['message-headers'])) { + $response->setMessageHeaders($data['message-headers']); + } + if (isset($data['recipient'])) { + $response->setRecipient($data['recipient']); + } + if (isset($data['body-mime'])) { + $response->setBodyMime($data['body-mime']); + } + if (isset($data['attachments'])) { + $response->setAttachments($data['attachments']); + } + if (isset($data['content-id-map'])) { + $response->setContentIdMap($data['content-id-map']); + } + + return $response; + } + + /** + * @return string + */ + public function getRecipient() + { + return $this->recipient; + } + + /** + * @param string $recipient + */ + private function setRecipient($recipient) + { + $this->recipient = $recipient; + } + + /** + * @return string + */ + public function getBodyMime() + { + return $this->bodyMime; + } + + /** + * @param string $bodyMime + */ + private function setBodyMime($bodyMime) + { + $this->bodyMime = $bodyMime; + } + + /** + * @return string + */ + public function getRecipients() + { + return $this->recipients; + } + + /** + * @param string $recipients + */ + private function setRecipients($recipients) + { + $this->recipients = $recipients; + } + + /** + * @return string + */ + public function getSender() + { + return $this->sender; + } + + /** + * @param string $sender + */ + private function setSender($sender) + { + $this->sender = $sender; + } + + /** + * @return string + */ + public function getFrom() + { + return $this->from; + } + + /** + * @param string $from + */ + private function setFrom($from) + { + $this->from = $from; + } + + /** + * @return string + */ + public function getSubject() + { + return $this->subject; + } + + /** + * @param string $subject + */ + private function setSubject($subject) + { + $this->subject = $subject; + } + + /** + * @return string + */ + public function getBodyPlain() + { + return $this->bodyPlain; + } + + /** + * @param string $bodyPlain + */ + private function setBodyPlain($bodyPlain) + { + $this->bodyPlain = $bodyPlain; + } + + /** + * @return string + */ + public function getStrippedText() + { + return $this->strippedText; + } + + /** + * @param string $strippedText + */ + private function setStrippedText($strippedText) + { + $this->strippedText = $strippedText; + } + + /** + * @return string + */ + public function getStrippedSignature() + { + return $this->strippedSignature; + } + + /** + * @param string $strippedSignature + */ + private function setStrippedSignature($strippedSignature) + { + $this->strippedSignature = $strippedSignature; + } + + /** + * @return string + */ + public function getBodyHtml() + { + return $this->bodyHtml; + } + + /** + * @param string $bodyHtml + */ + private function setBodyHtml($bodyHtml) + { + $this->bodyHtml = $bodyHtml; + } + + /** + * @return string + */ + public function getStrippedHtml() + { + return $this->strippedHtml; + } + + /** + * @param string $strippedHtml + */ + private function setStrippedHtml($strippedHtml) + { + $this->strippedHtml = $strippedHtml; + } + + /** + * @return array + */ + public function getAttachments() + { + return $this->attachments; + } + + /** + * @param array $attachments + */ + private function setAttachments($attachments) + { + $this->attachments = $attachments; + } + + /** + * @return string + */ + public function getMessageUrl() + { + return $this->messageUrl; + } + + /** + * @param string $messageUrl + */ + private function setMessageUrl($messageUrl) + { + $this->messageUrl = $messageUrl; + } + + /** + * @return string + */ + public function getContentIdMap() + { + return $this->contentIdMap; + } + + /** + * @param string $contentIdMap + */ + public function setContentIdMap($contentIdMap) + { + $this->contentIdMap = $contentIdMap; + } + + /** + * @return array + */ + public function getMessageHeaders() + { + return $this->messageHeaders; + } + + /** + * @param array $messageHeaders + */ + private function setMessageHeaders(array $messageHeaders) + { + $this->messageHeaders = $messageHeaders; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/PaginationResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/PaginationResponse.php new file mode 100644 index 0000000..3d2895f --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/PaginationResponse.php @@ -0,0 +1,69 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +trait PaginationResponse +{ + /** + * @var array + */ + protected $paging; + + /** + * @return string + */ + public function getNextUrl() + { + if (!isset($this->paging['next'])) { + return; + } + + return $this->paging['next']; + } + + /** + * @return string + */ + public function getPreviousUrl() + { + if (!isset($this->paging['previous'])) { + return; + } + + return $this->paging['previous']; + } + + /** + * @return string + */ + public function getFirstUrl() + { + if (!isset($this->paging['first'])) { + return; + } + + return $this->paging['first']; + } + + /** + * @return string + */ + public function getLastUrl() + { + if (!isset($this->paging['last'])) { + return; + } + + return $this->paging['last']; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/PagingProvider.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/PagingProvider.php new file mode 100644 index 0000000..560a74d --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/PagingProvider.php @@ -0,0 +1,44 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model; + +/** + * @author Sean Johnson <sean@mailgun.com> + */ +interface PagingProvider +{ + /** + * Returns the `$paging->next` URL. + * + * @return string + */ + public function getNextUrl(); + + /** + * Returns the `$paging->prev` URL. + * + * @return string + */ + public function getPreviousUrl(); + + /** + * Returns the `$paging->first` URL. + * + * @return string + */ + public function getFirstUrl(); + + /** + * Returns the `$paging->last` URL. + * + * @return string + */ + public function getLastUrl(); +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Route/Action.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Route/Action.php new file mode 100644 index 0000000..bfdb942 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Route/Action.php @@ -0,0 +1,57 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Route; + +/** + * @author David Garcia <me@davidgarcia.cat> + */ +final class Action +{ + /** + * @var string + */ + private $action; + + /** + * Action Named Constructor to build several Action DTOs provided by an Array. + * + * @param array $data + * + * @return Action[] + */ + public static function createMultiple(array $data) + { + $items = []; + + foreach ($data as $action) { + $items[] = new self($action); + } + + return $items; + } + + /** + * Action Private Constructor. + * + * @param $action + */ + private function __construct($action) + { + $this->action = $action; + } + + /** + * @return string + */ + public function getAction() + { + return $this->action; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Route/Response/CreateResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Route/Response/CreateResponse.php new file mode 100644 index 0000000..687d08d --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Route/Response/CreateResponse.php @@ -0,0 +1,68 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Route\Response; + +use Mailgun\Model\Route\Route; +use Mailgun\Model\ApiResponse; + +/** + * @author David Garcia <me@davidgarcia.cat> + */ +final class CreateResponse implements ApiResponse +{ + /** + * @var string + */ + private $message; + + /** + * @var Route + */ + private $route; + + /** + * {@inheritdoc} + */ + public static function create(array $data) + { + $message = isset($data['message']) ? $data['message'] : null; + $route = isset($data['route']) ? Route::create($data['route']) : null; + + return new self($message, $route); + } + + /** + * CreateResponse Private Constructor. + * + * @param string|null $message + * @param Route|null $route + */ + private function __construct($message = null, Route $route = null) + { + $this->message = $message; + $this->route = $route; + } + + /** + * @return string + */ + public function getMessage() + { + return $this->message; + } + + /** + * @return Route + */ + public function getRoute() + { + return $this->route; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Route/Response/DeleteResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Route/Response/DeleteResponse.php new file mode 100644 index 0000000..26a2f63 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Route/Response/DeleteResponse.php @@ -0,0 +1,67 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Route\Response; + +use Mailgun\Model\ApiResponse; + +/** + * @author David Garcia <me@davidgarcia.cat> + */ +final class DeleteResponse implements ApiResponse +{ + /** + * @var string + */ + private $message; + + /** + * @var string + */ + private $error; + + /** + * @param array $data + * + * @return self + */ + public static function create(array $data) + { + return new self( + isset($data['message']) ? $data['message'] : null, + isset($data['error']) ? $data['error'] : null + ); + } + + /** + * @param string $message + * @param string $error + */ + private function __construct($message, $error) + { + $this->message = $message; + $this->error = $error; + } + + /** + * @return string + */ + public function getMessage() + { + return $this->message; + } + + /** + * @return string + */ + public function getError() + { + return $this->error; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Route/Response/IndexResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Route/Response/IndexResponse.php new file mode 100644 index 0000000..b78c254 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Route/Response/IndexResponse.php @@ -0,0 +1,77 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Route\Response; + +use Mailgun\Model\Route\Route; +use Mailgun\Model\ApiResponse; + +/** + * @author David Garcia <me@davidgarcia.cat> + */ +final class IndexResponse implements ApiResponse +{ + /** + * @var int + */ + private $totalCount; + + /** + * @var Route[] + */ + private $items; + + /** + * {@inheritdoc} + */ + public static function create(array $data) + { + $items = []; + + if (isset($data['items'])) { + foreach ($data['items'] as $item) { + $items[] = Route::create($item); + } + } + + if (isset($data['total_count'])) { + $count = $data['total_count']; + } else { + $count = count($items); + } + + return new self($count, $items); + } + + /** + * @param int $totalCount + * @param Route[] $items + */ + private function __construct($totalCount, array $items) + { + $this->totalCount = $totalCount; + $this->items = $items; + } + + /** + * @return int + */ + public function getTotalCount() + { + return $this->totalCount; + } + + /** + * @return Route[] + */ + public function getRoutes() + { + return $this->items; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Route/Response/ShowResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Route/Response/ShowResponse.php new file mode 100644 index 0000000..89b88d0 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Route/Response/ShowResponse.php @@ -0,0 +1,54 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Route\Response; + +use Mailgun\Model\Route\Route; +use Mailgun\Model\ApiResponse; + +/** + * @author David Garcia <me@davidgarcia.cat> + */ +final class ShowResponse implements ApiResponse +{ + /** + * @var Route|null + */ + private $route; + + /** + * {@inheritdoc} + */ + public static function create(array $data) + { + if (isset($data['route'])) { + return new self(Route::create($data['route'])); + } + + return new self(); + } + + /** + * ShowResponse constructor. + * + * @param Route|null $route + */ + private function __construct(Route $route = null) + { + $this->route = $route; + } + + /** + * @return Route|null + */ + public function getRoute() + { + return $this->route; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Route/Response/UpdateResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Route/Response/UpdateResponse.php new file mode 100644 index 0000000..43edc0b --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Route/Response/UpdateResponse.php @@ -0,0 +1,68 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Route\Response; + +use Mailgun\Model\ApiResponse; +use Mailgun\Model\Route\Route; + +/** + * @author David Garcia <me@davidgarcia.cat> + */ +final class UpdateResponse implements ApiResponse +{ + /** + * @var string|null + */ + private $message; + + /** + * @var Route|null + */ + private $route; + + /** + * @param array $data + * + * @return self + */ + public static function create(array $data) + { + $message = isset($data['message']) ? $data['message'] : null; + $route = isset($data['id']) ? Route::create($data) : null; + + return new self($message, $route); + } + + /** + * @param string|null $message + * @param Route|null $route + */ + private function __construct($message = null, Route $route = null) + { + $this->message = $message; + $this->route = $route; + } + + /** + * @return string|null + */ + public function getMessage() + { + return $this->message; + } + + /** + * @return Route|null + */ + public function getRoute() + { + return $this->route; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Route/Route.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Route/Route.php new file mode 100644 index 0000000..527073f --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Route/Route.php @@ -0,0 +1,133 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Route; + +/** + * @author David Garcia <me@davidgarcia.cat> + */ +final class Route +{ + /** + * @var string + */ + private $id; + + /** + * @var int + */ + private $priority; + + /** + * @var string + */ + private $filter; + + /** + * @var Action[] + */ + private $actions; + + /** + * @var string + */ + private $description; + + /** + * @var \DateTime + */ + private $createdAt; + + /** + * Route Named Constructor. + * + * @param array $data + * + * @return Route + */ + public static function create(array $data) + { + return new self( + isset($data['id']) ? $data['id'] : null, + isset($data['priority']) ? $data['priority'] : null, + isset($data['expression']) ? $data['expression'] : null, + isset($data['actions']) ? $data['actions'] : [], + isset($data['description']) ? $data['description'] : null, + isset($data['created_at']) ? new \DateTime($data['created_at']) : null + ); + } + + /** + * Route Private Constructor. + * + * @param string $id + * @param int $priority + * @param string $expression + * @param array $actions + * @param string $description + * @param \DateTime $createdAt + */ + private function __construct($id, $priority, $expression, $actions, $description, \DateTime $createdAt = null) + { + $this->id = $id; + $this->priority = $priority; + $this->filter = $expression; + $this->actions = Action::createMultiple($actions); + $this->description = $description; + $this->createdAt = $createdAt; + } + + /** + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * @return Action[] + */ + public function getActions() + { + return $this->actions; + } + + /** + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * @return string + */ + public function getFilter() + { + return $this->filter; + } + + /** + * @return int + */ + public function getPriority() + { + return $this->priority; + } + + /** + * @return \DateTime + */ + public function getCreatedAt() + { + return $this->createdAt; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Stats/AllResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Stats/AllResponse.php new file mode 100644 index 0000000..215f074 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Stats/AllResponse.php @@ -0,0 +1,77 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Stats; + +use Mailgun\Model\ApiResponse; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +final class AllResponse implements ApiResponse +{ + /** + * @var int + */ + private $totalCount; + + /** + * @var AllResponseItem[] + */ + private $items; + + /** + * @param int $totalCount + * @param AllResponseItem[] $items + */ + private function __construct($totalCount, array $items) + { + $this->totalCount = $totalCount; + $this->items = $items; + } + + /** + * @param array $data + * + * @return self + */ + public static function create(array $data) + { + $items = []; + if (isset($data['items'])) { + foreach ($data['items'] as $i) { + $items[] = AllResponseItem::create($i); + } + } + + if (isset($data['total_count'])) { + $count = $data['total_count']; + } else { + $count = count($items); + } + + return new self($count, $items); + } + + /** + * @return int + */ + public function getTotalCount() + { + return $this->totalCount; + } + + /** + * @return AllResponseItem[] + */ + public function getItems() + { + return $this->items; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Stats/AllResponseItem.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Stats/AllResponseItem.php new file mode 100644 index 0000000..d5d6dc4 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Stats/AllResponseItem.php @@ -0,0 +1,113 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Stats; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +final class AllResponseItem +{ + /** + * @var string + */ + private $id; + + /** + * @var string + */ + private $event; + + /** + * @var string + */ + private $totalCount; + + /** + * @var string[] + */ + private $tags; + + /** + * @var \DateTime + */ + private $createdAt; + + /** + * @param array $data + * + * @return self + */ + public static function create(array $data) + { + return new self( + isset($data['id']) ? $data['id'] : null, + isset($data['event']) ? $data['event'] : null, + isset($data['total_count']) ? $data['total_count'] : null, + isset($data['tags']) ? $data['tags'] : null, + isset($data['created_at']) ? new \DateTime($data['created_at']) : null + ); + } + + /** + * @param string $id + * @param string $event + * @param string $totalCount + * @param \string[] $tags + * @param \DateTime $createdAt + */ + private function __construct($id, $event, $totalCount, array $tags, \DateTime $createdAt) + { + $this->id = $id; + $this->event = $event; + $this->totalCount = $totalCount; + $this->tags = $tags; + $this->createdAt = $createdAt; + } + + /** + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * @return string + */ + public function getEvent() + { + return $this->event; + } + + /** + * @return string + */ + public function getTotalCount() + { + return $this->totalCount; + } + + /** + * @return string[] + */ + public function getTags() + { + return $this->tags; + } + + /** + * @return \DateTime + */ + public function getCreatedAt() + { + return $this->createdAt; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Stats/TotalResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Stats/TotalResponse.php new file mode 100644 index 0000000..3d4caff --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Stats/TotalResponse.php @@ -0,0 +1,105 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Stats; + +use Mailgun\Model\ApiResponse; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +final class TotalResponse implements ApiResponse +{ + /** + * @var \DateTime + */ + private $start; + + /** + * @var \DateTime + */ + private $end; + + /** + * @var string + */ + private $resolution; + + /** + * @var TotalResponseItem[] + */ + private $stats; + + /** + * @param \DateTime $start + * @param \DateTime $end + * @param string $resolution + * @param TotalResponseItem[] $stats + */ + private function __construct(\DateTime $start, \DateTime $end, $resolution, array $stats) + { + $this->start = $start; + $this->end = $end; + $this->resolution = $resolution; + $this->stats = $stats; + } + + /** + * @param array $data + * + * @return self + */ + public static function create(array $data) + { + $stats = []; + if (isset($data['status'])) { + foreach ($data['stats'] as $s) { + $stats[] = TotalResponseItem::create($s); + } + } + + $start = isset($data['start']) ? new \DateTime($data['start']) : null; + $end = isset($data['end']) ? new \DateTime($data['end']) : null; + $resolution = isset($data['resolution']) ? $data['resolution'] : null; + + return new self($start, $end, $resolution, $stats); + } + + /** + * @return \DateTime + */ + public function getStart() + { + return $this->start; + } + + /** + * @return \DateTime + */ + public function getEnd() + { + return $this->end; + } + + /** + * @return string + */ + public function getResolution() + { + return $this->resolution; + } + + /** + * @return TotalResponseItem[] + */ + public function getStats() + { + return $this->stats; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Stats/TotalResponseItem.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Stats/TotalResponseItem.php new file mode 100644 index 0000000..785d7d8 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Stats/TotalResponseItem.php @@ -0,0 +1,97 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Stats; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +class TotalResponseItem +{ + /** + * @var \DateTime + */ + private $time; + + /** + * @var array + */ + private $accepted; + + /** + * @var array + */ + private $delivered; + + /** + * @var array + */ + private $failed; + + /** + * @param array $data + * + * @return self + */ + public static function create(array $data) + { + return new self( + isset($data['time']) ? new \DateTime($data['time']) : null, + isset($data['accepted']) ? $data['accepted'] : null, + isset($data['delivered']) ? $data['delivered'] : null, + isset($data['failed']) ? $data['failed'] : null + ); + } + + /** + * @param \DateTime $time + * @param array $accepted + * @param array $delivered + * @param array $failed + */ + private function __construct(\DateTime $time, array $accepted, array $delivered, array $failed) + { + $this->time = $time; + $this->accepted = $accepted; + $this->delivered = $delivered; + $this->failed = $failed; + } + + /** + * @return \DateTime + */ + public function getTime() + { + return $this->time; + } + + /** + * @return array + */ + public function getAccepted() + { + return $this->accepted; + } + + /** + * @return array + */ + public function getDelivered() + { + return $this->delivered; + } + + /** + * @return array + */ + public function getFailed() + { + return $this->failed; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/BaseResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/BaseResponse.php new file mode 100644 index 0000000..413bee9 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/BaseResponse.php @@ -0,0 +1,69 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Suppression; + +use Mailgun\Model\ApiResponse; + +/** + * Serves only as an abstract base for Suppression API code. + * + * @author Sean Johnson <sean@mailgun.com> + */ +abstract class BaseResponse implements ApiResponse +{ + /** + * @var string + */ + private $address; + + /** + * @var string + */ + private $message; + + /** + * @param string $address + * @param string $message + */ + private function __construct($address, $message) + { + $this->address = $address; + $this->message = $message; + } + + /** + * @param array $data + * + * @return BaseResponse + */ + public static function create(array $data) + { + $address = isset($data['address']) ? $data['address'] : ''; + $message = isset($data['message']) ? $data['message'] : ''; + + return new static($address, $message); + } + + /** + * @return string + */ + public function getAddress() + { + return $this->address; + } + + /** + * @return string + */ + public function getMessage() + { + return $this->message; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Bounce/Bounce.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Bounce/Bounce.php new file mode 100644 index 0000000..687effc --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Bounce/Bounce.php @@ -0,0 +1,123 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Suppression\Bounce; + +/** + * @author Sean Johnson <sean@mailgun.com> + */ +class Bounce +{ + /** + * @var string + */ + private $address; + + /** + * @var string + */ + private $code; + + /** + * @var string + */ + private $error; + + /** + * @var \DateTime + */ + private $createdAt; + + /** + * @param string $address + */ + private function __construct($address) + { + $this->address = $address; + $this->createdAt = new \DateTime(); + } + + /** + * @param array $data + * + * @return Bounce + */ + public static function create(array $data) + { + $bounce = new self($data['address']); + + if (isset($data['code'])) { + $bounce->setCode($data['code']); + } + if (isset($data['error'])) { + $bounce->setError($data['error']); + } + if (isset($data['created_at'])) { + $bounce->setCreatedAt(new \DateTime($data['created_at'])); + } + + return $bounce; + } + + /** + * @return string + */ + public function getAddress() + { + return $this->address; + } + + /** + * @return string + */ + public function getCode() + { + return $this->code; + } + + /** + * @param string $code + */ + private function setCode($code) + { + $this->code = $code; + } + + /** + * @return string + */ + public function getError() + { + return $this->error; + } + + /** + * @param string $error + */ + private function setError($error) + { + $this->error = $error; + } + + /** + * @return \DateTime + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + * @param \DateTime $createdAt + */ + private function setCreatedAt(\DateTime $createdAt) + { + $this->createdAt = $createdAt; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Bounce/CreateResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Bounce/CreateResponse.php new file mode 100644 index 0000000..e91d5e8 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Bounce/CreateResponse.php @@ -0,0 +1,19 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Suppression\Bounce; + +use Mailgun\Model\Suppression\BaseResponse; + +/** + * @author Sean Johnson <sean@mailgun.com> + */ +final class CreateResponse extends BaseResponse +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Bounce/DeleteResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Bounce/DeleteResponse.php new file mode 100644 index 0000000..92dac6a --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Bounce/DeleteResponse.php @@ -0,0 +1,19 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Suppression\Bounce; + +use Mailgun\Model\Suppression\BaseResponse; + +/** + * @author Sean Johnson <sean@mailgun.com> + */ +final class DeleteResponse extends BaseResponse +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Bounce/IndexResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Bounce/IndexResponse.php new file mode 100644 index 0000000..cbf7658 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Bounce/IndexResponse.php @@ -0,0 +1,62 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Suppression\Bounce; + +use Mailgun\Model\ApiResponse; +use Mailgun\Model\PaginationResponse; +use Mailgun\Model\PagingProvider; + +/** + * @author Sean Johnson <sean@mailgun.com> + */ +final class IndexResponse implements ApiResponse, PagingProvider +{ + use PaginationResponse; + + /** + * @var Bounce[] + */ + private $items; + + /** + * @param Bounce[] $items + * @param array $paging + */ + private function __construct(array $items, array $paging) + { + $this->items = $items; + $this->paging = $paging; + } + + /** + * @param array $data + * + * @return IndexResponse + */ + public static function create(array $data) + { + $bounces = []; + if (isset($data['items'])) { + foreach ($data['items'] as $item) { + $bounces[] = Bounce::create($item); + } + } + + return new self($bounces, $data['paging']); + } + + /** + * @return Bounce[] + */ + public function getItems() + { + return $this->items; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Bounce/ShowResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Bounce/ShowResponse.php new file mode 100644 index 0000000..894babd --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Bounce/ShowResponse.php @@ -0,0 +1,19 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Suppression\Bounce; + +use Mailgun\Model\ApiResponse; + +/** + * @author Sean Johnson <sean@mailgun.com> + */ +final class ShowResponse extends Bounce implements ApiResponse +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Complaint/Complaint.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Complaint/Complaint.php new file mode 100644 index 0000000..c9506d2 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Complaint/Complaint.php @@ -0,0 +1,75 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Suppression\Complaint; + +/** + * @author Sean Johnson <sean@mailgun.com> + */ +class Complaint +{ + /** + * @var string + */ + private $address; + + /** + * @var \DateTime + */ + private $createdAt; + + /** + * @param string $address + */ + private function __construct($address) + { + $this->address = $address; + $this->createdAt = new \DateTime(); + } + + /** + * @param array $data + * + * @return Complaint + */ + public static function create(array $data) + { + $complaint = new self($data['address']); + + if (isset($data['created_at'])) { + $complaint->setCreatedAt(new \DateTime($data['created_at'])); + } + + return $complaint; + } + + /** + * @return string + */ + public function getAddress() + { + return $this->address; + } + + /** + * @return \DateTime + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + * @param \DateTime $createdAt + */ + private function setCreatedAt(\DateTime $createdAt) + { + $this->createdAt = $createdAt; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Complaint/CreateResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Complaint/CreateResponse.php new file mode 100644 index 0000000..78e3dde --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Complaint/CreateResponse.php @@ -0,0 +1,19 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Suppression\Complaint; + +use Mailgun\Model\Suppression\BaseResponse; + +/** + * @author Sean Johnson <sean@mailgun.com> + */ +final class CreateResponse extends BaseResponse +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Complaint/DeleteResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Complaint/DeleteResponse.php new file mode 100644 index 0000000..9c8ce93 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Complaint/DeleteResponse.php @@ -0,0 +1,19 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Suppression\Complaint; + +use Mailgun\Model\Suppression\BaseResponse; + +/** + * @author Sean Johnson <sean@mailgun.com> + */ +final class DeleteResponse extends BaseResponse +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Complaint/IndexResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Complaint/IndexResponse.php new file mode 100644 index 0000000..6f96b4f --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Complaint/IndexResponse.php @@ -0,0 +1,62 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Suppression\Complaint; + +use Mailgun\Model\ApiResponse; +use Mailgun\Model\PaginationResponse; +use Mailgun\Model\PagingProvider; + +/** + * @author Sean Johnson <sean@mailgun.com> + */ +final class IndexResponse implements ApiResponse, PagingProvider +{ + use PaginationResponse; + + /** + * @var Complaint[] + */ + private $items; + + /** + * @param Complaint[] $items + * @param array $paging + */ + private function __construct(array $items, array $paging) + { + $this->items = $items; + $this->paging = $paging; + } + + /** + * @param array $data + * + * @return IndexResponse + */ + public static function create(array $data) + { + $complaints = []; + if (isset($data['items'])) { + foreach ($data['items'] as $item) { + $complaints[] = Complaint::create($item); + } + } + + return new self($complaints, $data['paging']); + } + + /** + * @return Complaint[] + */ + public function getItems() + { + return $this->items; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Complaint/ShowResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Complaint/ShowResponse.php new file mode 100644 index 0000000..4ad2102 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Complaint/ShowResponse.php @@ -0,0 +1,19 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Suppression\Complaint; + +use Mailgun\Model\ApiResponse; + +/** + * @author Sean Johnson <sean@mailgun.com> + */ +final class ShowResponse extends Complaint implements ApiResponse +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Unsubscribe/CreateResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Unsubscribe/CreateResponse.php new file mode 100644 index 0000000..8d398f3 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Unsubscribe/CreateResponse.php @@ -0,0 +1,19 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Suppression\Unsubscribe; + +use Mailgun\Model\Suppression\BaseResponse; + +/** + * @author Sean Johnson <sean@mailgun.com> + */ +final class CreateResponse extends BaseResponse +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Unsubscribe/DeleteResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Unsubscribe/DeleteResponse.php new file mode 100644 index 0000000..c873026 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Unsubscribe/DeleteResponse.php @@ -0,0 +1,19 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Suppression\Unsubscribe; + +use Mailgun\Model\Suppression\BaseResponse; + +/** + * @author Sean Johnson <sean@mailgun.com> + */ +final class DeleteResponse extends BaseResponse +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Unsubscribe/IndexResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Unsubscribe/IndexResponse.php new file mode 100644 index 0000000..fb3ebda --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Unsubscribe/IndexResponse.php @@ -0,0 +1,62 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Suppression\Unsubscribe; + +use Mailgun\Model\ApiResponse; +use Mailgun\Model\PaginationResponse; +use Mailgun\Model\PagingProvider; + +/** + * @author Sean Johnson <sean@mailgun.com> + */ +final class IndexResponse implements ApiResponse, PagingProvider +{ + use PaginationResponse; + + /** + * @var Unsubscribe[] + */ + private $items; + + /** + * @param Unsubscribe[] $items + * @param array $paging + */ + private function __construct(array $items, array $paging) + { + $this->items = $items; + $this->paging = $paging; + } + + /** + * @param array $data + * + * @return IndexResponse + */ + public static function create(array $data) + { + $unsubscribes = []; + if (isset($data['items'])) { + foreach ($data['items'] as $item) { + $unsubscribes[] = Unsubscribe::create($item); + } + } + + return new self($unsubscribes, $data['paging']); + } + + /** + * @return Unsubscribe[] + */ + public function getItems() + { + return $this->items; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Unsubscribe/ShowResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Unsubscribe/ShowResponse.php new file mode 100644 index 0000000..558c92d --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Unsubscribe/ShowResponse.php @@ -0,0 +1,19 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Suppression\Unsubscribe; + +use Mailgun\Model\ApiResponse; + +/** + * @author Sean Johnson <sean@mailgun.com> + */ +final class ShowResponse extends Unsubscribe implements ApiResponse +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Unsubscribe/Unsubscribe.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Unsubscribe/Unsubscribe.php new file mode 100644 index 0000000..eed521d --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Suppression/Unsubscribe/Unsubscribe.php @@ -0,0 +1,99 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Suppression\Unsubscribe; + +/** + * @author Sean Johnson <sean@mailgun.com> + */ +class Unsubscribe +{ + /** + * @var string + */ + private $address; + + /** + * @var string + */ + private $tag; + + /** + * @var \DateTime + */ + private $createdAt; + + /** + * @param string $address + */ + private function __construct($address) + { + $this->address = $address; + $this->createdAt = new \DateTime(); + } + + /** + * @param array $data + * + * @return Unsubscribe + */ + public static function create(array $data) + { + $unsubscribe = new self($data['address']); + + if (isset($data['tag'])) { + $unsubscribe->setTag($data['tag']); + } + if (isset($data['created_at'])) { + $unsubscribe->setCreatedAt(new \DateTime($data['created_at'])); + } + + return $unsubscribe; + } + + /** + * @return string + */ + public function getAddress() + { + return $this->address; + } + + /** + * @return string + */ + public function getTag() + { + return $this->tag; + } + + /** + * @param string $tag + */ + private function setTag($tag) + { + $this->tag = $tag; + } + + /** + * @return \DateTime + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + * @param \DateTime $createdAt + */ + private function setCreatedAt(\DateTime $createdAt) + { + $this->createdAt = $createdAt; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Tag/DeleteResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Tag/DeleteResponse.php new file mode 100644 index 0000000..84f7a23 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Tag/DeleteResponse.php @@ -0,0 +1,49 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Tag; + +use Mailgun\Model\ApiResponse; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +final class DeleteResponse implements ApiResponse +{ + /** + * @var string + */ + private $message; + + /** + * @param string $message + */ + private function __construct($message) + { + $this->message = $message; + } + + /** + * @param array $data + * + * @return DeleteResponse + */ + public static function create(array $data) + { + return new self($data['message']); + } + + /** + * @return string + */ + public function getMessage() + { + return $this->message; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Tag/IndexResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Tag/IndexResponse.php new file mode 100644 index 0000000..feec846 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Tag/IndexResponse.php @@ -0,0 +1,60 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Tag; + +use Mailgun\Model\PaginationResponse; +use Mailgun\Model\PagingProvider; +use Mailgun\Model\ApiResponse; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +final class IndexResponse implements ApiResponse, PagingProvider +{ + use PaginationResponse; + + /** + * @var Tag[] + */ + private $items; + + /** + * @param Tag[] $items + * @param array $paging + */ + public function __construct(array $items, array $paging) + { + $this->items = $items; + $this->paging = $paging; + } + + /** + * @param array $data + * + * @return IndexResponse + */ + public static function create(array $data) + { + $items = []; + foreach ($data['items'] as $item) { + $items[] = Tag::create($item); + } + + return new self($items, $data['paging']); + } + + /** + * @return Tag[] + */ + public function getItems() + { + return $this->items; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Tag/ShowResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Tag/ShowResponse.php new file mode 100644 index 0000000..1c1d8e3 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Tag/ShowResponse.php @@ -0,0 +1,19 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Tag; + +use Mailgun\Model\ApiResponse; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +final class ShowResponse extends Tag implements ApiResponse +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Tag/StatisticsResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Tag/StatisticsResponse.php new file mode 100644 index 0000000..1716a6f --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Tag/StatisticsResponse.php @@ -0,0 +1,131 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Tag; + +use Mailgun\Model\ApiResponse; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +final class StatisticsResponse implements ApiResponse +{ + /** + * @var string + */ + private $tag; + + /** + * @var string + */ + private $description; + + /** + * @var string + */ + private $resolution; + + /** + * @var \DateTime + */ + private $start; + + /** + * @var \DateTime + */ + private $end; + + /** + * @var array + */ + private $stats; + + /** + * @param string $tag + * @param string $description + * @param \DateTime $start + * @param \DateTime $end + * @param string $resolution + * @param array $stats + */ + private function __construct($tag, $description, \DateTime $start, \DateTime $end, $resolution, array $stats) + { + $this->tag = $tag; + $this->description = $description; + $this->resolution = $resolution; + $this->start = $start; + $this->end = $end; + $this->stats = $stats; + } + + /** + * @param array $data + * + * @return StatisticsResponse + */ + public static function create(array $data) + { + return new self( + $data['tag'], + $data['description'], + new \DateTime($data['start']), + new \DateTime($data['end']), + $data['resolution'], + $data['stats'] + ); + } + + /** + * @return string + */ + public function getTag() + { + return $this->tag; + } + + /** + * @return string + */ + public function getDescription() + { + return $this->description; + } + + /** + * @return string + */ + public function getResolution() + { + return $this->resolution; + } + + /** + * @return \DateTime + */ + public function getStart() + { + return $this->start; + } + + /** + * @return \DateTime + */ + public function getEnd() + { + return $this->end; + } + + /** + * @return array + */ + public function getStats() + { + return $this->stats; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Tag/Tag.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Tag/Tag.php new file mode 100644 index 0000000..dabd6a7 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Tag/Tag.php @@ -0,0 +1,73 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Tag; + +class Tag +{ + /** + * @var string + */ + private $tag; + + /** + * @var string + */ + private $description; + + /** + * @var \DateTime + */ + private $firstSeen; + + /** + * @var \DateTime + */ + private $lastSeen; + + /** + * @param string $tag + * @param string $description + * @param \DateTime $firstSeen + * @param \DateTime $lastSeen + */ + public function __construct($tag, $description, \DateTime $firstSeen, \DateTime $lastSeen) + { + $this->tag = $tag; + $this->description = $description; + $this->firstSeen = $firstSeen; + $this->lastSeen = $lastSeen; + } + + /** + * @param array $data + * + * @return Tag + */ + public static function create(array $data) + { + return new self($data['tag'], $data['description'], $data['first-seen'], $data['last-seen']); + } + + /** + * @return string + */ + public function getTag() + { + return $this->tag; + } + + /** + * @return string + */ + public function getDescription() + { + return $this->description; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Tag/UpdateResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Tag/UpdateResponse.php new file mode 100644 index 0000000..4f4d2bd --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Tag/UpdateResponse.php @@ -0,0 +1,49 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Tag; + +use Mailgun\Model\ApiResponse; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +final class UpdateResponse implements ApiResponse +{ + /** + * @var string + */ + private $message; + + /** + * @param string $message + */ + private function __construct($message) + { + $this->message = $message; + } + + /** + * @param array $data + * + * @return UpdateResponse + */ + public static function create(array $data) + { + return new self($data['message']); + } + + /** + * @return string + */ + public function getMessage() + { + return $this->message; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Webhook/BaseResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Webhook/BaseResponse.php new file mode 100644 index 0000000..6cd0fe6 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Webhook/BaseResponse.php @@ -0,0 +1,78 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Webhook; + +use Mailgun\Model\ApiResponse; + +/** + * This is only mean to be the base response for Webhook API. + * + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +abstract class BaseResponse implements ApiResponse +{ + /** + * @var array + */ + private $webhook = []; + + /** + * @var string + */ + private $message; + + /** + * @param array $webhook + * @param string $message + */ + public function __construct(array $webhook, $message) + { + $this->webhook = $webhook; + $this->message = $message; + } + + /** + * @param array $data + * + * @return static + */ + public static function create(array $data) + { + $webhook = []; + $message = ''; + if (isset($data['webhook'])) { + $webhook = $data['webhook']; + } + + if (isset($data['message'])) { + $message = $data['message']; + } + + return new static($webhook, $message); + } + + /** + * @return string|null + */ + public function getWebhookUrl() + { + if (isset($this->webhook['url'])) { + return $this->webhook['url']; + } + } + + /** + * @return string + */ + public function getMessage() + { + return $this->message; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Webhook/CreateResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Webhook/CreateResponse.php new file mode 100644 index 0000000..43d93c0 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Webhook/CreateResponse.php @@ -0,0 +1,17 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Webhook; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +class CreateResponse extends BaseResponse +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Webhook/DeleteResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Webhook/DeleteResponse.php new file mode 100644 index 0000000..8f0c094 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Webhook/DeleteResponse.php @@ -0,0 +1,17 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Webhook; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +class DeleteResponse extends BaseResponse +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Webhook/IndexResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Webhook/IndexResponse.php new file mode 100644 index 0000000..6ed276c --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Webhook/IndexResponse.php @@ -0,0 +1,219 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Webhook; + +use Mailgun\Model\ApiResponse; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +class IndexResponse implements ApiResponse +{ + /** + * @var array + */ + private $bounce = []; + + /** + * @var array + */ + private $deliver = []; + + /** + * @var array + */ + private $drop = []; + + /** + * @var array + */ + private $spam = []; + + /** + * @var array + */ + private $unsubscribe = []; + + /** + * @var array + */ + private $click = []; + + /** + * @var array + */ + private $open = []; + + /** + * Do not let this object be creted without the ::create. + */ + private function __construct() + { + } + + /** + * @param array $data + * + * @return IndexResponse + */ + public static function create(array $data) + { + $self = new self(); + if (isset($data['bounce'])) { + $self->setBounce($data['bounce']); + } + if (isset($data['deliver'])) { + $self->setDeliver($data['deliver']); + } + if (isset($data['drop'])) { + $self->setDrop($data['drop']); + } + if (isset($data['spam'])) { + $self->setSpam($data['spam']); + } + if (isset($data['unsubscribe'])) { + $self->setUnsubscribe($data['unsubscribe']); + } + if (isset($data['click'])) { + $self->setClick($data['click']); + } + if (isset($data['open'])) { + $self->setOpen($data['open']); + } + + return $self; + } + + /** + * @return string|null + */ + public function getBounceUrl() + { + if (isset($this->bounce['url'])) { + return $this->bounce['url']; + } + } + + /** + * @param array $bounce + */ + private function setBounce($bounce) + { + $this->bounce = $bounce; + } + + /** + * @return string|null + */ + public function getDeliverUrl() + { + if (isset($this->deliver['url'])) { + return $this->deliver['url']; + } + } + + /** + * @param array $deliver + */ + private function setDeliver($deliver) + { + $this->deliver = $deliver; + } + + /** + * @return string|null + */ + public function getDropUrl() + { + if (isset($this->drop['url'])) { + return $this->drop['url']; + } + } + + /** + * @param array $drop + */ + private function setDrop($drop) + { + $this->drop = $drop; + } + + /** + * @return string|null + */ + public function getSpamUrl() + { + if (isset($this->spam['url'])) { + return $this->spam['url']; + } + } + + /** + * @param array $spam + */ + private function setSpam($spam) + { + $this->spam = $spam; + } + + /** + * @return string|null + */ + public function getUnsubscribeUrl() + { + if (isset($this->unsubscribe['url'])) { + return $this->unsubscribe['url']; + } + } + + /** + * @param array $unsubscribe + */ + private function setUnsubscribe($unsubscribe) + { + $this->unsubscribe = $unsubscribe; + } + + /** + * @return string|null + */ + public function getClickUrl() + { + if (isset($this->click['url'])) { + return $this->click['url']; + } + } + + /** + * @param array $click + */ + private function setClick($click) + { + $this->click = $click; + } + + /** + * @return string|null + */ + public function getOpenUrl() + { + if (isset($this->open['url'])) { + return $this->open['url']; + } + } + + /** + * @param array $open + */ + private function setOpen($open) + { + $this->open = $open; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Webhook/ShowResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Webhook/ShowResponse.php new file mode 100644 index 0000000..10a64c1 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Webhook/ShowResponse.php @@ -0,0 +1,56 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Webhook; + +use Mailgun\Model\ApiResponse; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +class ShowResponse implements ApiResponse +{ + /** + * @var array + */ + private $webhook = []; + + /** + * @param array $webhook + */ + public function __construct(array $webhook) + { + $this->webhook = $webhook; + } + + /** + * @param array $data + * + * @return ShowResponse + */ + public static function create(array $data) + { + $webhook = []; + if (isset($data['webhook'])) { + $webhook = $data['webhook']; + } + + return new self($webhook); + } + + /** + * @return string|null + */ + public function getWebhookUrl() + { + if (isset($this->webhook['url'])) { + return $this->webhook['url']; + } + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Webhook/UpdateResponse.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Webhook/UpdateResponse.php new file mode 100644 index 0000000..7ab0c3f --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/Model/Webhook/UpdateResponse.php @@ -0,0 +1,17 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun\Model\Webhook; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +class UpdateResponse extends BaseResponse +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/RequestBuilder.php b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/RequestBuilder.php new file mode 100644 index 0000000..db1f0b1 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/mailgun/mailgun-php/src/Mailgun/RequestBuilder.php @@ -0,0 +1,121 @@ +<?php + +/* + * Copyright (C) 2013-2016 Mailgun + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +namespace Mailgun; + +use Http\Discovery\MessageFactoryDiscovery; +use Http\Message\MultipartStream\MultipartStreamBuilder; +use Http\Message\RequestFactory; +use Psr\Http\Message\RequestInterface; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +class RequestBuilder +{ + /** + * @var RequestFactory + */ + private $requestFactory; + + /** + * @var MultipartStreamBuilder + */ + private $multipartStreamBuilder; + + /** + * Creates a new PSR-7 request. + * + * @param string $method + * @param string $uri + * @param array $headers + * @param array|string|null $body Request body. If body is an array we will send a as multipart stream request. + * If array, each array *item* MUST look like: + * array ( + * 'content' => string|resource|StreamInterface, + * 'name' => string, + * 'filename'=> string (optional) + * 'headers' => array (optinal) ['header-name' => 'header-value'] + * ) + * + * @return RequestInterface + */ + public function create($method, $uri, array $headers = [], $body = null) + { + if (!is_array($body)) { + return $this->getRequestFactory()->createRequest($method, $uri, $headers, $body); + } + + $builder = $this->getMultipartStreamBuilder(); + foreach ($body as $item) { + $name = $item['name']; + $content = $item['content']; + unset($item['name']); + unset($item['content']); + + $builder->addResource($name, $content, $item); + } + + $multipartStream = $builder->build(); + $boundary = $builder->getBoundary(); + $builder->reset(); + + $headers['Content-Type'] = 'multipart/form-data; boundary="'.$boundary.'"'; + + return $this->getRequestFactory()->createRequest($method, $uri, $headers, $multipartStream); + } + + /** + * @return RequestFactory + */ + private function getRequestFactory() + { + if ($this->requestFactory === null) { + $this->requestFactory = MessageFactoryDiscovery::find(); + } + + return $this->requestFactory; + } + + /** + * @param RequestFactory $requestFactory + * + * @return RequestBuilder + */ + public function setRequestFactory($requestFactory) + { + $this->requestFactory = $requestFactory; + + return $this; + } + + /** + * @return MultipartStreamBuilder + */ + private function getMultipartStreamBuilder() + { + if ($this->multipartStreamBuilder === null) { + $this->multipartStreamBuilder = new MultipartStreamBuilder(); + } + + return $this->multipartStreamBuilder; + } + + /** + * @param MultipartStreamBuilder $multipartStreamBuilder + * + * @return RequestBuilder + */ + public function setMultipartStreamBuilder($multipartStreamBuilder) + { + $this->multipartStreamBuilder = $multipartStreamBuilder; + + return $this; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/CHANGELOG.md b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/CHANGELOG.md new file mode 100644 index 0000000..3031720 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/CHANGELOG.md @@ -0,0 +1,137 @@ +# Change Log + +## 1.7.0 - 2017-11-30 + +### Added + +- Symfony 4 support + +### Changed + +- Strict comparison in DecoderPlugin + +## 1.6.0 - 2017-10-16 + +### Added + +- Add HttpClientPool client to leverage load balancing and fallback mechanism [see the documentation](http://docs.php-http.org/en/latest/components/client-common.html) for more details. +- `PluginClientFactory` to create `PluginClient` instances. +- Added new option 'delay' for `RetryPlugin`. +- Added new option 'decider' for `RetryPlugin`. +- Supports more cookie date formats in the Cookie Plugin + +### Changed + +- The `RetryPlugin` does now wait between retries. To disable/change this feature you must write something like: + +```php +$plugin = new RetryPlugin(['delay' => function(RequestInterface $request, Exception $e, $retries) { + return 0; +}); +``` + +### Deprecated + +- The `debug_plugins` option for `PluginClient` is deprecated and will be removed in 2.0. Use the decorator design pattern instead like in [ProfilePlugin](https://github.com/php-http/HttplugBundle/blob/de33f9c14252f22093a5ec7d84f17535ab31a384/Collector/ProfilePlugin.php). + +## 1.5.0 - 2017-03-30 + +### Added + +- `QueryDefaultsPlugin` to add default query parameters. + +## 1.4.2 - 2017-03-18 + +### Deprecated + +- `DecoderPlugin` does not longer claim to support `compress` content encoding + +### Fixed + +- `CookiePlugin` allows main domain cookies to be sent/stored for subdomains +- `DecoderPlugin` uses the right `FilteredStream` to handle `deflate` content encoding + + +## 1.4.1 - 2017-02-20 + +### Fixed + +- Cast return value of `StreamInterface::getSize` to string in `ContentLengthPlugin` + + +## 1.4.0 - 2016-11-04 + +### Added + +- Add Path plugin +- Base URI plugin that combines Add Host and Add Path plugins + + +## 1.3.0 - 2016-10-16 + +### Changed + +- Fix Emulated Trait to use Http based promise which respect the HttpAsyncClient interface +- Require Httplug 1.1 where we use HTTP specific promises. +- RedirectPlugin: use the full URL instead of the URI to properly keep track of redirects +- Add AddPathPlugin for API URLs with base path +- Add BaseUriPlugin that combines AddHostPlugin and AddPathPlugin + + +## 1.2.1 - 2016-07-26 + +### Changed + +- AddHostPlugin also sets the port if specified + + +## 1.2.0 - 2016-07-14 + +### Added + +- Suggest separate plugins in composer.json +- Introduced `debug_plugins` option for `PluginClient` + + +## 1.1.0 - 2016-05-04 + +### Added + +- Add a flexible http client providing both contract, and only emulating what's necessary +- HTTP Client Router: route requests to underlying clients +- Plugin client and core plugins moved here from `php-http/plugins` + +### Deprecated + +- Extending client classes, they will be made final in version 2.0 + + +## 1.0.0 - 2016-01-27 + +### Changed + +- Remove useless interface in BatchException + + +## 0.2.0 - 2016-01-12 + +### Changed + +- Updated package files +- Updated HTTPlug to RC1 + + +## 0.1.1 - 2015-12-26 + +### Added + +- Emulated clients + + +## 0.1.0 - 2015-12-25 + +### Added + +- Batch client from utils +- Methods client from utils +- Emulators and decorators from client-tools diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/LICENSE b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/LICENSE new file mode 100644 index 0000000..4558d6f --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2015-2016 PHP HTTP Team <team@php-http.org> + +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/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/README.md b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/README.md new file mode 100644 index 0000000..017bfce --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/README.md @@ -0,0 +1,55 @@ +# HTTP Client Common + +[![Latest Version](https://img.shields.io/github/release/php-http/client-common.svg?style=flat-square)](https://github.com/php-http/client-common/releases) +[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) +[![Build Status](https://img.shields.io/travis/php-http/client-common.svg?style=flat-square)](https://travis-ci.org/php-http/client-common) +[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/php-http/client-common.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/client-common) +[![Quality Score](https://img.shields.io/scrutinizer/g/php-http/client-common.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/client-common) +[![Total Downloads](https://img.shields.io/packagist/dt/php-http/client-common.svg?style=flat-square)](https://packagist.org/packages/php-http/client-common) + +**Common HTTP Client implementations and tools for HTTPlug.** + + +## Install + +Via Composer + +``` bash +$ composer require php-http/client-common +``` + + +## Usage + +This package provides common tools for HTTP Clients: + +- BatchClient to handle sending requests in parallel +- A convenience client with HTTP method names as class methods +- Emulator, decorator layers for sync/async clients + + +## Documentation + +Please see the [official documentation](http://docs.php-http.org/en/latest/components/client-common.html). + + +## Testing + +``` bash +$ composer test +``` + + +## Contributing + +Please see our [contributing guide](http://docs.php-http.org/en/latest/development/contributing.html). + + +## Security + +If you discover any security related issues, please contact us at [security@php-http.org](mailto:security@php-http.org). + + +## License + +The MIT License (MIT). Please see [License File](LICENSE) for more information. diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/composer.json b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/composer.json new file mode 100644 index 0000000..fc5fc5f --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/composer.json @@ -0,0 +1,43 @@ +{ + "name": "php-http/client-common", + "description": "Common HTTP Client implementations and tools for HTTPlug", + "license": "MIT", + "keywords": ["http", "client", "httplug", "common"], + "homepage": "http://httplug.io", + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "require": { + "php": "^5.4 || ^7.0", + "php-http/httplug": "^1.1", + "php-http/message-factory": "^1.0", + "php-http/message": "^1.6", + "symfony/options-resolver": "^2.6 || ^3.0 || ^4.0" + }, + "require-dev": { + "phpspec/phpspec": "^2.5 || ^3.4 || ^4.2", + "guzzlehttp/psr7": "^1.4" + }, + "suggest": { + "php-http/logger-plugin": "PSR-3 Logger plugin", + "php-http/cache-plugin": "PSR-6 Cache plugin", + "php-http/stopwatch-plugin": "Symfony Stopwatch plugin" + }, + "autoload": { + "psr-4": { + "Http\\Client\\Common\\": "src/" + } + }, + "scripts": { + "test": "vendor/bin/phpspec run", + "test-ci": "vendor/bin/phpspec run -c phpspec.ci.yml" + }, + "extra": { + "branch-alias": { + "dev-master": "1.7-dev" + } + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/BatchClient.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/BatchClient.php new file mode 100644 index 0000000..2036355 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/BatchClient.php @@ -0,0 +1,73 @@ +<?php + +namespace Http\Client\Common; + +use Http\Client\Exception; +use Http\Client\HttpClient; +use Http\Client\Common\Exception\BatchException; +use Psr\Http\Message\RequestInterface; + +/** + * BatchClient allow to sends multiple request and retrieve a Batch Result. + * + * This implementation simply loops over the requests and uses sendRequest with each of them. + * + * @author Joel Wurtz <jwurtz@jolicode.com> + */ +class BatchClient implements HttpClient +{ + /** + * @var HttpClient + */ + private $client; + + /** + * @param HttpClient $client + */ + public function __construct(HttpClient $client) + { + $this->client = $client; + } + + /** + * {@inheritdoc} + */ + public function sendRequest(RequestInterface $request) + { + return $this->client->sendRequest($request); + } + + /** + * Send several requests. + * + * You may not assume that the requests are executed in a particular order. If the order matters + * for your application, use sendRequest sequentially. + * + * @param RequestInterface[] The requests to send + * + * @return BatchResult Containing one result per request + * + * @throws BatchException If one or more requests fails. The exception gives access to the + * BatchResult with a map of request to result for success, request to + * exception for failures + */ + public function sendRequests(array $requests) + { + $batchResult = new BatchResult(); + + foreach ($requests as $request) { + try { + $response = $this->sendRequest($request); + $batchResult = $batchResult->addResponse($request, $response); + } catch (Exception $e) { + $batchResult = $batchResult->addException($request, $e); + } + } + + if ($batchResult->hasExceptions()) { + throw new BatchException($batchResult); + } + + return $batchResult; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/BatchResult.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/BatchResult.php new file mode 100644 index 0000000..710611d --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/BatchResult.php @@ -0,0 +1,181 @@ +<?php + +namespace Http\Client\Common; + +use Http\Client\Exception; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; + +/** + * Responses and exceptions returned from parallel request execution. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +final class BatchResult +{ + /** + * @var \SplObjectStorage + */ + private $responses; + + /** + * @var \SplObjectStorage + */ + private $exceptions; + + public function __construct() + { + $this->responses = new \SplObjectStorage(); + $this->exceptions = new \SplObjectStorage(); + } + + /** + * Checks if there are any successful responses at all. + * + * @return bool + */ + public function hasResponses() + { + return $this->responses->count() > 0; + } + + /** + * Returns all successful responses. + * + * @return ResponseInterface[] + */ + public function getResponses() + { + $responses = []; + + foreach ($this->responses as $request) { + $responses[] = $this->responses[$request]; + } + + return $responses; + } + + /** + * Checks if there is a successful response for a request. + * + * @param RequestInterface $request + * + * @return bool + */ + public function isSuccessful(RequestInterface $request) + { + return $this->responses->contains($request); + } + + /** + * Returns the response for a successful request. + * + * @param RequestInterface $request + * + * @return ResponseInterface + * + * @throws \UnexpectedValueException If request was not part of the batch or failed + */ + public function getResponseFor(RequestInterface $request) + { + try { + return $this->responses[$request]; + } catch (\UnexpectedValueException $e) { + throw new \UnexpectedValueException('Request not found', $e->getCode(), $e); + } + } + + /** + * Adds a response in an immutable way. + * + * @param RequestInterface $request + * @param ResponseInterface $response + * + * @return BatchResult the new BatchResult with this request-response pair added to it + */ + public function addResponse(RequestInterface $request, ResponseInterface $response) + { + $new = clone $this; + $new->responses->attach($request, $response); + + return $new; + } + + /** + * Checks if there are any unsuccessful requests at all. + * + * @return bool + */ + public function hasExceptions() + { + return $this->exceptions->count() > 0; + } + + /** + * Returns all exceptions for the unsuccessful requests. + * + * @return Exception[] + */ + public function getExceptions() + { + $exceptions = []; + + foreach ($this->exceptions as $request) { + $exceptions[] = $this->exceptions[$request]; + } + + return $exceptions; + } + + /** + * Checks if there is an exception for a request, meaning the request failed. + * + * @param RequestInterface $request + * + * @return bool + */ + public function isFailed(RequestInterface $request) + { + return $this->exceptions->contains($request); + } + + /** + * Returns the exception for a failed request. + * + * @param RequestInterface $request + * + * @return Exception + * + * @throws \UnexpectedValueException If request was not part of the batch or was successful + */ + public function getExceptionFor(RequestInterface $request) + { + try { + return $this->exceptions[$request]; + } catch (\UnexpectedValueException $e) { + throw new \UnexpectedValueException('Request not found', $e->getCode(), $e); + } + } + + /** + * Adds an exception in an immutable way. + * + * @param RequestInterface $request + * @param Exception $exception + * + * @return BatchResult the new BatchResult with this request-exception pair added to it + */ + public function addException(RequestInterface $request, Exception $exception) + { + $new = clone $this; + $new->exceptions->attach($request, $exception); + + return $new; + } + + public function __clone() + { + $this->responses = clone $this->responses; + $this->exceptions = clone $this->exceptions; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/EmulatedHttpAsyncClient.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/EmulatedHttpAsyncClient.php new file mode 100644 index 0000000..1b16316 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/EmulatedHttpAsyncClient.php @@ -0,0 +1,27 @@ +<?php + +namespace Http\Client\Common; + +use Http\Client\HttpAsyncClient; +use Http\Client\HttpClient; + +/** + * Emulates an async HTTP client. + * + * This should be replaced by an anonymous class in PHP 7. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +class EmulatedHttpAsyncClient implements HttpClient, HttpAsyncClient +{ + use HttpAsyncClientEmulator; + use HttpClientDecorator; + + /** + * @param HttpClient $httpClient + */ + public function __construct(HttpClient $httpClient) + { + $this->httpClient = $httpClient; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/EmulatedHttpClient.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/EmulatedHttpClient.php new file mode 100644 index 0000000..01046c8 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/EmulatedHttpClient.php @@ -0,0 +1,27 @@ +<?php + +namespace Http\Client\Common; + +use Http\Client\HttpAsyncClient; +use Http\Client\HttpClient; + +/** + * Emulates an HTTP client. + * + * This should be replaced by an anonymous class in PHP 7. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +class EmulatedHttpClient implements HttpClient, HttpAsyncClient +{ + use HttpAsyncClientDecorator; + use HttpClientEmulator; + + /** + * @param HttpAsyncClient $httpAsyncClient + */ + public function __construct(HttpAsyncClient $httpAsyncClient) + { + $this->httpAsyncClient = $httpAsyncClient; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Exception/BatchException.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Exception/BatchException.php new file mode 100644 index 0000000..66a9271 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Exception/BatchException.php @@ -0,0 +1,39 @@ +<?php + +namespace Http\Client\Common\Exception; + +use Http\Client\Exception\TransferException; +use Http\Client\Common\BatchResult; + +/** + * This exception is thrown when HttpClient::sendRequests led to at least one failure. + * + * It gives access to a BatchResult with the request-exception and request-response pairs. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +final class BatchException extends TransferException +{ + /** + * @var BatchResult + */ + private $result; + + /** + * @param BatchResult $result + */ + public function __construct(BatchResult $result) + { + $this->result = $result; + } + + /** + * Returns the BatchResult that contains all responses and exceptions. + * + * @return BatchResult + */ + public function getResult() + { + return $this->result; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Exception/CircularRedirectionException.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Exception/CircularRedirectionException.php new file mode 100644 index 0000000..73ec521 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Exception/CircularRedirectionException.php @@ -0,0 +1,14 @@ +<?php + +namespace Http\Client\Common\Exception; + +use Http\Client\Exception\HttpException; + +/** + * Thrown when circular redirection is detected. + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +class CircularRedirectionException extends HttpException +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Exception/ClientErrorException.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Exception/ClientErrorException.php new file mode 100644 index 0000000..b1f6cc8 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Exception/ClientErrorException.php @@ -0,0 +1,14 @@ +<?php + +namespace Http\Client\Common\Exception; + +use Http\Client\Exception\HttpException; + +/** + * Thrown when there is a client error (4xx). + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +class ClientErrorException extends HttpException +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Exception/HttpClientNotFoundException.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Exception/HttpClientNotFoundException.php new file mode 100644 index 0000000..5d33f98 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Exception/HttpClientNotFoundException.php @@ -0,0 +1,14 @@ +<?php + +namespace Http\Client\Common\Exception; + +use Http\Client\Exception\TransferException; + +/** + * Thrown when a http client cannot be chosen in a pool. + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +class HttpClientNotFoundException extends TransferException +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Exception/LoopException.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Exception/LoopException.php new file mode 100644 index 0000000..e834124 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Exception/LoopException.php @@ -0,0 +1,14 @@ +<?php + +namespace Http\Client\Common\Exception; + +use Http\Client\Exception\RequestException; + +/** + * Thrown when the Plugin Client detects an endless loop. + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +class LoopException extends RequestException +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Exception/MultipleRedirectionException.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Exception/MultipleRedirectionException.php new file mode 100644 index 0000000..ae514cd --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Exception/MultipleRedirectionException.php @@ -0,0 +1,14 @@ +<?php + +namespace Http\Client\Common\Exception; + +use Http\Client\Exception\HttpException; + +/** + * Redirect location cannot be chosen. + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +class MultipleRedirectionException extends HttpException +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Exception/ServerErrorException.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Exception/ServerErrorException.php new file mode 100644 index 0000000..665d724 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Exception/ServerErrorException.php @@ -0,0 +1,14 @@ +<?php + +namespace Http\Client\Common\Exception; + +use Http\Client\Exception\HttpException; + +/** + * Thrown when there is a server error (5xx). + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +class ServerErrorException extends HttpException +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/FlexibleHttpClient.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/FlexibleHttpClient.php new file mode 100644 index 0000000..58f8813 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/FlexibleHttpClient.php @@ -0,0 +1,39 @@ +<?php + +namespace Http\Client\Common; + +use Http\Client\HttpAsyncClient; +use Http\Client\HttpClient; + +/** + * A flexible http client, which implements both interface and will emulate + * one contract, the other, or none at all depending on the injected client contract. + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +final class FlexibleHttpClient implements HttpClient, HttpAsyncClient +{ + use HttpClientDecorator; + use HttpAsyncClientDecorator; + + /** + * @param HttpClient|HttpAsyncClient $client + */ + public function __construct($client) + { + if (!($client instanceof HttpClient) && !($client instanceof HttpAsyncClient)) { + throw new \LogicException('Client must be an instance of Http\\Client\\HttpClient or Http\\Client\\HttpAsyncClient'); + } + + $this->httpClient = $client; + $this->httpAsyncClient = $client; + + if (!($this->httpClient instanceof HttpClient)) { + $this->httpClient = new EmulatedHttpClient($this->httpClient); + } + + if (!($this->httpAsyncClient instanceof HttpAsyncClient)) { + $this->httpAsyncClient = new EmulatedHttpAsyncClient($this->httpAsyncClient); + } + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpAsyncClientDecorator.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpAsyncClientDecorator.php new file mode 100644 index 0000000..6eb576c --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpAsyncClientDecorator.php @@ -0,0 +1,29 @@ +<?php + +namespace Http\Client\Common; + +use Http\Client\HttpAsyncClient; +use Psr\Http\Message\RequestInterface; + +/** + * Decorates an HTTP Async Client. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +trait HttpAsyncClientDecorator +{ + /** + * @var HttpAsyncClient + */ + protected $httpAsyncClient; + + /** + * {@inheritdoc} + * + * @see HttpAsyncClient::sendAsyncRequest + */ + public function sendAsyncRequest(RequestInterface $request) + { + return $this->httpAsyncClient->sendAsyncRequest($request); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpAsyncClientEmulator.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpAsyncClientEmulator.php new file mode 100644 index 0000000..c0ba354 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpAsyncClientEmulator.php @@ -0,0 +1,36 @@ +<?php + +namespace Http\Client\Common; + +use Http\Client\Exception; +use Http\Client\Promise; +use Psr\Http\Message\RequestInterface; + +/** + * Emulates an HTTP Async Client in an HTTP Client. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +trait HttpAsyncClientEmulator +{ + /** + * {@inheritdoc} + * + * @see HttpClient::sendRequest + */ + abstract public function sendRequest(RequestInterface $request); + + /** + * {@inheritdoc} + * + * @see HttpAsyncClient::sendAsyncRequest + */ + public function sendAsyncRequest(RequestInterface $request) + { + try { + return new Promise\HttpFulfilledPromise($this->sendRequest($request)); + } catch (Exception $e) { + return new Promise\HttpRejectedPromise($e); + } + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpClientDecorator.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpClientDecorator.php new file mode 100644 index 0000000..a33d5ef --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpClientDecorator.php @@ -0,0 +1,29 @@ +<?php + +namespace Http\Client\Common; + +use Http\Client\HttpClient; +use Psr\Http\Message\RequestInterface; + +/** + * Decorates an HTTP Client. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +trait HttpClientDecorator +{ + /** + * @var HttpClient + */ + protected $httpClient; + + /** + * {@inheritdoc} + * + * @see HttpClient::sendRequest + */ + public function sendRequest(RequestInterface $request) + { + return $this->httpClient->sendRequest($request); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpClientEmulator.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpClientEmulator.php new file mode 100644 index 0000000..dbec1ab --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpClientEmulator.php @@ -0,0 +1,32 @@ +<?php + +namespace Http\Client\Common; + +use Psr\Http\Message\RequestInterface; + +/** + * Emulates an HTTP Client in an HTTP Async Client. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +trait HttpClientEmulator +{ + /** + * {@inheritdoc} + * + * @see HttpClient::sendRequest + */ + public function sendRequest(RequestInterface $request) + { + $promise = $this->sendAsyncRequest($request); + + return $promise->wait(); + } + + /** + * {@inheritdoc} + * + * @see HttpAsyncClient::sendAsyncRequest + */ + abstract public function sendAsyncRequest(RequestInterface $request); +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpClientPool.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpClientPool.php new file mode 100644 index 0000000..7ac292c --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpClientPool.php @@ -0,0 +1,59 @@ +<?php + +namespace Http\Client\Common; + +use Http\Client\Common\Exception\HttpClientNotFoundException; +use Http\Client\HttpAsyncClient; +use Http\Client\HttpClient; +use Psr\Http\Message\RequestInterface; + +/** + * A http client pool allows to send requests on a pool of different http client using a specific strategy (least used, + * round robin, ...). + */ +abstract class HttpClientPool implements HttpAsyncClient, HttpClient +{ + /** + * @var HttpClientPoolItem[] + */ + protected $clientPool = []; + + /** + * Add a client to the pool. + * + * @param HttpClient|HttpAsyncClient|HttpClientPoolItem $client + */ + public function addHttpClient($client) + { + if (!$client instanceof HttpClientPoolItem) { + $client = new HttpClientPoolItem($client); + } + + $this->clientPool[] = $client; + } + + /** + * Return an http client given a specific strategy. + * + * @throws HttpClientNotFoundException When no http client has been found into the pool + * + * @return HttpClientPoolItem Return a http client that can do both sync or async + */ + abstract protected function chooseHttpClient(); + + /** + * {@inheritdoc} + */ + public function sendAsyncRequest(RequestInterface $request) + { + return $this->chooseHttpClient()->sendAsyncRequest($request); + } + + /** + * {@inheritdoc} + */ + public function sendRequest(RequestInterface $request) + { + return $this->chooseHttpClient()->sendRequest($request); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpClientPool/LeastUsedClientPool.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpClientPool/LeastUsedClientPool.php new file mode 100644 index 0000000..6299cce --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpClientPool/LeastUsedClientPool.php @@ -0,0 +1,45 @@ +<?php + +namespace Http\Client\Common\HttpClientPool; + +use Http\Client\Common\Exception\HttpClientNotFoundException; +use Http\Client\Common\HttpClientPool; +use Http\Client\Common\HttpClientPoolItem; + +/** + * LeastUsedClientPool will choose the client with the less current request in the pool. + * + * This strategy is only useful when doing async request + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +final class LeastUsedClientPool extends HttpClientPool +{ + /** + * {@inheritdoc} + */ + protected function chooseHttpClient() + { + $clientPool = array_filter($this->clientPool, function (HttpClientPoolItem $clientPoolItem) { + return !$clientPoolItem->isDisabled(); + }); + + if (0 === count($clientPool)) { + throw new HttpClientNotFoundException('Cannot choose a http client as there is no one present in the pool'); + } + + usort($clientPool, function (HttpClientPoolItem $clientA, HttpClientPoolItem $clientB) { + if ($clientA->getSendingRequestCount() === $clientB->getSendingRequestCount()) { + return 0; + } + + if ($clientA->getSendingRequestCount() < $clientB->getSendingRequestCount()) { + return -1; + } + + return 1; + }); + + return reset($clientPool); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpClientPool/RandomClientPool.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpClientPool/RandomClientPool.php new file mode 100644 index 0000000..3255f86 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpClientPool/RandomClientPool.php @@ -0,0 +1,31 @@ +<?php + +namespace Http\Client\Common\HttpClientPool; + +use Http\Client\Common\Exception\HttpClientNotFoundException; +use Http\Client\Common\HttpClientPool; +use Http\Client\Common\HttpClientPoolItem; + +/** + * RoundRobinClientPool will choose the next client in the pool. + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +final class RandomClientPool extends HttpClientPool +{ + /** + * {@inheritdoc} + */ + protected function chooseHttpClient() + { + $clientPool = array_filter($this->clientPool, function (HttpClientPoolItem $clientPoolItem) { + return !$clientPoolItem->isDisabled(); + }); + + if (0 === count($clientPool)) { + throw new HttpClientNotFoundException('Cannot choose a http client as there is no one present in the pool'); + } + + return $clientPool[array_rand($clientPool)]; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpClientPool/RoundRobinClientPool.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpClientPool/RoundRobinClientPool.php new file mode 100644 index 0000000..8d8e40a --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpClientPool/RoundRobinClientPool.php @@ -0,0 +1,41 @@ +<?php + +namespace Http\Client\Common\HttpClientPool; + +use Http\Client\Common\Exception\HttpClientNotFoundException; +use Http\Client\Common\HttpClientPool; + +/** + * RoundRobinClientPool will choose the next client in the pool. + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +final class RoundRobinClientPool extends HttpClientPool +{ + /** + * {@inheritdoc} + */ + protected function chooseHttpClient() + { + $last = current($this->clientPool); + + do { + $client = next($this->clientPool); + + if (false === $client) { + $client = reset($this->clientPool); + + if (false === $client) { + throw new HttpClientNotFoundException('Cannot choose a http client as there is no one present in the pool'); + } + } + + // Case when there is only one and the last one has been disabled + if ($last === $client && $client->isDisabled()) { + throw new HttpClientNotFoundException('Cannot choose a http client as there is no one enabled in the pool'); + } + } while ($client->isDisabled()); + + return $client; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpClientPoolItem.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpClientPoolItem.php new file mode 100644 index 0000000..09cd6dd --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpClientPoolItem.php @@ -0,0 +1,178 @@ +<?php + +namespace Http\Client\Common; + +use Http\Client\HttpAsyncClient; +use Http\Client\HttpClient; +use Psr\Http\Message\RequestInterface; +use Http\Client\Exception; + +/** + * A HttpClientPoolItem represent a HttpClient inside a Pool. + * + * It is disabled when a request failed and can be reenable after a certain number of seconds + * It also keep tracks of the current number of request the client is currently sending (only usable for async method) + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +class HttpClientPoolItem implements HttpClient, HttpAsyncClient +{ + /** + * @var int Number of request this client is currently sending + */ + private $sendingRequestCount = 0; + + /** + * @var \DateTime|null Time when this client has been disabled or null if enable + */ + private $disabledAt; + + /** + * @var int|null Number of seconds after this client is reenable, by default null: never reenable this client + */ + private $reenableAfter; + + /** + * @var FlexibleHttpClient A http client responding to async and sync request + */ + private $client; + + /** + * @param HttpClient|HttpAsyncClient $client + * @param null|int $reenableAfter Number of seconds after this client is reenable + */ + public function __construct($client, $reenableAfter = null) + { + $this->client = new FlexibleHttpClient($client); + $this->reenableAfter = $reenableAfter; + } + + /** + * {@inheritdoc} + */ + public function sendRequest(RequestInterface $request) + { + if ($this->isDisabled()) { + throw new Exception\RequestException('Cannot send the request as this client has been disabled', $request); + } + + try { + $this->incrementRequestCount(); + $response = $this->client->sendRequest($request); + $this->decrementRequestCount(); + } catch (Exception $e) { + $this->disable(); + $this->decrementRequestCount(); + + throw $e; + } + + return $response; + } + + /** + * {@inheritdoc} + */ + public function sendAsyncRequest(RequestInterface $request) + { + if ($this->isDisabled()) { + throw new Exception\RequestException('Cannot send the request as this client has been disabled', $request); + } + + $this->incrementRequestCount(); + + return $this->client->sendAsyncRequest($request)->then(function ($response) { + $this->decrementRequestCount(); + + return $response; + }, function ($exception) { + $this->disable(); + $this->decrementRequestCount(); + + throw $exception; + }); + } + + /** + * Whether this client is disabled or not. + * + * Will also reactivate this client if possible + * + * @internal + * + * @return bool + */ + public function isDisabled() + { + $disabledAt = $this->getDisabledAt(); + + if (null !== $this->reenableAfter && null !== $disabledAt) { + // Reenable after a certain time + $now = new \DateTime(); + + if (($now->getTimestamp() - $disabledAt->getTimestamp()) >= $this->reenableAfter) { + $this->enable(); + + return false; + } + + return true; + } + + return null !== $disabledAt; + } + + /** + * Get current number of request that is send by the underlying http client. + * + * @internal + * + * @return int + */ + public function getSendingRequestCount() + { + return $this->sendingRequestCount; + } + + /** + * Return when this client has been disabled or null if it's enabled. + * + * @return \DateTime|null + */ + private function getDisabledAt() + { + return $this->disabledAt; + } + + /** + * Increment the request count. + */ + private function incrementRequestCount() + { + ++$this->sendingRequestCount; + } + + /** + * Decrement the request count. + */ + private function decrementRequestCount() + { + --$this->sendingRequestCount; + } + + /** + * Enable the current client. + */ + private function enable() + { + $this->disabledAt = null; + } + + /** + * Disable the current client. + */ + private function disable() + { + $this->disabledAt = new \DateTime('now'); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpClientRouter.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpClientRouter.php new file mode 100644 index 0000000..9f72133 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpClientRouter.php @@ -0,0 +1,74 @@ +<?php + +namespace Http\Client\Common; + +use Http\Client\Exception\RequestException; +use Http\Client\HttpAsyncClient; +use Http\Client\HttpClient; +use Http\Message\RequestMatcher; +use Psr\Http\Message\RequestInterface; + +/** + * Route a request to a specific client in the stack based using a RequestMatcher. + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +final class HttpClientRouter implements HttpClient, HttpAsyncClient +{ + /** + * @var array + */ + private $clients = []; + + /** + * {@inheritdoc} + */ + public function sendRequest(RequestInterface $request) + { + $client = $this->chooseHttpClient($request); + + return $client->sendRequest($request); + } + + /** + * {@inheritdoc} + */ + public function sendAsyncRequest(RequestInterface $request) + { + $client = $this->chooseHttpClient($request); + + return $client->sendAsyncRequest($request); + } + + /** + * Add a client to the router. + * + * @param HttpClient|HttpAsyncClient $client + * @param RequestMatcher $requestMatcher + */ + public function addClient($client, RequestMatcher $requestMatcher) + { + $this->clients[] = [ + 'matcher' => $requestMatcher, + 'client' => new FlexibleHttpClient($client), + ]; + } + + /** + * Choose an HTTP client given a specific request. + * + * @param RequestInterface $request + * + * @return HttpClient|HttpAsyncClient + */ + protected function chooseHttpClient(RequestInterface $request) + { + foreach ($this->clients as $client) { + if ($client['matcher']->matches($request)) { + return $client['client']; + } + } + + throw new RequestException('No client found for the specified request', $request); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpMethodsClient.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpMethodsClient.php new file mode 100644 index 0000000..58804fc --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/HttpMethodsClient.php @@ -0,0 +1,205 @@ +<?php + +namespace Http\Client\Common; + +use Http\Client\Exception; +use Http\Client\HttpClient; +use Http\Message\RequestFactory; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\StreamInterface; +use Psr\Http\Message\UriInterface; + +/** + * Convenience HTTP client that integrates the MessageFactory in order to send + * requests in the following form:. + * + * $client + * ->get('/foo') + * ->post('/bar') + * ; + * + * The client also exposes the sendRequest methods of the wrapped HttpClient. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + * @author David Buchmann <mail@davidbu.ch> + */ +class HttpMethodsClient implements HttpClient +{ + /** + * @var HttpClient + */ + private $httpClient; + + /** + * @var RequestFactory + */ + private $requestFactory; + + /** + * @param HttpClient $httpClient The client to send requests with + * @param RequestFactory $requestFactory The message factory to create requests + */ + public function __construct(HttpClient $httpClient, RequestFactory $requestFactory) + { + $this->httpClient = $httpClient; + $this->requestFactory = $requestFactory; + } + + /** + * Sends a GET request. + * + * @param string|UriInterface $uri + * @param array $headers + * + * @throws Exception + * + * @return ResponseInterface + */ + public function get($uri, array $headers = []) + { + return $this->send('GET', $uri, $headers, null); + } + + /** + * Sends an HEAD request. + * + * @param string|UriInterface $uri + * @param array $headers + * + * @throws Exception + * + * @return ResponseInterface + */ + public function head($uri, array $headers = []) + { + return $this->send('HEAD', $uri, $headers, null); + } + + /** + * Sends a TRACE request. + * + * @param string|UriInterface $uri + * @param array $headers + * + * @throws Exception + * + * @return ResponseInterface + */ + public function trace($uri, array $headers = []) + { + return $this->send('TRACE', $uri, $headers, null); + } + + /** + * Sends a POST request. + * + * @param string|UriInterface $uri + * @param array $headers + * @param string|StreamInterface|null $body + * + * @throws Exception + * + * @return ResponseInterface + */ + public function post($uri, array $headers = [], $body = null) + { + return $this->send('POST', $uri, $headers, $body); + } + + /** + * Sends a PUT request. + * + * @param string|UriInterface $uri + * @param array $headers + * @param string|StreamInterface|null $body + * + * @throws Exception + * + * @return ResponseInterface + */ + public function put($uri, array $headers = [], $body = null) + { + return $this->send('PUT', $uri, $headers, $body); + } + + /** + * Sends a PATCH request. + * + * @param string|UriInterface $uri + * @param array $headers + * @param string|StreamInterface|null $body + * + * @throws Exception + * + * @return ResponseInterface + */ + public function patch($uri, array $headers = [], $body = null) + { + return $this->send('PATCH', $uri, $headers, $body); + } + + /** + * Sends a DELETE request. + * + * @param string|UriInterface $uri + * @param array $headers + * @param string|StreamInterface|null $body + * + * @throws Exception + * + * @return ResponseInterface + */ + public function delete($uri, array $headers = [], $body = null) + { + return $this->send('DELETE', $uri, $headers, $body); + } + + /** + * Sends an OPTIONS request. + * + * @param string|UriInterface $uri + * @param array $headers + * @param string|StreamInterface|null $body + * + * @throws Exception + * + * @return ResponseInterface + */ + public function options($uri, array $headers = [], $body = null) + { + return $this->send('OPTIONS', $uri, $headers, $body); + } + + /** + * Sends a request with any HTTP method. + * + * @param string $method HTTP method to use + * @param string|UriInterface $uri + * @param array $headers + * @param string|StreamInterface|null $body + * + * @throws Exception + * + * @return ResponseInterface + */ + public function send($method, $uri, array $headers = [], $body = null) + { + return $this->sendRequest($this->requestFactory->createRequest( + $method, + $uri, + $headers, + $body + )); + } + + /** + * Forward to the underlying HttpClient. + * + * {@inheritdoc} + */ + public function sendRequest(RequestInterface $request) + { + return $this->httpClient->sendRequest($request); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin.php new file mode 100644 index 0000000..89a2a62 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin.php @@ -0,0 +1,32 @@ +<?php + +namespace Http\Client\Common; + +use Http\Promise\Promise; +use Psr\Http\Message\RequestInterface; + +/** + * A plugin is a middleware to transform the request and/or the response. + * + * The plugin can: + * - break the chain and return a response + * - dispatch the request to the next middleware + * - restart the request + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +interface Plugin +{ + /** + * Handle the request and return the response coming from the next callable. + * + * @see http://docs.php-http.org/en/latest/plugins/build-your-own.html + * + * @param RequestInterface $request + * @param callable $next Next middleware in the chain, the request is passed as the first argument + * @param callable $first First middleware in the chain, used to to restart a request + * + * @return Promise Resolves a PSR-7 Response or fails with an Http\Client\Exception (The same as HttpAsyncClient). + */ + public function handleRequest(RequestInterface $request, callable $next, callable $first); +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/AddHostPlugin.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/AddHostPlugin.php new file mode 100644 index 0000000..29ab8ae --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/AddHostPlugin.php @@ -0,0 +1,77 @@ +<?php + +namespace Http\Client\Common\Plugin; + +use Http\Client\Common\Plugin; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\UriInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; + +/** + * Add schema, host and port to a request. Can be set to overwrite the schema and host if desired. + * + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +final class AddHostPlugin implements Plugin +{ + /** + * @var UriInterface + */ + private $host; + + /** + * @var bool + */ + private $replace; + + /** + * @param UriInterface $host + * @param array $config { + * + * @var bool $replace True will replace all hosts, false will only add host when none is specified. + * } + */ + public function __construct(UriInterface $host, array $config = []) + { + if ('' === $host->getHost()) { + throw new \LogicException('Host can not be empty'); + } + + $this->host = $host; + + $resolver = new OptionsResolver(); + $this->configureOptions($resolver); + $options = $resolver->resolve($config); + + $this->replace = $options['replace']; + } + + /** + * {@inheritdoc} + */ + public function handleRequest(RequestInterface $request, callable $next, callable $first) + { + if ($this->replace || '' === $request->getUri()->getHost()) { + $uri = $request->getUri() + ->withHost($this->host->getHost()) + ->withScheme($this->host->getScheme()) + ->withPort($this->host->getPort()) + ; + + $request = $request->withUri($uri); + } + + return $next($request); + } + + /** + * @param OptionsResolver $resolver + */ + private function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults([ + 'replace' => false, + ]); + $resolver->setAllowedTypes('replace', 'bool'); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/AddPathPlugin.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/AddPathPlugin.php new file mode 100644 index 0000000..e24d61a --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/AddPathPlugin.php @@ -0,0 +1,48 @@ +<?php + +namespace Http\Client\Common\Plugin; + +use Http\Client\Common\Plugin; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\UriInterface; + +/** + * Prepend a base path to the request URI. Useful for base API URLs like http://domain.com/api. + * + * @author Sullivan Senechal <soullivaneuh@gmail.com> + */ +final class AddPathPlugin implements Plugin +{ + /** + * @var UriInterface + */ + private $uri; + + /** + * @param UriInterface $uri + */ + public function __construct(UriInterface $uri) + { + if ('' === $uri->getPath()) { + throw new \LogicException('URI path cannot be empty'); + } + + if ('/' === substr($uri->getPath(), -1)) { + throw new \LogicException('URI path cannot end with a slash.'); + } + + $this->uri = $uri; + } + + /** + * {@inheritdoc} + */ + public function handleRequest(RequestInterface $request, callable $next, callable $first) + { + $request = $request->withUri($request->getUri() + ->withPath($this->uri->getPath().$request->getUri()->getPath()) + ); + + return $next($request); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/AuthenticationPlugin.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/AuthenticationPlugin.php new file mode 100644 index 0000000..194712f --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/AuthenticationPlugin.php @@ -0,0 +1,38 @@ +<?php + +namespace Http\Client\Common\Plugin; + +use Http\Client\Common\Plugin; +use Http\Message\Authentication; +use Psr\Http\Message\RequestInterface; + +/** + * Send an authenticated request. + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +final class AuthenticationPlugin implements Plugin +{ + /** + * @var Authentication An authentication system + */ + private $authentication; + + /** + * @param Authentication $authentication + */ + public function __construct(Authentication $authentication) + { + $this->authentication = $authentication; + } + + /** + * {@inheritdoc} + */ + public function handleRequest(RequestInterface $request, callable $next, callable $first) + { + $request = $this->authentication->authenticate($request); + + return $next($request); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/BaseUriPlugin.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/BaseUriPlugin.php new file mode 100644 index 0000000..2c2a775 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/BaseUriPlugin.php @@ -0,0 +1,54 @@ +<?php + +namespace Http\Client\Common\Plugin; + +use Http\Client\Common\Plugin; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\UriInterface; + +/** + * Combines the AddHostPlugin and AddPathPlugin. + * + * @author Sullivan Senechal <soullivaneuh@gmail.com> + */ +final class BaseUriPlugin implements Plugin +{ + /** + * @var AddHostPlugin + */ + private $addHostPlugin; + + /** + * @var AddPathPlugin|null + */ + private $addPathPlugin = null; + + /** + * @param UriInterface $uri Has to contain a host name and cans have a path. + * @param array $hostConfig Config for AddHostPlugin. @see AddHostPlugin::configureOptions + */ + public function __construct(UriInterface $uri, array $hostConfig = []) + { + $this->addHostPlugin = new AddHostPlugin($uri, $hostConfig); + + if (rtrim($uri->getPath(), '/')) { + $this->addPathPlugin = new AddPathPlugin($uri); + } + } + + /** + * {@inheritdoc} + */ + public function handleRequest(RequestInterface $request, callable $next, callable $first) + { + $addHostNext = function (RequestInterface $request) use ($next, $first) { + return $this->addHostPlugin->handleRequest($request, $next, $first); + }; + + if ($this->addPathPlugin) { + return $this->addPathPlugin->handleRequest($request, $addHostNext, $first); + } + + return $addHostNext($request); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/ContentLengthPlugin.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/ContentLengthPlugin.php new file mode 100644 index 0000000..0f7aafa --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/ContentLengthPlugin.php @@ -0,0 +1,36 @@ +<?php + +namespace Http\Client\Common\Plugin; + +use Http\Client\Common\Plugin; +use Http\Message\Encoding\ChunkStream; +use Psr\Http\Message\RequestInterface; + +/** + * Allow to set the correct content length header on the request or to transfer it as a chunk if not possible. + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +final class ContentLengthPlugin implements Plugin +{ + /** + * {@inheritdoc} + */ + public function handleRequest(RequestInterface $request, callable $next, callable $first) + { + if (!$request->hasHeader('Content-Length')) { + $stream = $request->getBody(); + + // Cannot determine the size so we use a chunk stream + if (null === $stream->getSize()) { + $stream = new ChunkStream($stream); + $request = $request->withBody($stream); + $request = $request->withAddedHeader('Transfer-Encoding', 'chunked'); + } else { + $request = $request->withHeader('Content-Length', (string) $stream->getSize()); + } + } + + return $next($request); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/ContentTypePlugin.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/ContentTypePlugin.php new file mode 100644 index 0000000..8ef1d62 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/ContentTypePlugin.php @@ -0,0 +1,123 @@ +<?php + +namespace Http\Client\Common\Plugin; + +use Http\Client\Common\Plugin; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\StreamInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; + +/** + * Allow to set the correct content type header on the request automatically only if it is not set. + * + * @author Karim Pinchon <karim.pinchon@gmail.com> + */ +final class ContentTypePlugin implements Plugin +{ + /** + * Allow to disable the content type detection when stream is too large (as it can consume a lot of resource). + * + * @var bool + * + * true skip the content type detection + * false detect the content type (default value) + */ + protected $skipDetection; + + /** + * Determine the size stream limit for which the detection as to be skipped (default to 16Mb). + * + * @var int + */ + protected $sizeLimit; + + /** + * @param array $config { + * + * @var bool $skip_detection True skip detection if stream size is bigger than $size_limit. + * @var int $size_limit size stream limit for which the detection as to be skipped. + * } + */ + public function __construct(array $config = []) + { + $resolver = new OptionsResolver(); + $resolver->setDefaults([ + 'skip_detection' => false, + 'size_limit' => 16000000, + ]); + $resolver->setAllowedTypes('skip_detection', 'bool'); + $resolver->setAllowedTypes('size_limit', 'int'); + + $options = $resolver->resolve($config); + + $this->skipDetection = $options['skip_detection']; + $this->sizeLimit = $options['size_limit']; + } + + /** + * {@inheritdoc} + */ + public function handleRequest(RequestInterface $request, callable $next, callable $first) + { + if (!$request->hasHeader('Content-Type')) { + $stream = $request->getBody(); + $streamSize = $stream->getSize(); + + if (!$stream->isSeekable()) { + return $next($request); + } + + if (0 === $streamSize) { + return $next($request); + } + + if ($this->skipDetection && (null === $streamSize || $streamSize >= $this->sizeLimit)) { + return $next($request); + } + + if ($this->isJson($stream)) { + $request = $request->withHeader('Content-Type', 'application/json'); + + return $next($request); + } + + if ($this->isXml($stream)) { + $request = $request->withHeader('Content-Type', 'application/xml'); + + return $next($request); + } + } + + return $next($request); + } + + /** + * @param $stream StreamInterface + * + * @return bool + */ + private function isJson($stream) + { + $stream->rewind(); + + json_decode($stream->getContents()); + + return JSON_ERROR_NONE === json_last_error(); + } + + /** + * @param $stream StreamInterface + * + * @return \SimpleXMLElement|false + */ + private function isXml($stream) + { + $stream->rewind(); + + $previousValue = libxml_use_internal_errors(true); + $isXml = simplexml_load_string($stream->getContents()); + libxml_use_internal_errors($previousValue); + + return $isXml; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/CookiePlugin.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/CookiePlugin.php new file mode 100644 index 0000000..59ee90d --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/CookiePlugin.php @@ -0,0 +1,180 @@ +<?php + +namespace Http\Client\Common\Plugin; + +use Http\Client\Common\Plugin; +use Http\Client\Exception\TransferException; +use Http\Message\Cookie; +use Http\Message\CookieJar; +use Http\Message\CookieUtil; +use Http\Message\Exception\UnexpectedValueException; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; + +/** + * Handle request cookies. + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +final class CookiePlugin implements Plugin +{ + /** + * Cookie storage. + * + * @var CookieJar + */ + private $cookieJar; + + /** + * @param CookieJar $cookieJar + */ + public function __construct(CookieJar $cookieJar) + { + $this->cookieJar = $cookieJar; + } + + /** + * {@inheritdoc} + */ + public function handleRequest(RequestInterface $request, callable $next, callable $first) + { + foreach ($this->cookieJar->getCookies() as $cookie) { + if ($cookie->isExpired()) { + continue; + } + + if (!$cookie->matchDomain($request->getUri()->getHost())) { + continue; + } + + if (!$cookie->matchPath($request->getUri()->getPath())) { + continue; + } + + if ($cookie->isSecure() && ('https' !== $request->getUri()->getScheme())) { + continue; + } + + $request = $request->withAddedHeader('Cookie', sprintf('%s=%s', $cookie->getName(), $cookie->getValue())); + } + + return $next($request)->then(function (ResponseInterface $response) use ($request) { + if ($response->hasHeader('Set-Cookie')) { + $setCookies = $response->getHeader('Set-Cookie'); + + foreach ($setCookies as $setCookie) { + $cookie = $this->createCookie($request, $setCookie); + + // Cookie invalid do not use it + if (null === $cookie) { + continue; + } + + // Restrict setting cookie from another domain + if (!preg_match("/\.{$cookie->getDomain()}$/", '.'.$request->getUri()->getHost())) { + continue; + } + + $this->cookieJar->addCookie($cookie); + } + } + + return $response; + }); + } + + /** + * Creates a cookie from a string. + * + * @param RequestInterface $request + * @param $setCookie + * + * @return Cookie|null + * + * @throws TransferException + */ + private function createCookie(RequestInterface $request, $setCookie) + { + $parts = array_map('trim', explode(';', $setCookie)); + + if (empty($parts) || !strpos($parts[0], '=')) { + return; + } + + list($name, $cookieValue) = $this->createValueKey(array_shift($parts)); + + $maxAge = null; + $expires = null; + $domain = $request->getUri()->getHost(); + $path = $request->getUri()->getPath(); + $secure = false; + $httpOnly = false; + + // Add the cookie pieces into the parsed data array + foreach ($parts as $part) { + list($key, $value) = $this->createValueKey($part); + + switch (strtolower($key)) { + case 'expires': + try { + $expires = CookieUtil::parseDate($value); + } catch (UnexpectedValueException $e) { + throw new TransferException( + sprintf( + 'Cookie header `%s` expires value `%s` could not be converted to date', + $name, + $value + ), + null, + $e + ); + } + + break; + + case 'max-age': + $maxAge = (int) $value; + + break; + + case 'domain': + $domain = $value; + + break; + + case 'path': + $path = $value; + + break; + + case 'secure': + $secure = true; + + break; + + case 'httponly': + $httpOnly = true; + + break; + } + } + + return new Cookie($name, $cookieValue, $maxAge, $domain, $path, $secure, $httpOnly, $expires); + } + + /** + * Separates key/value pair from cookie. + * + * @param $part + * + * @return array + */ + private function createValueKey($part) + { + $parts = explode('=', $part, 2); + $key = trim($parts[0]); + $value = isset($parts[1]) ? trim($parts[1]) : true; + + return [$key, $value]; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/DecoderPlugin.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/DecoderPlugin.php new file mode 100644 index 0000000..b661b61 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/DecoderPlugin.php @@ -0,0 +1,140 @@ +<?php + +namespace Http\Client\Common\Plugin; + +use Http\Client\Common\Plugin; +use Http\Message\Encoding; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\StreamInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; + +/** + * Allow to decode response body with a chunk, deflate, compress or gzip encoding. + * + * If zlib is not installed, only chunked encoding can be handled. + * + * If Content-Encoding is not disabled, the plugin will add an Accept-Encoding header for the encoding methods it supports. + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +final class DecoderPlugin implements Plugin +{ + /** + * @var bool Whether this plugin decode stream with value in the Content-Encoding header (default to true). + * + * If set to false only the Transfer-Encoding header will be used + */ + private $useContentEncoding; + + /** + * @param array $config { + * + * @var bool $use_content_encoding Whether this plugin should look at the Content-Encoding header first or only at the Transfer-Encoding (defaults to true). + * } + */ + public function __construct(array $config = []) + { + $resolver = new OptionsResolver(); + $resolver->setDefaults([ + 'use_content_encoding' => true, + ]); + $resolver->setAllowedTypes('use_content_encoding', 'bool'); + $options = $resolver->resolve($config); + + $this->useContentEncoding = $options['use_content_encoding']; + } + + /** + * {@inheritdoc} + */ + public function handleRequest(RequestInterface $request, callable $next, callable $first) + { + $encodings = extension_loaded('zlib') ? ['gzip', 'deflate'] : ['identity']; + + if ($this->useContentEncoding) { + $request = $request->withHeader('Accept-Encoding', $encodings); + } + $encodings[] = 'chunked'; + $request = $request->withHeader('TE', $encodings); + + return $next($request)->then(function (ResponseInterface $response) { + return $this->decodeResponse($response); + }); + } + + /** + * Decode a response body given its Transfer-Encoding or Content-Encoding value. + * + * @param ResponseInterface $response Response to decode + * + * @return ResponseInterface New response decoded + */ + private function decodeResponse(ResponseInterface $response) + { + $response = $this->decodeOnEncodingHeader('Transfer-Encoding', $response); + + if ($this->useContentEncoding) { + $response = $this->decodeOnEncodingHeader('Content-Encoding', $response); + } + + return $response; + } + + /** + * Decode a response on a specific header (content encoding or transfer encoding mainly). + * + * @param string $headerName Name of the header + * @param ResponseInterface $response Response + * + * @return ResponseInterface A new instance of the response decoded + */ + private function decodeOnEncodingHeader($headerName, ResponseInterface $response) + { + if ($response->hasHeader($headerName)) { + $encodings = $response->getHeader($headerName); + $newEncodings = []; + + while ($encoding = array_pop($encodings)) { + $stream = $this->decorateStream($encoding, $response->getBody()); + + if (false === $stream) { + array_unshift($newEncodings, $encoding); + + continue; + } + + $response = $response->withBody($stream); + } + + $response = $response->withHeader($headerName, $newEncodings); + } + + return $response; + } + + /** + * Decorate a stream given an encoding. + * + * @param string $encoding + * @param StreamInterface $stream + * + * @return StreamInterface|false A new stream interface or false if encoding is not supported + */ + private function decorateStream($encoding, StreamInterface $stream) + { + if ('chunked' === strtolower($encoding)) { + return new Encoding\DechunkStream($stream); + } + + if ('deflate' === strtolower($encoding)) { + return new Encoding\DecompressStream($stream); + } + + if ('gzip' === strtolower($encoding)) { + return new Encoding\GzipDecodeStream($stream); + } + + return false; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/ErrorPlugin.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/ErrorPlugin.php new file mode 100644 index 0000000..f09d3b1 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/ErrorPlugin.php @@ -0,0 +1,55 @@ +<?php + +namespace Http\Client\Common\Plugin; + +use Http\Client\Common\Exception\ClientErrorException; +use Http\Client\Common\Exception\ServerErrorException; +use Http\Client\Common\Plugin; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; + +/** + * Throw exception when the response of a request is not acceptable. + * + * Status codes 400-499 lead to a ClientErrorException, status 500-599 to a ServerErrorException. + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +final class ErrorPlugin implements Plugin +{ + /** + * {@inheritdoc} + */ + public function handleRequest(RequestInterface $request, callable $next, callable $first) + { + $promise = $next($request); + + return $promise->then(function (ResponseInterface $response) use ($request) { + return $this->transformResponseToException($request, $response); + }); + } + + /** + * Transform response to an error if possible. + * + * @param RequestInterface $request Request of the call + * @param ResponseInterface $response Response of the call + * + * @throws ClientErrorException If response status code is a 4xx + * @throws ServerErrorException If response status code is a 5xx + * + * @return ResponseInterface If status code is not in 4xx or 5xx return response + */ + protected function transformResponseToException(RequestInterface $request, ResponseInterface $response) + { + if ($response->getStatusCode() >= 400 && $response->getStatusCode() < 500) { + throw new ClientErrorException($response->getReasonPhrase(), $request, $response); + } + + if ($response->getStatusCode() >= 500 && $response->getStatusCode() < 600) { + throw new ServerErrorException($response->getReasonPhrase(), $request, $response); + } + + return $response; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/HeaderAppendPlugin.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/HeaderAppendPlugin.php new file mode 100644 index 0000000..26fd813 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/HeaderAppendPlugin.php @@ -0,0 +1,45 @@ +<?php + +namespace Http\Client\Common\Plugin; + +use Http\Client\Common\Plugin; +use Psr\Http\Message\RequestInterface; + +/** + * Append headers to the request. + * + * If the header already exists the value will be appended to the current value. + * + * This only makes sense for headers that can have multiple values like 'Forwarded' + * + * @see https://en.wikipedia.org/wiki/List_of_HTTP_header_fields + * + * @author Soufiane Ghzal <sghzal@gmail.com> + */ +final class HeaderAppendPlugin implements Plugin +{ + /** + * @var array + */ + private $headers = []; + + /** + * @param array $headers Hashmap of header name to header value + */ + public function __construct(array $headers) + { + $this->headers = $headers; + } + + /** + * {@inheritdoc} + */ + public function handleRequest(RequestInterface $request, callable $next, callable $first) + { + foreach ($this->headers as $header => $headerValue) { + $request = $request->withAddedHeader($header, $headerValue); + } + + return $next($request); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/HeaderDefaultsPlugin.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/HeaderDefaultsPlugin.php new file mode 100644 index 0000000..6dfc111 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/HeaderDefaultsPlugin.php @@ -0,0 +1,43 @@ +<?php + +namespace Http\Client\Common\Plugin; + +use Http\Client\Common\Plugin; +use Psr\Http\Message\RequestInterface; + +/** + * Set header to default value if it does not exist. + * + * If a given header already exists the value wont be replaced and the request wont be changed. + * + * @author Soufiane Ghzal <sghzal@gmail.com> + */ +final class HeaderDefaultsPlugin implements Plugin +{ + /** + * @var array + */ + private $headers = []; + + /** + * @param array $headers Hashmap of header name to header value + */ + public function __construct(array $headers) + { + $this->headers = $headers; + } + + /** + * {@inheritdoc} + */ + public function handleRequest(RequestInterface $request, callable $next, callable $first) + { + foreach ($this->headers as $header => $headerValue) { + if (!$request->hasHeader($header)) { + $request = $request->withHeader($header, $headerValue); + } + } + + return $next($request); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/HeaderRemovePlugin.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/HeaderRemovePlugin.php new file mode 100644 index 0000000..fc9c19d --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/HeaderRemovePlugin.php @@ -0,0 +1,41 @@ +<?php + +namespace Http\Client\Common\Plugin; + +use Http\Client\Common\Plugin; +use Psr\Http\Message\RequestInterface; + +/** + * Removes headers from the request. + * + * @author Soufiane Ghzal <sghzal@gmail.com> + */ +final class HeaderRemovePlugin implements Plugin +{ + /** + * @var array + */ + private $headers = []; + + /** + * @param array $headers List of header names to remove from the request + */ + public function __construct(array $headers) + { + $this->headers = $headers; + } + + /** + * {@inheritdoc} + */ + public function handleRequest(RequestInterface $request, callable $next, callable $first) + { + foreach ($this->headers as $header) { + if ($request->hasHeader($header)) { + $request = $request->withoutHeader($header); + } + } + + return $next($request); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/HeaderSetPlugin.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/HeaderSetPlugin.php new file mode 100644 index 0000000..75f11d4 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/HeaderSetPlugin.php @@ -0,0 +1,41 @@ +<?php + +namespace Http\Client\Common\Plugin; + +use Http\Client\Common\Plugin; +use Psr\Http\Message\RequestInterface; + +/** + * Set headers on the request. + * + * If the header does not exist it wil be set, if the header already exists it will be replaced. + * + * @author Soufiane Ghzal <sghzal@gmail.com> + */ +final class HeaderSetPlugin implements Plugin +{ + /** + * @var array + */ + private $headers = []; + + /** + * @param array $headers Hashmap of header name to header value + */ + public function __construct(array $headers) + { + $this->headers = $headers; + } + + /** + * {@inheritdoc} + */ + public function handleRequest(RequestInterface $request, callable $next, callable $first) + { + foreach ($this->headers as $header => $headerValue) { + $request = $request->withHeader($header, $headerValue); + } + + return $next($request); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/HistoryPlugin.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/HistoryPlugin.php new file mode 100644 index 0000000..5abddbd --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/HistoryPlugin.php @@ -0,0 +1,49 @@ +<?php + +namespace Http\Client\Common\Plugin; + +use Http\Client\Common\Plugin; +use Http\Client\Exception; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; + +/** + * Record HTTP calls. + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +final class HistoryPlugin implements Plugin +{ + /** + * Journal use to store request / responses / exception. + * + * @var Journal + */ + private $journal; + + /** + * @param Journal $journal + */ + public function __construct(Journal $journal) + { + $this->journal = $journal; + } + + /** + * {@inheritdoc} + */ + public function handleRequest(RequestInterface $request, callable $next, callable $first) + { + $journal = $this->journal; + + return $next($request)->then(function (ResponseInterface $response) use ($request, $journal) { + $journal->addSuccess($request, $response); + + return $response; + }, function (Exception $exception) use ($request, $journal) { + $journal->addFailure($request, $exception); + + throw $exception; + }); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/Journal.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/Journal.php new file mode 100644 index 0000000..15f3095 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/Journal.php @@ -0,0 +1,31 @@ +<?php + +namespace Http\Client\Common\Plugin; + +use Http\Client\Exception; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; + +/** + * Records history of HTTP calls. + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +interface Journal +{ + /** + * Record a successful call. + * + * @param RequestInterface $request Request use to make the call + * @param ResponseInterface $response Response returned by the call + */ + public function addSuccess(RequestInterface $request, ResponseInterface $response); + + /** + * Record a failed call. + * + * @param RequestInterface $request Request use to make the call + * @param Exception $exception Exception returned by the call + */ + public function addFailure(RequestInterface $request, Exception $exception); +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/QueryDefaultsPlugin.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/QueryDefaultsPlugin.php new file mode 100644 index 0000000..6c1e32c --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/QueryDefaultsPlugin.php @@ -0,0 +1,54 @@ +<?php + +namespace Http\Client\Common\Plugin; + +use Http\Client\Common\Plugin; +use Psr\Http\Message\RequestInterface; + +/** + * Set query to default value if it does not exist. + * + * If a given query parameter already exists the value wont be replaced and the request wont be changed. + * + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +final class QueryDefaultsPlugin implements Plugin +{ + /** + * @var array + */ + private $queryParams = []; + + /** + * @param array $queryParams Hashmap of query name to query value. Names and values must not be url encoded as + * this plugin will encode them + */ + public function __construct(array $queryParams) + { + $this->queryParams = $queryParams; + } + + /** + * {@inheritdoc} + */ + public function handleRequest(RequestInterface $request, callable $next, callable $first) + { + foreach ($this->queryParams as $name => $value) { + $uri = $request->getUri(); + $array = []; + parse_str($uri->getQuery(), $array); + + // If query value is not found + if (!isset($array[$name])) { + $array[$name] = $value; + + // Create a new request with the new URI with the added query param + $request = $request->withUri( + $uri->withQuery(http_build_query($array)) + ); + } + } + + return $next($request); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/RedirectPlugin.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/RedirectPlugin.php new file mode 100644 index 0000000..d2f442e --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/RedirectPlugin.php @@ -0,0 +1,270 @@ +<?php + +namespace Http\Client\Common\Plugin; + +use Http\Client\Common\Exception\CircularRedirectionException; +use Http\Client\Common\Exception\MultipleRedirectionException; +use Http\Client\Common\Plugin; +use Http\Client\Exception\HttpException; +use Psr\Http\Message\MessageInterface; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\UriInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; + +/** + * Follow redirections. + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +class RedirectPlugin implements Plugin +{ + /** + * Rule on how to redirect, change method for the new request. + * + * @var array + */ + protected $redirectCodes = [ + 300 => [ + 'switch' => [ + 'unless' => ['GET', 'HEAD'], + 'to' => 'GET', + ], + 'multiple' => true, + 'permanent' => false, + ], + 301 => [ + 'switch' => [ + 'unless' => ['GET', 'HEAD'], + 'to' => 'GET', + ], + 'multiple' => false, + 'permanent' => true, + ], + 302 => [ + 'switch' => [ + 'unless' => ['GET', 'HEAD'], + 'to' => 'GET', + ], + 'multiple' => false, + 'permanent' => false, + ], + 303 => [ + 'switch' => [ + 'unless' => ['GET', 'HEAD'], + 'to' => 'GET', + ], + 'multiple' => false, + 'permanent' => false, + ], + 307 => [ + 'switch' => false, + 'multiple' => false, + 'permanent' => false, + ], + 308 => [ + 'switch' => false, + 'multiple' => false, + 'permanent' => true, + ], + ]; + + /** + * Determine how header should be preserved from old request. + * + * @var bool|array + * + * true will keep all previous headers (default value) + * false will ditch all previous headers + * string[] will keep only headers with the specified names + */ + protected $preserveHeader; + + /** + * Store all previous redirect from 301 / 308 status code. + * + * @var array + */ + protected $redirectStorage = []; + + /** + * Whether the location header must be directly used for a multiple redirection status code (300). + * + * @var bool + */ + protected $useDefaultForMultiple; + + /** + * @var array + */ + protected $circularDetection = []; + + /** + * @param array $config { + * + * @var bool|string[] $preserve_header True keeps all headers, false remove all of them, an array is interpreted as a list of header names to keep + * @var bool $use_default_for_multiple Whether the location header must be directly used for a multiple redirection status code (300). + * } + */ + public function __construct(array $config = []) + { + $resolver = new OptionsResolver(); + $resolver->setDefaults([ + 'preserve_header' => true, + 'use_default_for_multiple' => true, + ]); + $resolver->setAllowedTypes('preserve_header', ['bool', 'array']); + $resolver->setAllowedTypes('use_default_for_multiple', 'bool'); + $resolver->setNormalizer('preserve_header', function (OptionsResolver $resolver, $value) { + if (is_bool($value) && false === $value) { + return []; + } + + return $value; + }); + $options = $resolver->resolve($config); + + $this->preserveHeader = $options['preserve_header']; + $this->useDefaultForMultiple = $options['use_default_for_multiple']; + } + + /** + * {@inheritdoc} + */ + public function handleRequest(RequestInterface $request, callable $next, callable $first) + { + // Check in storage + if (array_key_exists((string) $request->getUri(), $this->redirectStorage)) { + $uri = $this->redirectStorage[(string) $request->getUri()]['uri']; + $statusCode = $this->redirectStorage[(string) $request->getUri()]['status']; + $redirectRequest = $this->buildRedirectRequest($request, $uri, $statusCode); + + return $first($redirectRequest); + } + + return $next($request)->then(function (ResponseInterface $response) use ($request, $first) { + $statusCode = $response->getStatusCode(); + + if (!array_key_exists($statusCode, $this->redirectCodes)) { + return $response; + } + + $uri = $this->createUri($response, $request); + $redirectRequest = $this->buildRedirectRequest($request, $uri, $statusCode); + $chainIdentifier = spl_object_hash((object) $first); + + if (!array_key_exists($chainIdentifier, $this->circularDetection)) { + $this->circularDetection[$chainIdentifier] = []; + } + + $this->circularDetection[$chainIdentifier][] = (string) $request->getUri(); + + if (in_array((string) $redirectRequest->getUri(), $this->circularDetection[$chainIdentifier])) { + throw new CircularRedirectionException('Circular redirection detected', $request, $response); + } + + if ($this->redirectCodes[$statusCode]['permanent']) { + $this->redirectStorage[(string) $request->getUri()] = [ + 'uri' => $uri, + 'status' => $statusCode, + ]; + } + + // Call redirect request in synchrone + $redirectPromise = $first($redirectRequest); + + return $redirectPromise->wait(); + }); + } + + /** + * Builds the redirect request. + * + * @param RequestInterface $request Original request + * @param UriInterface $uri New uri + * @param int $statusCode Status code from the redirect response + * + * @return MessageInterface|RequestInterface + */ + protected function buildRedirectRequest(RequestInterface $request, UriInterface $uri, $statusCode) + { + $request = $request->withUri($uri); + + if (false !== $this->redirectCodes[$statusCode]['switch'] && !in_array($request->getMethod(), $this->redirectCodes[$statusCode]['switch']['unless'])) { + $request = $request->withMethod($this->redirectCodes[$statusCode]['switch']['to']); + } + + if (is_array($this->preserveHeader)) { + $headers = array_keys($request->getHeaders()); + + foreach ($headers as $name) { + if (!in_array($name, $this->preserveHeader)) { + $request = $request->withoutHeader($name); + } + } + } + + return $request; + } + + /** + * Creates a new Uri from the old request and the location header. + * + * @param ResponseInterface $response The redirect response + * @param RequestInterface $request The original request + * + * @throws HttpException If location header is not usable (missing or incorrect) + * @throws MultipleRedirectionException If a 300 status code is received and default location cannot be resolved (doesn't use the location header or not present) + * + * @return UriInterface + */ + private function createUri(ResponseInterface $response, RequestInterface $request) + { + if ($this->redirectCodes[$response->getStatusCode()]['multiple'] && (!$this->useDefaultForMultiple || !$response->hasHeader('Location'))) { + throw new MultipleRedirectionException('Cannot choose a redirection', $request, $response); + } + + if (!$response->hasHeader('Location')) { + throw new HttpException('Redirect status code, but no location header present in the response', $request, $response); + } + + $location = $response->getHeaderLine('Location'); + $parsedLocation = parse_url($location); + + if (false === $parsedLocation) { + throw new HttpException(sprintf('Location %s could not be parsed', $location), $request, $response); + } + + $uri = $request->getUri(); + + if (array_key_exists('scheme', $parsedLocation)) { + $uri = $uri->withScheme($parsedLocation['scheme']); + } + + if (array_key_exists('host', $parsedLocation)) { + $uri = $uri->withHost($parsedLocation['host']); + } + + if (array_key_exists('port', $parsedLocation)) { + $uri = $uri->withPort($parsedLocation['port']); + } + + if (array_key_exists('path', $parsedLocation)) { + $uri = $uri->withPath($parsedLocation['path']); + } + + if (array_key_exists('query', $parsedLocation)) { + $uri = $uri->withQuery($parsedLocation['query']); + } else { + $uri = $uri->withQuery(''); + } + + if (array_key_exists('fragment', $parsedLocation)) { + $uri = $uri->withFragment($parsedLocation['fragment']); + } else { + $uri = $uri->withFragment(''); + } + + return $uri; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/RequestMatcherPlugin.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/RequestMatcherPlugin.php new file mode 100644 index 0000000..5f72b02 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/RequestMatcherPlugin.php @@ -0,0 +1,47 @@ +<?php + +namespace Http\Client\Common\Plugin; + +use Http\Client\Common\Plugin; +use Http\Message\RequestMatcher; +use Psr\Http\Message\RequestInterface; + +/** + * Apply a delegated plugin based on a request match. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +final class RequestMatcherPlugin implements Plugin +{ + /** + * @var RequestMatcher + */ + private $requestMatcher; + + /** + * @var Plugin + */ + private $delegatedPlugin; + + /** + * @param RequestMatcher $requestMatcher + * @param Plugin $delegatedPlugin + */ + public function __construct(RequestMatcher $requestMatcher, Plugin $delegatedPlugin) + { + $this->requestMatcher = $requestMatcher; + $this->delegatedPlugin = $delegatedPlugin; + } + + /** + * {@inheritdoc} + */ + public function handleRequest(RequestInterface $request, callable $next, callable $first) + { + if ($this->requestMatcher->matches($request)) { + return $this->delegatedPlugin->handleRequest($request, $next, $first); + } + + return $next($request); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/RetryPlugin.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/RetryPlugin.php new file mode 100644 index 0000000..8446246 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/Plugin/RetryPlugin.php @@ -0,0 +1,122 @@ +<?php + +namespace Http\Client\Common\Plugin; + +use Http\Client\Common\Plugin; +use Http\Client\Exception; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; + +/** + * Retry the request if an exception is thrown. + * + * By default will retry only one time. + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +final class RetryPlugin implements Plugin +{ + /** + * Number of retry before sending an exception. + * + * @var int + */ + private $retry; + + /** + * @var callable + */ + private $delay; + + /** + * @var callable + */ + private $decider; + + /** + * Store the retry counter for each request. + * + * @var array + */ + private $retryStorage = []; + + /** + * @param array $config { + * + * @var int $retries Number of retries to attempt if an exception occurs before letting the exception bubble up. + * @var callable $decider A callback that gets a request and an exception to decide after a failure whether the request should be retried. + * @var callable $delay A callback that gets a request, an exception and the number of retries and returns how many microseconds we should wait before trying again. + * } + */ + public function __construct(array $config = []) + { + $resolver = new OptionsResolver(); + $resolver->setDefaults([ + 'retries' => 1, + 'decider' => function (RequestInterface $request, Exception $e) { + return true; + }, + 'delay' => __CLASS__.'::defaultDelay', + ]); + $resolver->setAllowedTypes('retries', 'int'); + $resolver->setAllowedTypes('decider', 'callable'); + $resolver->setAllowedTypes('delay', 'callable'); + $options = $resolver->resolve($config); + + $this->retry = $options['retries']; + $this->decider = $options['decider']; + $this->delay = $options['delay']; + } + + /** + * {@inheritdoc} + */ + public function handleRequest(RequestInterface $request, callable $next, callable $first) + { + $chainIdentifier = spl_object_hash((object) $first); + + return $next($request)->then(function (ResponseInterface $response) use ($request, $chainIdentifier) { + if (array_key_exists($chainIdentifier, $this->retryStorage)) { + unset($this->retryStorage[$chainIdentifier]); + } + + return $response; + }, function (Exception $exception) use ($request, $next, $first, $chainIdentifier) { + if (!array_key_exists($chainIdentifier, $this->retryStorage)) { + $this->retryStorage[$chainIdentifier] = 0; + } + + if ($this->retryStorage[$chainIdentifier] >= $this->retry) { + unset($this->retryStorage[$chainIdentifier]); + + throw $exception; + } + + if (!call_user_func($this->decider, $request, $exception)) { + throw $exception; + } + + $time = call_user_func($this->delay, $request, $exception, $this->retryStorage[$chainIdentifier]); + usleep($time); + + // Retry in synchrone + ++$this->retryStorage[$chainIdentifier]; + $promise = $this->handleRequest($request, $next, $first); + + return $promise->wait(); + }); + } + + /** + * @param RequestInterface $request + * @param Exception $e + * @param int $retries The number of retries we made before. First time this get called it will be 0. + * + * @return int + */ + public static function defaultDelay(RequestInterface $request, Exception $e, $retries) + { + return pow(2, $retries) * 500000; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/PluginClient.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/PluginClient.php new file mode 100644 index 0000000..93aea8f --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/PluginClient.php @@ -0,0 +1,179 @@ +<?php + +namespace Http\Client\Common; + +use Http\Client\Common\Exception\LoopException; +use Http\Client\Exception as HttplugException; +use Http\Client\HttpAsyncClient; +use Http\Client\HttpClient; +use Http\Client\Promise\HttpFulfilledPromise; +use Http\Client\Promise\HttpRejectedPromise; +use Psr\Http\Message\RequestInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; + +/** + * The client managing plugins and providing a decorator around HTTP Clients. + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +final class PluginClient implements HttpClient, HttpAsyncClient +{ + /** + * An HTTP async client. + * + * @var HttpAsyncClient + */ + private $client; + + /** + * The plugin chain. + * + * @var Plugin[] + */ + private $plugins; + + /** + * A list of options. + * + * @var array + */ + private $options; + + /** + * @param HttpClient|HttpAsyncClient $client + * @param Plugin[] $plugins + * @param array $options { + * + * @var int $max_restarts + * @var Plugin[] $debug_plugins an array of plugins that are injected between each normal plugin + * } + * + * @throws \RuntimeException if client is not an instance of HttpClient or HttpAsyncClient + */ + public function __construct($client, array $plugins = [], array $options = []) + { + if ($client instanceof HttpAsyncClient) { + $this->client = $client; + } elseif ($client instanceof HttpClient) { + $this->client = new EmulatedHttpAsyncClient($client); + } else { + throw new \RuntimeException('Client must be an instance of Http\\Client\\HttpClient or Http\\Client\\HttpAsyncClient'); + } + + $this->plugins = $plugins; + $this->options = $this->configure($options); + } + + /** + * {@inheritdoc} + */ + public function sendRequest(RequestInterface $request) + { + // If we don't have an http client, use the async call + if (!($this->client instanceof HttpClient)) { + return $this->sendAsyncRequest($request)->wait(); + } + + // Else we want to use the synchronous call of the underlying client, and not the async one in the case + // we have both an async and sync call + $pluginChain = $this->createPluginChain($this->plugins, function (RequestInterface $request) { + try { + return new HttpFulfilledPromise($this->client->sendRequest($request)); + } catch (HttplugException $exception) { + return new HttpRejectedPromise($exception); + } + }); + + return $pluginChain($request)->wait(); + } + + /** + * {@inheritdoc} + */ + public function sendAsyncRequest(RequestInterface $request) + { + $pluginChain = $this->createPluginChain($this->plugins, function (RequestInterface $request) { + return $this->client->sendAsyncRequest($request); + }); + + return $pluginChain($request); + } + + /** + * Configure the plugin client. + * + * @param array $options + * + * @return array + */ + private function configure(array $options = []) + { + if (isset($options['debug_plugins'])) { + @trigger_error('The "debug_plugins" option is deprecated since 1.5 and will be removed in 2.0.', E_USER_DEPRECATED); + } + + $resolver = new OptionsResolver(); + $resolver->setDefaults([ + 'max_restarts' => 10, + 'debug_plugins' => [], + ]); + + $resolver + ->setAllowedTypes('debug_plugins', 'array') + ->setAllowedValues('debug_plugins', function (array $plugins) { + foreach ($plugins as $plugin) { + // Make sure each object passed with the `debug_plugins` is an instance of Plugin. + if (!$plugin instanceof Plugin) { + return false; + } + } + + return true; + }); + + return $resolver->resolve($options); + } + + /** + * Create the plugin chain. + * + * @param Plugin[] $pluginList A list of plugins + * @param callable $clientCallable Callable making the HTTP call + * + * @return callable + */ + private function createPluginChain($pluginList, callable $clientCallable) + { + $firstCallable = $lastCallable = $clientCallable; + + /* + * Inject debug plugins between each plugin. + */ + $pluginListWithDebug = $this->options['debug_plugins']; + foreach ($pluginList as $plugin) { + $pluginListWithDebug[] = $plugin; + $pluginListWithDebug = array_merge($pluginListWithDebug, $this->options['debug_plugins']); + } + + while ($plugin = array_pop($pluginListWithDebug)) { + $lastCallable = function (RequestInterface $request) use ($plugin, $lastCallable, &$firstCallable) { + return $plugin->handleRequest($request, $lastCallable, $firstCallable); + }; + + $firstCallable = $lastCallable; + } + + $firstCalls = 0; + $firstCallable = function (RequestInterface $request) use ($lastCallable, &$firstCalls) { + if ($firstCalls > $this->options['max_restarts']) { + throw new LoopException('Too many restarts in plugin client', $request); + } + + ++$firstCalls; + + return $lastCallable($request); + }; + + return $firstCallable; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/PluginClientFactory.php b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/PluginClientFactory.php new file mode 100644 index 0000000..bd4c08f --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/client-common/src/PluginClientFactory.php @@ -0,0 +1,62 @@ +<?php + +namespace Http\Client\Common; + +use Http\Client\HttpAsyncClient; +use Http\Client\HttpClient; + +/** + * Factory to create PluginClient instances. Using this factory instead of calling PluginClient constructor will enable + * the Symfony profiling without any configuration. + * + * @author Fabien Bourigault <bourigaultfabien@gmail.com> + */ +final class PluginClientFactory +{ + /** + * @var callable + */ + private static $factory; + + /** + * Set the factory to use. + * The callable to provide must have the same arguments and return type as PluginClientFactory::createClient. + * This is used by the HTTPlugBundle to provide a better Symfony integration. + * Unlike the createClient method, this one is static to allow zero configuration profiling by hooking into early + * application execution. + * + * @internal + * + * @param callable $factory + */ + public static function setFactory(callable $factory) + { + static::$factory = $factory; + } + + /** + * @param HttpClient|HttpAsyncClient $client + * @param Plugin[] $plugins + * @param array $options { + * + * @var string $client_name to give client a name which may be used when displaying client information like in + * the HTTPlugBundle profiler. + * } + * + * @see PluginClient constructor for PluginClient specific $options. + * + * @return PluginClient + */ + public function createClient($client, array $plugins = [], array $options = []) + { + if (static::$factory) { + $factory = static::$factory; + + return $factory($client, $plugins, $options); + } + + unset($options['client_name']); + + return new PluginClient($client, $plugins, $options); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/.php_cs b/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/.php_cs new file mode 100644 index 0000000..febeee5 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/.php_cs @@ -0,0 +1,9 @@ +<?php + +return Symfony\CS\Config\Config::create() + ->level(Symfony\CS\FixerInterface::PSR2_LEVEL) + ->fixers([]) + ->finder( + Symfony\CS\Finder\DefaultFinder::create()->in(__DIR__ . '/src') + ) +; diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/.styleci.yml b/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/.styleci.yml new file mode 100644 index 0000000..4d43c93 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/.styleci.yml @@ -0,0 +1,4 @@ +preset: psr2 +finder: + path: + - "src" diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/CHANGELOG.md b/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/CHANGELOG.md new file mode 100644 index 0000000..a3f52d1 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/CHANGELOG.md @@ -0,0 +1,163 @@ +# Change Log + +## 1.7 - 2017-02-09 + +### Changed + +- #30: Make sure we rewind streams + +## 1.6.2 - 2017-01-02 + +### Fixed + +- #29: Request not using CURLOPT_POSTFIELDS have content-length set to + +### Changed + +- Use binary mode to create response body stream. + + +## 1.6.1 - 2016-11-11 + +### Fixed + +- #27: ErrorPlugin and sendAsyncRequest() incompatibility + + +## 1.6 - 2016-09-12 + +### Changed + +- `Client::sendRequest` now throws `Http\Client\Exception\NetworkException` on network errors. +- `\UnexpectedValueException` replaced with `Http\Client\Exception\RequestException` in + `Client::sendRequest` and `Client::sendAsyncRequest` + + +## 1.5.1 - 2016-08-29 + +### Fixed + +- #26: Combining CurlClient with StopwatchPlugin causes Promise onRejected handler to never be + invoked. + + +## 1.5 - 2016-08-03 + +### Changed + +- Request body can be send with any method except GET, HEAD and TRACE. +- #25: Make discovery a hard dependency. + + +## 1.4.2 - 2016-06-14 + +### Added + +- #23: "php-http/async-client-implementation" added to "provide" section. + + +## 1.4.1 - 2016-05-30 + +### Fixed + +- #22: Cannot create the client using `HttpClientDiscovery`. + + +## 1.4 - 2016-03-30 + +### Changed + +- #20: Minimize memory usage when reading large response body. + + +## 1.3 - 2016-03-14 + +### Fixed + +- #18: Invalid "Expect" header. + +### Removed + +- #13: Remove HeaderParser. + + +## 1.2 - 2016-03-09 + +### Added + +- #16: Make sure discovery can find the curl client + +### Fixed + +- #15: "Out of memory" sending large files. + + +## 1.1.0 - 2016-01-29 + +### Changed + +- Switch to php-http/message 1.0. + + +## 1.0.0 - 2016-01-28 + +First stable release. + + +## 0.7.0 - 2016-01-26 + +### Changed + +- Migrate from `php-http/discovery` and `php-http/utils` to `php-http/message`. + +## 0.6.0 - 2016-01-12 + +### Changed + +- Root namespace changed from `Http\Curl` to `Http\Client\Curl`. +- Main client class name renamed from `CurlHttpClient` to `Client`. +- Minimum required [php-http/discovery](https://packagist.org/packages/php-http/discovery) + version changed to 0.5. + + +## 0.5.0 - 2015-12-18 + +### Changed + +- Compatibility with php-http/httplug 1.0 beta +- Switch to php-http/discovery 0.4 + + +## 0.4.0 - 2015-12-16 + +### Changed + +- Switch to php-http/message-factory 1.0 + + +## 0.3.1 - 2015-12-14 + +### Changed + +- Requirements fixed. + + +## 0.3.0 - 2015-11-24 + +### Changed + +- Use cURL constants as options keys. + + +## 0.2.0 - 2015-11-17 + +### Added + +- HttpAsyncClient support. + + +## 0.1.0 - 2015-11-11 + +### Added + +- Initial release diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/LICENSE b/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/LICENSE new file mode 100644 index 0000000..8e2c4a0 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2015 PHP HTTP Team <team@php-http.org> + +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/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/README.md b/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/README.md new file mode 100644 index 0000000..fc60b7e --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/README.md @@ -0,0 +1,44 @@ +# Curl client for PHP HTTP + +[![Latest Version](https://img.shields.io/github/release/php-http/curl-client.svg?style=flat-square)](https://github.com/php-http/curl-client/releases) +[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) +[![Build Status](https://img.shields.io/travis/php-http/curl-client.svg?style=flat-square)](https://travis-ci.org/php-http/curl-client) +[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/php-http/curl-client.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/curl-client) +[![Quality Score](https://img.shields.io/scrutinizer/g/php-http/curl-client.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/curl-client) +[![Total Downloads](https://img.shields.io/packagist/dt/php-http/curl-client.svg?style=flat-square)](https://packagist.org/packages/php-http/curl-client) + +The cURL client use the cURL PHP extension which must be activated in your `php.ini`. + + +## Install + +Via Composer + +``` bash +$ composer require php-http/curl-client +``` + +## Documentation + +Please see the [official documentation](http://docs.php-http.org/en/latest/clients/curl-client.html). + +## Testing + +``` bash +$ composer test +``` + +## Contributing + +Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details. + + +## Security + +If you discover any security related issues, please contact us at +[security@php-http.org](mailto:security@php-http.org). + + +## License + +The MIT License (MIT). Please see [License File](LICENSE) for more information. diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/composer.json b/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/composer.json new file mode 100644 index 0000000..5d16222 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/composer.json @@ -0,0 +1,50 @@ +{ + "name": "php-http/curl-client", + "description": "cURL client for PHP-HTTP", + "license": "MIT", + "keywords": ["http", "curl"], + "homepage": "http://php-http.org", + "authors": [ + { + "name": "Михаил Красильников", + "email": "m.krasilnikov@yandex.ru" + } + ], + "prefer-stable": true, + "minimum-stability": "beta", + "config": { + "bin-dir": "vendor/bin" + }, + "require": { + "php": "^5.5 || ^7.0", + "ext-curl": "*", + "php-http/httplug": "^1.0", + "php-http/message-factory": "^1.0.2", + "php-http/message": "^1.2", + "php-http/discovery": "^1.0" + }, + "require-dev": { + "guzzlehttp/psr7": "^1.0", + "php-http/client-integration-tests": "^0.5.1", + "phpunit/phpunit": "^4.8.27", + "zendframework/zend-diactoros": "^1.0" + }, + "autoload": { + "psr-4": { + "Http\\Client\\Curl\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Http\\Client\\Curl\\Tests\\": "tests/" + } + }, + "provide": { + "php-http/client-implementation": "1.0", + "php-http/async-client-implementation": "1.0" + }, + "scripts": { + "test": "vendor/bin/phpunit", + "test-ci": "vendor/bin/phpunit --coverage-clover build/coverage.xml" + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/puli.json b/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/puli.json new file mode 100644 index 0000000..b35768d --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/puli.json @@ -0,0 +1,242 @@ +{ + "version": "1.0", + "name": "php-http/curl-client", + "bindings": { + "98239b8b-103b-4f47-94c7-4cba49a05a1f": { + "_class": "Puli\\Discovery\\Binding\\ClassBinding", + "class": "Http\\Client\\Curl\\Client", + "type": "Http\\Client\\HttpAsyncClient" + }, + "a6a79968-2aa5-427c-bbe1-a581d9a48321": { + "_class": "Puli\\Discovery\\Binding\\ClassBinding", + "class": "Http\\Client\\Curl\\Client", + "type": "Http\\Client\\HttpClient" + } + }, + "config": { + "bootstrap-file": "vendor/autoload.php" + }, + "packages": { + "clue/stream-filter": { + "install-path": "vendor/clue/stream-filter", + "installer": "composer", + "env": "dev" + }, + "doctrine/instantiator": { + "install-path": "vendor/doctrine/instantiator", + "installer": "composer", + "env": "dev" + }, + "guzzlehttp/psr7": { + "install-path": "vendor/guzzlehttp/psr7", + "installer": "composer", + "env": "dev" + }, + "justinrainbow/json-schema": { + "install-path": "vendor/justinrainbow/json-schema", + "installer": "composer", + "env": "dev" + }, + "paragonie/random_compat": { + "install-path": "vendor/paragonie/random_compat", + "installer": "composer", + "env": "dev" + }, + "php-http/adapter-integration-tests": { + "install-path": "vendor/php-http/adapter-integration-tests", + "installer": "composer", + "env": "dev" + }, + "php-http/discovery": { + "install-path": "vendor/php-http/discovery", + "installer": "composer", + "env": "dev" + }, + "php-http/httplug": { + "install-path": "vendor/php-http/httplug", + "installer": "composer" + }, + "php-http/message": { + "install-path": "vendor/php-http/message", + "installer": "composer", + "env": "dev" + }, + "php-http/message-factory": { + "install-path": "vendor/php-http/message-factory", + "installer": "composer" + }, + "php-http/promise": { + "install-path": "vendor/php-http/promise", + "installer": "composer" + }, + "phpdocumentor/reflection-docblock": { + "install-path": "vendor/phpdocumentor/reflection-docblock", + "installer": "composer", + "env": "dev" + }, + "phpspec/prophecy": { + "install-path": "vendor/phpspec/prophecy", + "installer": "composer", + "env": "dev" + }, + "phpunit/php-code-coverage": { + "install-path": "vendor/phpunit/php-code-coverage", + "installer": "composer", + "env": "dev" + }, + "phpunit/php-file-iterator": { + "install-path": "vendor/phpunit/php-file-iterator", + "installer": "composer", + "env": "dev" + }, + "phpunit/php-text-template": { + "install-path": "vendor/phpunit/php-text-template", + "installer": "composer", + "env": "dev" + }, + "phpunit/php-timer": { + "install-path": "vendor/phpunit/php-timer", + "installer": "composer", + "env": "dev" + }, + "phpunit/php-token-stream": { + "install-path": "vendor/phpunit/php-token-stream", + "installer": "composer", + "env": "dev" + }, + "phpunit/phpunit": { + "install-path": "vendor/phpunit/phpunit", + "installer": "composer", + "env": "dev" + }, + "phpunit/phpunit-mock-objects": { + "install-path": "vendor/phpunit/phpunit-mock-objects", + "installer": "composer", + "env": "dev" + }, + "psr/http-message": { + "install-path": "vendor/psr/http-message", + "installer": "composer" + }, + "psr/log": { + "install-path": "vendor/psr/log", + "installer": "composer", + "env": "dev" + }, + "puli/composer-plugin": { + "install-path": "vendor/puli/composer-plugin", + "installer": "composer", + "env": "dev" + }, + "puli/discovery": { + "install-path": "vendor/puli/discovery", + "installer": "composer", + "env": "dev" + }, + "puli/repository": { + "install-path": "vendor/puli/repository", + "installer": "composer", + "env": "dev" + }, + "puli/url-generator": { + "install-path": "vendor/puli/url-generator", + "installer": "composer", + "env": "dev" + }, + "ramsey/uuid": { + "install-path": "vendor/ramsey/uuid", + "installer": "composer", + "env": "dev" + }, + "sebastian/comparator": { + "install-path": "vendor/sebastian/comparator", + "installer": "composer", + "env": "dev" + }, + "sebastian/diff": { + "install-path": "vendor/sebastian/diff", + "installer": "composer", + "env": "dev" + }, + "sebastian/environment": { + "install-path": "vendor/sebastian/environment", + "installer": "composer", + "env": "dev" + }, + "sebastian/exporter": { + "install-path": "vendor/sebastian/exporter", + "installer": "composer", + "env": "dev" + }, + "sebastian/global-state": { + "install-path": "vendor/sebastian/global-state", + "installer": "composer", + "env": "dev" + }, + "sebastian/recursion-context": { + "install-path": "vendor/sebastian/recursion-context", + "installer": "composer", + "env": "dev" + }, + "sebastian/version": { + "install-path": "vendor/sebastian/version", + "installer": "composer", + "env": "dev" + }, + "seld/jsonlint": { + "install-path": "vendor/seld/jsonlint", + "installer": "composer", + "env": "dev" + }, + "symfony/filesystem": { + "install-path": "vendor/symfony/filesystem", + "installer": "composer", + "env": "dev" + }, + "symfony/process": { + "install-path": "vendor/symfony/process", + "installer": "composer", + "env": "dev" + }, + "symfony/yaml": { + "install-path": "vendor/symfony/yaml", + "installer": "composer", + "env": "dev" + }, + "th3n3rd/cartesian-product": { + "install-path": "vendor/th3n3rd/cartesian-product", + "installer": "composer", + "env": "dev" + }, + "webmozart/assert": { + "install-path": "vendor/webmozart/assert", + "installer": "composer", + "env": "dev" + }, + "webmozart/expression": { + "install-path": "vendor/webmozart/expression", + "installer": "composer", + "env": "dev" + }, + "webmozart/glob": { + "install-path": "vendor/webmozart/glob", + "installer": "composer", + "env": "dev" + }, + "webmozart/json": { + "install-path": "vendor/webmozart/json", + "installer": "composer", + "env": "dev" + }, + "webmozart/path-util": { + "install-path": "vendor/webmozart/path-util", + "installer": "composer", + "env": "dev" + }, + "zendframework/zend-diactoros": { + "install-path": "vendor/zendframework/zend-diactoros", + "installer": "composer", + "env": "dev" + } + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/src/Client.php b/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/src/Client.php new file mode 100644 index 0000000..5696ab3 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/src/Client.php @@ -0,0 +1,371 @@ +<?php +namespace Http\Client\Curl; + +use Http\Client\Exception; +use Http\Client\HttpAsyncClient; +use Http\Client\HttpClient; +use Http\Discovery\MessageFactoryDiscovery; +use Http\Discovery\StreamFactoryDiscovery; +use Http\Message\MessageFactory; +use Http\Message\StreamFactory; +use Http\Promise\Promise; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; + +/** + * PSR-7 compatible cURL based HTTP client + * + * @license http://opensource.org/licenses/MIT MIT + * + * @author Михаил Красильников <m.krasilnikov@yandex.ru> + * @author Blake Williams <github@shabbyrobe.org> + * + * @api + * @since 1.0 + */ +class Client implements HttpClient, HttpAsyncClient +{ + /** + * cURL options + * + * @var array + */ + private $options; + + /** + * PSR-7 message factory + * + * @var MessageFactory + */ + private $messageFactory; + + /** + * PSR-7 stream factory + * + * @var StreamFactory + */ + private $streamFactory; + + /** + * cURL synchronous requests handle + * + * @var resource|null + */ + private $handle = null; + + /** + * Simultaneous requests runner + * + * @var MultiRunner|null + */ + private $multiRunner = null; + + /** + * Create new client + * + * @param MessageFactory|null $messageFactory HTTP Message factory + * @param StreamFactory|null $streamFactory HTTP Stream factory + * @param array $options cURL options (see http://php.net/curl_setopt) + * + * @throws \Http\Discovery\Exception\NotFoundException If factory discovery failed. + * + * @since 1.0 + */ + public function __construct( + MessageFactory $messageFactory = null, + StreamFactory $streamFactory = null, + array $options = [] + ) { + $this->messageFactory = $messageFactory ?: MessageFactoryDiscovery::find(); + $this->streamFactory = $streamFactory ?: StreamFactoryDiscovery::find(); + $this->options = $options; + } + + /** + * Release resources if still active + */ + public function __destruct() + { + if (is_resource($this->handle)) { + curl_close($this->handle); + } + } + + /** + * Sends a PSR-7 request. + * + * @param RequestInterface $request + * + * @return ResponseInterface + * + * @throws \Http\Client\Exception\NetworkException In case of network problems. + * @throws \Http\Client\Exception\RequestException On invalid request. + * @throws \InvalidArgumentException For invalid header names or values. + * @throws \RuntimeException If creating the body stream fails. + * + * @since 1.6 \UnexpectedValueException replaced with RequestException. + * @since 1.6 Throw NetworkException on network errors. + * @since 1.0 + */ + public function sendRequest(RequestInterface $request) + { + $responseBuilder = $this->createResponseBuilder(); + $options = $this->createCurlOptions($request, $responseBuilder); + + if (is_resource($this->handle)) { + curl_reset($this->handle); + } else { + $this->handle = curl_init(); + } + + curl_setopt_array($this->handle, $options); + curl_exec($this->handle); + + $errno = curl_errno($this->handle); + switch ($errno) { + case CURLE_OK: + // All OK, no actions needed. + break; + case CURLE_COULDNT_RESOLVE_PROXY: + case CURLE_COULDNT_RESOLVE_HOST: + case CURLE_COULDNT_CONNECT: + case CURLE_OPERATION_TIMEOUTED: + case CURLE_SSL_CONNECT_ERROR: + throw new Exception\NetworkException(curl_error($this->handle), $request); + default: + throw new Exception\RequestException(curl_error($this->handle), $request); + } + + $response = $responseBuilder->getResponse(); + $response->getBody()->seek(0); + + return $response; + } + + /** + * Sends a PSR-7 request in an asynchronous way. + * + * @param RequestInterface $request + * + * @return Promise + * + * @throws \Http\Client\Exception\RequestException On invalid request. + * @throws \InvalidArgumentException For invalid header names or values. + * @throws \RuntimeException If creating the body stream fails. + * + * @since 1.6 \UnexpectedValueException replaced with RequestException. + * @since 1.0 + */ + public function sendAsyncRequest(RequestInterface $request) + { + if (!$this->multiRunner instanceof MultiRunner) { + $this->multiRunner = new MultiRunner(); + } + + $handle = curl_init(); + $responseBuilder = $this->createResponseBuilder(); + $options = $this->createCurlOptions($request, $responseBuilder); + curl_setopt_array($handle, $options); + + $core = new PromiseCore($request, $handle, $responseBuilder); + $promise = new CurlPromise($core, $this->multiRunner); + $this->multiRunner->add($core); + + return $promise; + } + + /** + * Generates cURL options + * + * @param RequestInterface $request + * @param ResponseBuilder $responseBuilder + * + * @throws \Http\Client\Exception\RequestException On invalid request. + * @throws \InvalidArgumentException For invalid header names or values. + * @throws \RuntimeException if can not read body + * + * @return array + */ + private function createCurlOptions(RequestInterface $request, ResponseBuilder $responseBuilder) + { + $options = $this->options; + + $options[CURLOPT_HEADER] = false; + $options[CURLOPT_RETURNTRANSFER] = false; + $options[CURLOPT_FOLLOWLOCATION] = false; + + try { + $options[CURLOPT_HTTP_VERSION] + = $this->getProtocolVersion($request->getProtocolVersion()); + } catch (\UnexpectedValueException $e) { + throw new Exception\RequestException($e->getMessage(), $request); + } + $options[CURLOPT_URL] = (string) $request->getUri(); + + $options = $this->addRequestBodyOptions($request, $options); + + $options[CURLOPT_HTTPHEADER] = $this->createHeaders($request, $options); + + if ($request->getUri()->getUserInfo()) { + $options[CURLOPT_USERPWD] = $request->getUri()->getUserInfo(); + } + + $options[CURLOPT_HEADERFUNCTION] = function ($ch, $data) use ($responseBuilder) { + $str = trim($data); + if ('' !== $str) { + if (strpos(strtolower($str), 'http/') === 0) { + $responseBuilder->setStatus($str)->getResponse(); + } else { + $responseBuilder->addHeader($str); + } + } + + return strlen($data); + }; + + $options[CURLOPT_WRITEFUNCTION] = function ($ch, $data) use ($responseBuilder) { + return $responseBuilder->getResponse()->getBody()->write($data); + }; + + return $options; + } + + /** + * Return cURL constant for specified HTTP version + * + * @param string $requestVersion + * + * @throws \UnexpectedValueException if unsupported version requested + * + * @return int + */ + private function getProtocolVersion($requestVersion) + { + switch ($requestVersion) { + case '1.0': + return CURL_HTTP_VERSION_1_0; + case '1.1': + return CURL_HTTP_VERSION_1_1; + case '2.0': + if (defined('CURL_HTTP_VERSION_2_0')) { + return CURL_HTTP_VERSION_2_0; + } + throw new \UnexpectedValueException('libcurl 7.33 needed for HTTP 2.0 support'); + } + + return CURL_HTTP_VERSION_NONE; + } + + /** + * Add request body related cURL options. + * + * @param RequestInterface $request + * @param array $options + * + * @return array + */ + private function addRequestBodyOptions(RequestInterface $request, array $options) + { + /* + * Some HTTP methods cannot have payload: + * + * - GET — cURL will automatically change method to PUT or POST if we set CURLOPT_UPLOAD or + * CURLOPT_POSTFIELDS. + * - HEAD — cURL treats HEAD as GET request with a same restrictions. + * - TRACE — According to RFC7231: a client MUST NOT send a message body in a TRACE request. + */ + if (!in_array($request->getMethod(), ['GET', 'HEAD', 'TRACE'], true)) { + $body = $request->getBody(); + $bodySize = $body->getSize(); + if ($bodySize !== 0) { + if ($body->isSeekable()) { + $body->rewind(); + } + + // Message has non empty body. + if (null === $bodySize || $bodySize > 1024 * 1024) { + // Avoid full loading large or unknown size body into memory + $options[CURLOPT_UPLOAD] = true; + if (null !== $bodySize) { + $options[CURLOPT_INFILESIZE] = $bodySize; + } + $options[CURLOPT_READFUNCTION] = function ($ch, $fd, $length) use ($body) { + return $body->read($length); + }; + } else { + // Small body can be loaded into memory + $options[CURLOPT_POSTFIELDS] = (string) $body; + } + } + } + + if ($request->getMethod() === 'HEAD') { + // This will set HTTP method to "HEAD". + $options[CURLOPT_NOBODY] = true; + } elseif ($request->getMethod() !== 'GET') { + // GET is a default method. Other methods should be specified explicitly. + $options[CURLOPT_CUSTOMREQUEST] = $request->getMethod(); + } + + return $options; + } + + /** + * Create headers array for CURLOPT_HTTPHEADER + * + * @param RequestInterface $request + * @param array $options cURL options + * + * @return string[] + */ + private function createHeaders(RequestInterface $request, array $options) + { + $curlHeaders = []; + $headers = $request->getHeaders(); + foreach ($headers as $name => $values) { + $header = strtolower($name); + if ('expect' === $header) { + // curl-client does not support "Expect-Continue", so dropping "expect" headers + continue; + } + if ('content-length' === $header) { + if (array_key_exists(CURLOPT_POSTFIELDS, $options)) { + // Small body content length can be calculated here. + $values = [strlen($options[CURLOPT_POSTFIELDS])]; + } elseif (!array_key_exists(CURLOPT_READFUNCTION, $options)) { + // Else if there is no body, forcing "Content-length" to 0 + $values = [0]; + } + } + foreach ($values as $value) { + $curlHeaders[] = $name . ': ' . $value; + } + } + /* + * curl-client does not support "Expect-Continue", but cURL adds "Expect" header by default. + * We can not suppress it, but we can set it to empty. + */ + $curlHeaders[] = 'Expect:'; + + return $curlHeaders; + } + + /** + * Create new ResponseBuilder instance + * + * @return ResponseBuilder + * + * @throws \RuntimeException If creating the stream from $body fails. + */ + private function createResponseBuilder() + { + try { + $body = $this->streamFactory->createStream(fopen('php://temp', 'w+b')); + } catch (\InvalidArgumentException $e) { + throw new \RuntimeException('Can not create "php://temp" stream.'); + } + $response = $this->messageFactory->createResponse(200, null, [], $body); + + return new ResponseBuilder($response); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/src/CurlPromise.php b/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/src/CurlPromise.php new file mode 100644 index 0000000..68a775c --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/src/CurlPromise.php @@ -0,0 +1,108 @@ +<?php +namespace Http\Client\Curl; + +use Http\Promise\Promise; + +/** + * Promise represents a response that may not be available yet, but will be resolved at some point + * in future. It acts like a proxy to the actual response. + * + * This interface is an extension of the promises/a+ specification https://promisesaplus.com/ + * Value is replaced by an object where its class implement a Psr\Http\Message\RequestInterface. + * Reason is replaced by an object where its class implement a Http\Client\Exception. + * + * @license http://opensource.org/licenses/MIT MIT + * + * @author Михаил Красильников <m.krasilnikov@yandex.ru> + */ +class CurlPromise implements Promise +{ + /** + * Shared promise core + * + * @var PromiseCore + */ + private $core; + + /** + * Requests runner + * + * @var MultiRunner + */ + private $runner; + + /** + * Create new promise. + * + * @param PromiseCore $core Shared promise core + * @param MultiRunner $runner Simultaneous requests runner + */ + public function __construct(PromiseCore $core, MultiRunner $runner) + { + $this->core = $core; + $this->runner = $runner; + } + + /** + * Add behavior for when the promise is resolved or rejected. + * + * If you do not care about one of the cases, you can set the corresponding callable to null + * The callback will be called when the response or exception arrived and never more than once. + * + * @param callable $onFulfilled Called when a response will be available. + * @param callable $onRejected Called when an error happens. + * + * You must always return the Response in the interface or throw an Exception. + * + * @return Promise Always returns a new promise which is resolved with value of the executed + * callback (onFulfilled / onRejected). + */ + public function then(callable $onFulfilled = null, callable $onRejected = null) + { + if ($onFulfilled) { + $this->core->addOnFulfilled($onFulfilled); + } + if ($onRejected) { + $this->core->addOnRejected($onRejected); + } + + return new self($this->core, $this->runner); + } + + /** + * Get the state of the promise, one of PENDING, FULFILLED or REJECTED. + * + * @return string + */ + public function getState() + { + return $this->core->getState(); + } + + /** + * Wait for the promise to be fulfilled or rejected. + * + * When this method returns, the request has been resolved and the appropriate callable has terminated. + * + * When called with the unwrap option + * + * @param bool $unwrap Whether to return resolved value / throw reason or not + * + * @return \Psr\Http\Message\ResponseInterface|null Resolved value, null if $unwrap is set to false + * + * @throws \Http\Client\Exception The rejection reason. + */ + public function wait($unwrap = true) + { + $this->runner->wait($this->core); + + if ($unwrap) { + if ($this->core->getState() === self::REJECTED) { + throw $this->core->getException(); + } + + return $this->core->getResponse(); + } + return null; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/src/MultiRunner.php b/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/src/MultiRunner.php new file mode 100644 index 0000000..9094c0f --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/src/MultiRunner.php @@ -0,0 +1,127 @@ +<?php +namespace Http\Client\Curl; + +use Http\Client\Exception\RequestException; + +/** + * Simultaneous requests runner + * + * @license http://opensource.org/licenses/MIT MIT + * + * @author Михаил Красильников <m.krasilnikov@yandex.ru> + */ +class MultiRunner +{ + /** + * cURL multi handle + * + * @var resource|null + */ + private $multiHandle = null; + + /** + * Awaiting cores + * + * @var PromiseCore[] + */ + private $cores = []; + + /** + * Release resources if still active + */ + public function __destruct() + { + if (is_resource($this->multiHandle)) { + curl_multi_close($this->multiHandle); + } + } + + /** + * Add promise to runner + * + * @param PromiseCore $core + */ + public function add(PromiseCore $core) + { + foreach ($this->cores as $existed) { + if ($existed === $core) { + return; + } + } + + $this->cores[] = $core; + + if (null === $this->multiHandle) { + $this->multiHandle = curl_multi_init(); + } + curl_multi_add_handle($this->multiHandle, $core->getHandle()); + } + + /** + * Remove promise from runner + * + * @param PromiseCore $core + */ + public function remove(PromiseCore $core) + { + foreach ($this->cores as $index => $existed) { + if ($existed === $core) { + curl_multi_remove_handle($this->multiHandle, $core->getHandle()); + unset($this->cores[$index]); + return; + } + } + } + + /** + * Wait for request(s) to be completed. + * + * @param PromiseCore|null $targetCore + */ + public function wait(PromiseCore $targetCore = null) + { + do { + $status = curl_multi_exec($this->multiHandle, $active); + $info = curl_multi_info_read($this->multiHandle); + if (false !== $info) { + $core = $this->findCoreByHandle($info['handle']); + + if (null === $core) { + // We have no promise for this handle. Drop it. + curl_multi_remove_handle($this->multiHandle, $info['handle']); + continue; + } + + if (CURLE_OK === $info['result']) { + $core->fulfill(); + } else { + $error = curl_error($core->getHandle()); + $core->reject(new RequestException($error, $core->getRequest())); + } + $this->remove($core); + + // This is a promise we are waited for. So exiting wait(). + if ($core === $targetCore) { + return; + } + } + } while ($status === CURLM_CALL_MULTI_PERFORM || $active); + } + + /** + * Find core by handle. + * + * @param resource $handle + * + * @return PromiseCore|null + */ + private function findCoreByHandle($handle) + { + foreach ($this->cores as $core) { + if ($core->getHandle() === $handle) { + return $core; + } + } + return null; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/src/PromiseCore.php b/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/src/PromiseCore.php new file mode 100644 index 0000000..f1a3aa5 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/src/PromiseCore.php @@ -0,0 +1,224 @@ +<?php +namespace Http\Client\Curl; + +use Http\Client\Exception; +use Http\Promise\Promise; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; + +/** + * Shared promises core. + * + * @license http://opensource.org/licenses/MIT MIT + * + * @author Михаил Красильников <m.krasilnikov@yandex.ru> + */ +class PromiseCore +{ + /** + * HTTP request + * + * @var RequestInterface + */ + private $request; + + /** + * cURL handle + * + * @var resource + */ + private $handle; + + /** + * Response builder + * + * @var ResponseBuilder + */ + private $responseBuilder; + + /** + * Promise state + * + * @var string + */ + private $state; + + /** + * Exception + * + * @var Exception|null + */ + private $exception = null; + + /** + * Functions to call when a response will be available. + * + * @var callable[] + */ + private $onFulfilled = []; + + /** + * Functions to call when an error happens. + * + * @var callable[] + */ + private $onRejected = []; + + /** + * Create shared core. + * + * @param RequestInterface $request HTTP request + * @param resource $handle cURL handle + * @param ResponseBuilder $responseBuilder + */ + public function __construct( + RequestInterface $request, + $handle, + ResponseBuilder $responseBuilder + ) { + assert('is_resource($handle)'); + assert('get_resource_type($handle) === "curl"'); + + $this->request = $request; + $this->handle = $handle; + $this->responseBuilder = $responseBuilder; + $this->state = Promise::PENDING; + } + + /** + * Add on fulfilled callback. + * + * @param callable $callback + */ + public function addOnFulfilled(callable $callback) + { + if ($this->getState() === Promise::PENDING) { + $this->onFulfilled[] = $callback; + } elseif ($this->getState() === Promise::FULFILLED) { + $response = call_user_func($callback, $this->responseBuilder->getResponse()); + if ($response instanceof ResponseInterface) { + $this->responseBuilder->setResponse($response); + } + } + } + + /** + * Add on rejected callback. + * + * @param callable $callback + */ + public function addOnRejected(callable $callback) + { + if ($this->getState() === Promise::PENDING) { + $this->onRejected[] = $callback; + } elseif ($this->getState() === Promise::REJECTED) { + $this->exception = call_user_func($callback, $this->exception); + } + } + + /** + * Return cURL handle + * + * @return resource + */ + public function getHandle() + { + return $this->handle; + } + + /** + * Get the state of the promise, one of PENDING, FULFILLED or REJECTED. + * + * @return string + */ + public function getState() + { + return $this->state; + } + + /** + * Return request + * + * @return RequestInterface + */ + public function getRequest() + { + return $this->request; + } + + /** + * Return the value of the promise (fulfilled). + * + * @return ResponseInterface Response Object only when the Promise is fulfilled. + */ + public function getResponse() + { + return $this->responseBuilder->getResponse(); + } + + /** + * Get the reason why the promise was rejected. + * + * If the exception is an instance of Http\Client\Exception\HttpException it will contain + * the response object with the status code and the http reason. + * + * @return Exception Exception Object only when the Promise is rejected. + * + * @throws \LogicException When the promise is not rejected. + */ + public function getException() + { + if (null === $this->exception) { + throw new \LogicException('Promise is not rejected'); + } + + return $this->exception; + } + + /** + * Fulfill promise. + */ + public function fulfill() + { + $this->state = Promise::FULFILLED; + $response = $this->responseBuilder->getResponse(); + try { + $response->getBody()->seek(0); + } catch (\RuntimeException $e) { + $exception = new Exception\TransferException($e->getMessage(), $e->getCode(), $e); + $this->reject($exception); + + return; + } + + while (count($this->onFulfilled) > 0) { + $callback = array_shift($this->onFulfilled); + $response = call_user_func($callback, $response); + } + + if ($response instanceof ResponseInterface) { + $this->responseBuilder->setResponse($response); + } + } + + /** + * Reject promise. + * + * @param Exception $exception Reject reason. + */ + public function reject(Exception $exception) + { + $this->exception = $exception; + $this->state = Promise::REJECTED; + + while (count($this->onRejected) > 0) { + $callback = array_shift($this->onRejected); + try { + $exception = call_user_func($callback, $this->exception); + $this->exception = $exception; + } catch (Exception $exception) { + $this->exception = $exception; + } + } + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/src/ResponseBuilder.php b/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/src/ResponseBuilder.php new file mode 100644 index 0000000..99e79db --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/curl-client/src/ResponseBuilder.php @@ -0,0 +1,21 @@ +<?php +namespace Http\Client\Curl; + +use Http\Message\Builder\ResponseBuilder as OriginalResponseBuilder; +use Psr\Http\Message\ResponseInterface; + +/** + * Extended response builder + */ +class ResponseBuilder extends OriginalResponseBuilder +{ + /** + * Replace response with a new instance + * + * @param ResponseInterface $response + */ + public function setResponse(ResponseInterface $response) + { + $this->response = $response; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/CHANGELOG.md b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/CHANGELOG.md new file mode 100644 index 0000000..2c476ea --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/CHANGELOG.md @@ -0,0 +1,186 @@ +# Change Log + +## 1.3.0 - 2017-08-03 + +### Added + +- Discovery support for CakePHP adapter +- Discovery support for Zend adapter +- Discovery support for Artax adapter + +## 1.2.1 - 2017-03-02 + +### Fixed + +- Fixed minor issue with `MockClientStrategy`, also added more tests. + +## 1.2.0 - 2017-02-12 + +### Added + +- MockClientStrategy class. + +## 1.1.1 - 2016-11-27 + +### Changed + +- Made exception messages clearer. `StrategyUnavailableException` is no longer the previous exception to `DiscoveryFailedException`. +- `CommonClassesStrategy` is using `self` instead of `static`. Using `static` makes no sense when `CommonClassesStrategy` is final. + +## 1.1.0 - 2016-10-20 + +### Added + +- Discovery support for Slim Framework factories + +## 1.0.0 - 2016-07-18 + +### Added + +- Added back `Http\Discovery\NotFoundException` to preserve BC with 0.8 version. You may upgrade from 0.8.x and 0.9.x to 1.0.0 without any BC breaks. +- Added interface `Http\Discovery\Exception` which is implemented by all our exceptions + +### Changed + +- Puli strategy renamed to Puli Beta strategy to prevent incompatibility with a future Puli stable + +### Deprecated + +- For BC reasons, the old `Http\Discovery\NotFoundException` (extending the new exception) will be thrown until version 2.0 + + +## 0.9.1 - 2016-06-28 + +### Changed + +- Dropping PHP 5.4 support because we use the ::class constant. + + +## 0.9.0 - 2016-06-25 + +### Added + +- Discovery strategies to find classes + +### Changed + +- [Puli](http://puli.io) made optional +- Improved exceptions +- **[BC] `NotFoundException` moved to `Http\Discovery\Exception\NotFoundException`** + + +## 0.8.0 - 2016-02-11 + +### Changed + +- Puli composer plugin must be installed separately + + +## 0.7.0 - 2016-01-15 + +### Added + +- Temporary puli.phar (Beta 10) executable + +### Changed + +- Updated HTTPlug dependencies +- Updated Puli dependencies +- Local configuration to make tests passing + +### Removed + +- Puli CLI dependency + + +## 0.6.4 - 2016-01-07 + +### Fixed + +- Puli [not working](https://twitter.com/PuliPHP/status/685132540588507137) with the latest json-schema + + +## 0.6.3 - 2016-01-04 + +### Changed + +- Adjust Puli dependencies + + +## 0.6.2 - 2016-01-04 + +### Changed + +- Make Puli CLI a requirement + + +## 0.6.1 - 2016-01-03 + +### Changed + +- More flexible Puli requirement + + +## 0.6.0 - 2015-12-30 + +### Changed + +- Use [Puli](http://puli.io) for discovery +- Improved exception messages + + +## 0.5.0 - 2015-12-25 + +### Changed + +- Updated message factory dependency (php-http/message) + + +## 0.4.0 - 2015-12-17 + +### Added + +- Array condition evaluation in the Class Discovery + +### Removed + +- Message factories (moved to php-http/utils) + + +## 0.3.0 - 2015-11-18 + +### Added + +- HTTP Async Client Discovery +- Stream factories + +### Changed + +- Discoveries and Factories are final +- Message and Uri factories have the type in their names +- Diactoros Message factory uses Stream factory internally + +### Fixed + +- Improved docblocks for API documentation generation + + +## 0.2.0 - 2015-10-31 + +### Changed + +- Renamed AdapterDiscovery to ClientDiscovery + + +## 0.1.1 - 2015-06-13 + +### Fixed + +- Bad HTTP Adapter class name for Guzzle 5 + + +## 0.1.0 - 2015-06-12 + +### Added + +- Initial release diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/LICENSE b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/LICENSE new file mode 100644 index 0000000..4558d6f --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2015-2016 PHP HTTP Team <team@php-http.org> + +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/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/README.md b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/README.md new file mode 100644 index 0000000..7c5151e --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/README.md @@ -0,0 +1,46 @@ +# HTTPlug Discovery + +[![Latest Version](https://img.shields.io/github/release/php-http/discovery.svg?style=flat-square)](https://github.com/php-http/discovery/releases) +[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) +[![Build Status](https://img.shields.io/travis/php-http/discovery.svg?style=flat-square)](https://travis-ci.org/php-http/discovery) +[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/php-http/discovery.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/discovery) +[![Quality Score](https://img.shields.io/scrutinizer/g/php-http/discovery.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/discovery) +[![Total Downloads](https://img.shields.io/packagist/dt/php-http/discovery.svg?style=flat-square)](https://packagist.org/packages/php-http/discovery) + +**Finds installed HTTPlug implementations and PSR-7 message factories.** + + +## Install + +Via Composer + +``` bash +$ composer require php-http/discovery +``` + + +## Documentation + +Please see the [official documentation](http://php-http.readthedocs.org/en/latest/discovery.html). + + +## Testing + +``` bash +$ composer test +``` + + +## Contributing + +Please see our [contributing guide](http://docs.php-http.org/en/latest/development/contributing.html). + + +## Security + +If you discover any security related issues, please contact us at [security@php-http.org](mailto:security@php-http.org). + + +## License + +The MIT License (MIT). Please see [License File](LICENSE) for more information. diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/composer.json b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/composer.json new file mode 100644 index 0000000..128af59 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/composer.json @@ -0,0 +1,48 @@ +{ + "name": "php-http/discovery", + "description": "Finds installed HTTPlug implementations and PSR-7 message factories", + "license": "MIT", + "keywords": ["http", "discovery", "client", "adapter", "message", "factory", "psr7"], + "homepage": "http://php-http.org", + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "require": { + "php": "^5.5 || ^7.0" + }, + "require-dev": { + "php-http/httplug": "^1.0", + "php-http/message-factory": "^1.0", + "puli/composer-plugin": "1.0.0-beta10", + "phpspec/phpspec": "^2.4", + "henrikbjorn/phpspec-code-coverage" : "^2.0.2" + }, + "suggest": { + "puli/composer-plugin": "Sets up Puli which is recommended for Discovery to work. Check http://docs.php-http.org/en/latest/discovery.html for more details.", + "php-http/message": "Allow to use Guzzle, Diactoros or Slim Framework factories" + }, + "autoload": { + "psr-4": { + "Http\\Discovery\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "spec\\Http\\Discovery\\": "spec/" + } + }, + "scripts": { + "test": "vendor/bin/phpspec run", + "test-ci": "vendor/bin/phpspec run -c phpspec.ci.yml" + }, + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "prefer-stable": true, + "minimum-stability": "beta" +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/ClassDiscovery.php b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/ClassDiscovery.php new file mode 100644 index 0000000..2c3e877 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/ClassDiscovery.php @@ -0,0 +1,207 @@ +<?php + +namespace Http\Discovery; + +use Http\Discovery\Exception\ClassInstantiationFailedException; +use Http\Discovery\Exception\DiscoveryFailedException; +use Http\Discovery\Exception\StrategyUnavailableException; + +/** + * Registry that based find results on class existence. + * + * @author David de Boer <david@ddeboer.nl> + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +abstract class ClassDiscovery +{ + /** + * A list of strategies to find classes. + * + * @var array + */ + private static $strategies = [ + Strategy\PuliBetaStrategy::class, + Strategy\CommonClassesStrategy::class, + ]; + + /** + * Discovery cache to make the second time we use discovery faster. + * + * @var array + */ + private static $cache = []; + + /** + * Finds a class. + * + * @param string $type + * + * @return string|\Closure + * + * @throws DiscoveryFailedException + */ + protected static function findOneByType($type) + { + // Look in the cache + if (null !== ($class = self::getFromCache($type))) { + return $class; + } + + $exceptions = []; + foreach (self::$strategies as $strategy) { + try { + $candidates = call_user_func($strategy.'::getCandidates', $type); + } catch (StrategyUnavailableException $e) { + $exceptions[] = $e; + continue; + } + + foreach ($candidates as $candidate) { + if (isset($candidate['condition'])) { + if (!self::evaluateCondition($candidate['condition'])) { + continue; + } + } + + // save the result for later use + self::storeInCache($type, $candidate); + + return $candidate['class']; + } + } + + throw DiscoveryFailedException::create($exceptions); + } + + /** + * Get a value from cache. + * + * @param string $type + * + * @return string|null + */ + private static function getFromCache($type) + { + if (!isset(self::$cache[$type])) { + return; + } + + $candidate = self::$cache[$type]; + if (isset($candidate['condition'])) { + if (!self::evaluateCondition($candidate['condition'])) { + return; + } + } + + return $candidate['class']; + } + + /** + * Store a value in cache. + * + * @param string $type + * @param string $class + */ + private static function storeInCache($type, $class) + { + self::$cache[$type] = $class; + } + + /** + * Set new strategies and clear the cache. + * + * @param array $strategies string array of fully qualified class name to a DiscoveryStrategy + */ + public static function setStrategies(array $strategies) + { + self::$strategies = $strategies; + self::clearCache(); + } + + /** + * Append a strategy at the end of the strategy queue. + * + * @param string $strategy Fully qualified class name to a DiscoveryStrategy + */ + public static function appendStrategy($strategy) + { + self::$strategies[] = $strategy; + self::clearCache(); + } + + /** + * Prepend a strategy at the beginning of the strategy queue. + * + * @param string $strategy Fully qualified class name to a DiscoveryStrategy + */ + public static function prependStrategy($strategy) + { + array_unshift(self::$strategies, $strategy); + self::clearCache(); + } + + /** + * Clear the cache. + */ + public static function clearCache() + { + self::$cache = []; + } + + /** + * Evaluates conditions to boolean. + * + * @param mixed $condition + * + * @return bool + */ + protected static function evaluateCondition($condition) + { + if (is_string($condition)) { + // Should be extended for functions, extensions??? + return class_exists($condition); + } elseif (is_callable($condition)) { + return $condition(); + } elseif (is_bool($condition)) { + return $condition; + } elseif (is_array($condition)) { + $evaluatedCondition = true; + + // Immediately stop execution if the condition is false + for ($i = 0; $i < count($condition) && false !== $evaluatedCondition; ++$i) { + $evaluatedCondition &= static::evaluateCondition($condition[$i]); + } + + return $evaluatedCondition; + } + + return false; + } + + /** + * Get an instance of the $class. + * + * @param string|\Closure $class A FQCN of a class or a closure that instantiate the class. + * + * @return object + * + * @throws ClassInstantiationFailedException + */ + protected static function instantiateClass($class) + { + try { + if (is_string($class)) { + return new $class(); + } + + if (is_callable($class)) { + return $class(); + } + } catch (\Exception $e) { + throw new ClassInstantiationFailedException('Unexpected exception when instantiating class.', 0, $e); + } + + throw new ClassInstantiationFailedException('Could not instantiate class because parameter is neither a callable nor a string'); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/Exception.php b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/Exception.php new file mode 100644 index 0000000..973c908 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/Exception.php @@ -0,0 +1,12 @@ +<?php + +namespace Http\Discovery; + +/** + * An interface implemented by all discovery related exceptions. + * + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +interface Exception +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/Exception/ClassInstantiationFailedException.php b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/Exception/ClassInstantiationFailedException.php new file mode 100644 index 0000000..e95bf5d --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/Exception/ClassInstantiationFailedException.php @@ -0,0 +1,14 @@ +<?php + +namespace Http\Discovery\Exception; + +use Http\Discovery\Exception; + +/** + * Thrown when a class fails to instantiate. + * + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +final class ClassInstantiationFailedException extends \RuntimeException implements Exception +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/Exception/DiscoveryFailedException.php b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/Exception/DiscoveryFailedException.php new file mode 100644 index 0000000..304b727 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/Exception/DiscoveryFailedException.php @@ -0,0 +1,51 @@ +<?php + +namespace Http\Discovery\Exception; + +use Http\Discovery\Exception; + +/** + * Thrown when all discovery strategies fails to find a resource. + * + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +final class DiscoveryFailedException extends \Exception implements Exception +{ + /** + * @var \Exception[] + */ + private $exceptions; + + /** + * @param string $message + * @param \Exception[] $exceptions + */ + public function __construct($message, array $exceptions = []) + { + $this->exceptions = $exceptions; + + parent::__construct($message); + } + + /** + * @param \Exception[] $exceptions + */ + public static function create($exceptions) + { + $message = 'Could not find resource using any discovery strategy. Find more information at http://docs.php-http.org/en/latest/discovery.html#common-errors'; + foreach ($exceptions as $e) { + $message .= "\n - ".$e->getMessage(); + } + $message .= "\n\n"; + + return new self($message, $exceptions); + } + + /** + * @return \Exception[] + */ + public function getExceptions() + { + return $this->exceptions; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/Exception/NotFoundException.php b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/Exception/NotFoundException.php new file mode 100644 index 0000000..befbf48 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/Exception/NotFoundException.php @@ -0,0 +1,16 @@ +<?php + +namespace Http\Discovery\Exception; + +use Http\Discovery\Exception; + +/** + * Thrown when a discovery does not find any matches. + * + * @final do NOT extend this class, not final for BC reasons + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +/*final */class NotFoundException extends \RuntimeException implements Exception +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/Exception/PuliUnavailableException.php b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/Exception/PuliUnavailableException.php new file mode 100644 index 0000000..a6ade73 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/Exception/PuliUnavailableException.php @@ -0,0 +1,12 @@ +<?php + +namespace Http\Discovery\Exception; + +/** + * Thrown when we can't use Puli for discovery. + * + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +final class PuliUnavailableException extends StrategyUnavailableException +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/Exception/StrategyUnavailableException.php b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/Exception/StrategyUnavailableException.php new file mode 100644 index 0000000..89ecf35 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/Exception/StrategyUnavailableException.php @@ -0,0 +1,15 @@ +<?php + +namespace Http\Discovery\Exception; + +use Http\Discovery\Exception; + +/** + * This exception is thrown when we cannot use a discovery strategy. This is *not* thrown when + * the discovery fails to find a class. + * + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +class StrategyUnavailableException extends \RuntimeException implements Exception +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/HttpAsyncClientDiscovery.php b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/HttpAsyncClientDiscovery.php new file mode 100644 index 0000000..6ef60e7 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/HttpAsyncClientDiscovery.php @@ -0,0 +1,36 @@ +<?php + +namespace Http\Discovery; + +use Http\Client\HttpAsyncClient; +use Http\Discovery\Exception\DiscoveryFailedException; + +/** + * Finds an HTTP Asynchronous Client. + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +final class HttpAsyncClientDiscovery extends ClassDiscovery +{ + /** + * Finds an HTTP Async Client. + * + * @return HttpAsyncClient + * + * @throws Exception\NotFoundException + */ + public static function find() + { + try { + $asyncClient = static::findOneByType(HttpAsyncClient::class); + } catch (DiscoveryFailedException $e) { + throw new NotFoundException( + 'No HTTPlug async clients found. Make sure to install a package providing "php-http/async-client-implementation". Example: "php-http/guzzle6-adapter".', + 0, + $e + ); + } + + return static::instantiateClass($asyncClient); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/HttpClientDiscovery.php b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/HttpClientDiscovery.php new file mode 100644 index 0000000..2654b7e --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/HttpClientDiscovery.php @@ -0,0 +1,36 @@ +<?php + +namespace Http\Discovery; + +use Http\Client\HttpClient; +use Http\Discovery\Exception\DiscoveryFailedException; + +/** + * Finds an HTTP Client. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +final class HttpClientDiscovery extends ClassDiscovery +{ + /** + * Finds an HTTP Client. + * + * @return HttpClient + * + * @throws Exception\NotFoundException + */ + public static function find() + { + try { + $client = static::findOneByType(HttpClient::class); + } catch (DiscoveryFailedException $e) { + throw new NotFoundException( + 'No HTTPlug clients found. Make sure to install a package providing "php-http/client-implementation". Example: "php-http/guzzle6-adapter".', + 0, + $e + ); + } + + return static::instantiateClass($client); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/MessageFactoryDiscovery.php b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/MessageFactoryDiscovery.php new file mode 100644 index 0000000..c21b9bf --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/MessageFactoryDiscovery.php @@ -0,0 +1,36 @@ +<?php + +namespace Http\Discovery; + +use Http\Discovery\Exception\DiscoveryFailedException; +use Http\Message\MessageFactory; + +/** + * Finds a Message Factory. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +final class MessageFactoryDiscovery extends ClassDiscovery +{ + /** + * Finds a Message Factory. + * + * @return MessageFactory + * + * @throws Exception\NotFoundException + */ + public static function find() + { + try { + $messageFactory = static::findOneByType(MessageFactory::class); + } catch (DiscoveryFailedException $e) { + throw new NotFoundException( + 'No message factories found. To use Guzzle, Diactoros or Slim Framework factories install php-http/message and the chosen message implementation.', + 0, + $e + ); + } + + return static::instantiateClass($messageFactory); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/NotFoundException.php b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/NotFoundException.php new file mode 100644 index 0000000..d59dadb --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/NotFoundException.php @@ -0,0 +1,14 @@ +<?php + +namespace Http\Discovery; + +/** + * Thrown when a discovery does not find any matches. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + * + * @deprecated since since version 1.0, and will be removed in 2.0. Use {@link \Http\Discovery\Exception\NotFoundException} instead. + */ +final class NotFoundException extends \Http\Discovery\Exception\NotFoundException +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/Strategy/CommonClassesStrategy.php b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/Strategy/CommonClassesStrategy.php new file mode 100644 index 0000000..6e42bee --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/Strategy/CommonClassesStrategy.php @@ -0,0 +1,82 @@ +<?php + +namespace Http\Discovery\Strategy; + +use GuzzleHttp\Psr7\Request as GuzzleRequest; +use Http\Message\MessageFactory\GuzzleMessageFactory; +use Http\Message\StreamFactory\GuzzleStreamFactory; +use Http\Message\UriFactory\GuzzleUriFactory; +use Http\Message\MessageFactory\DiactorosMessageFactory; +use Http\Message\StreamFactory\DiactorosStreamFactory; +use Http\Message\UriFactory\DiactorosUriFactory; +use Zend\Diactoros\Request as DiactorosRequest; +use Http\Message\MessageFactory\SlimMessageFactory; +use Http\Message\StreamFactory\SlimStreamFactory; +use Http\Message\UriFactory\SlimUriFactory; +use Slim\Http\Request as SlimRequest; +use Http\Adapter\Guzzle6\Client as Guzzle6; +use Http\Adapter\Guzzle5\Client as Guzzle5; +use Http\Client\Curl\Client as Curl; +use Http\Client\Socket\Client as Socket; +use Http\Adapter\React\Client as React; +use Http\Adapter\Buzz\Client as Buzz; +use Http\Adapter\Cake\Client as Cake; +use Http\Adapter\Zend\Client as Zend; +use Http\Adapter\Artax\Client as Artax; + +/** + * @internal + * + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +final class CommonClassesStrategy implements DiscoveryStrategy +{ + /** + * @var array + */ + private static $classes = [ + 'Http\Message\MessageFactory' => [ + ['class' => GuzzleMessageFactory::class, 'condition' => [GuzzleRequest::class, GuzzleMessageFactory::class]], + ['class' => DiactorosMessageFactory::class, 'condition' => [DiactorosRequest::class, DiactorosMessageFactory::class]], + ['class' => SlimMessageFactory::class, 'condition' => [SlimRequest::class, SlimMessageFactory::class]], + ], + 'Http\Message\StreamFactory' => [ + ['class' => GuzzleStreamFactory::class, 'condition' => [GuzzleRequest::class, GuzzleStreamFactory::class]], + ['class' => DiactorosStreamFactory::class, 'condition' => [DiactorosRequest::class, DiactorosStreamFactory::class]], + ['class' => SlimStreamFactory::class, 'condition' => [SlimRequest::class, SlimStreamFactory::class]], + ], + 'Http\Message\UriFactory' => [ + ['class' => GuzzleUriFactory::class, 'condition' => [GuzzleRequest::class, GuzzleUriFactory::class]], + ['class' => DiactorosUriFactory::class, 'condition' => [DiactorosRequest::class, DiactorosUriFactory::class]], + ['class' => SlimUriFactory::class, 'condition' => [SlimRequest::class, SlimUriFactory::class]], + ], + 'Http\Client\HttpAsyncClient' => [ + ['class' => Guzzle6::class, 'condition' => Guzzle6::class], + ['class' => Curl::class, 'condition' => Curl::class], + ['class' => React::class, 'condition' => React::class], + ], + 'Http\Client\HttpClient' => [ + ['class' => Guzzle6::class, 'condition' => Guzzle6::class], + ['class' => Guzzle5::class, 'condition' => Guzzle5::class], + ['class' => Curl::class, 'condition' => Curl::class], + ['class' => Socket::class, 'condition' => Socket::class], + ['class' => Buzz::class, 'condition' => Buzz::class], + ['class' => React::class, 'condition' => React::class], + ['class' => Cake::class, 'condition' => Cake::class], + ['class' => Zend::class, 'condition' => Zend::class], + ['class' => Artax::class, 'condition' => Artax::class], + ], + ]; + + /** + * {@inheritdoc} + */ + public static function getCandidates($type) + { + if (isset(self::$classes[$type])) { + return self::$classes[$type]; + } + + return []; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/Strategy/DiscoveryStrategy.php b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/Strategy/DiscoveryStrategy.php new file mode 100644 index 0000000..641485a --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/Strategy/DiscoveryStrategy.php @@ -0,0 +1,23 @@ +<?php + +namespace Http\Discovery\Strategy; + +use Http\Discovery\Exception\StrategyUnavailableException; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +interface DiscoveryStrategy +{ + /** + * Find a resource of a specific type. + * + * @param string $type + * + * @return array The return value is always an array with zero or more elements. Each + * element is an array with two keys ['class' => string, 'condition' => mixed]. + * + * @throws StrategyUnavailableException if we cannot use this strategy. + */ + public static function getCandidates($type); +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/Strategy/MockClientStrategy.php b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/Strategy/MockClientStrategy.php new file mode 100644 index 0000000..ea464cf --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/Strategy/MockClientStrategy.php @@ -0,0 +1,24 @@ +<?php + +namespace Http\Discovery\Strategy; + +use Http\Client\HttpClient; +use Http\Mock\Client as Mock; + +/** + * Find the Mock client. + * + * @author Sam Rapaport <me@samrapdev.com> + */ +final class MockClientStrategy implements DiscoveryStrategy +{ + /** + * {@inheritdoc} + */ + public static function getCandidates($type) + { + return ($type === HttpClient::class) + ? [['class' => Mock::class, 'condition' => Mock::class]] + : []; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/Strategy/PuliBetaStrategy.php b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/Strategy/PuliBetaStrategy.php new file mode 100644 index 0000000..2666fb3 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/Strategy/PuliBetaStrategy.php @@ -0,0 +1,91 @@ +<?php + +namespace Http\Discovery\Strategy; + +use Http\Discovery\Exception\PuliUnavailableException; +use Puli\Discovery\Api\Discovery; +use Puli\GeneratedPuliFactory; + +/** + * Find candidates using Puli. + * + * @internal + * @final + * + * @author David de Boer <david@ddeboer.nl> + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +class PuliBetaStrategy implements DiscoveryStrategy +{ + /** + * @var GeneratedPuliFactory + */ + protected static $puliFactory; + + /** + * @var Discovery + */ + protected static $puliDiscovery; + + /** + * @return GeneratedPuliFactory + * + * @throws PuliUnavailableException + */ + private static function getPuliFactory() + { + if (null === self::$puliFactory) { + if (!defined('PULI_FACTORY_CLASS')) { + throw new PuliUnavailableException('Puli Factory is not available'); + } + + $puliFactoryClass = PULI_FACTORY_CLASS; + + if (!class_exists($puliFactoryClass)) { + throw new PuliUnavailableException('Puli Factory class does not exist'); + } + + self::$puliFactory = new $puliFactoryClass(); + } + + return self::$puliFactory; + } + + /** + * Returns the Puli discovery layer. + * + * @return Discovery + * + * @throws PuliUnavailableException + */ + private static function getPuliDiscovery() + { + if (!isset(self::$puliDiscovery)) { + $factory = self::getPuliFactory(); + $repository = $factory->createRepository(); + + self::$puliDiscovery = $factory->createDiscovery($repository); + } + + return self::$puliDiscovery; + } + + /** + * {@inheritdoc} + */ + public static function getCandidates($type) + { + $returnData = []; + $bindings = self::getPuliDiscovery()->findBindings($type); + + foreach ($bindings as $binding) { + $condition = true; + if ($binding->hasParameterValue('depends')) { + $condition = $binding->getParameterValue('depends'); + } + $returnData[] = ['class' => $binding->getClassName(), 'condition' => $condition]; + } + + return $returnData; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/StreamFactoryDiscovery.php b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/StreamFactoryDiscovery.php new file mode 100644 index 0000000..7bcc8ce --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/StreamFactoryDiscovery.php @@ -0,0 +1,36 @@ +<?php + +namespace Http\Discovery; + +use Http\Discovery\Exception\DiscoveryFailedException; +use Http\Message\StreamFactory; + +/** + * Finds a Stream Factory. + * + * @author Михаил Красильников <m.krasilnikov@yandex.ru> + */ +final class StreamFactoryDiscovery extends ClassDiscovery +{ + /** + * Finds a Stream Factory. + * + * @return StreamFactory + * + * @throws Exception\NotFoundException + */ + public static function find() + { + try { + $streamFactory = static::findOneByType(StreamFactory::class); + } catch (DiscoveryFailedException $e) { + throw new NotFoundException( + 'No stream factories found. To use Guzzle, Diactoros or Slim Framework factories install php-http/message and the chosen message implementation.', + 0, + $e + ); + } + + return static::instantiateClass($streamFactory); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/UriFactoryDiscovery.php b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/UriFactoryDiscovery.php new file mode 100644 index 0000000..1eef1e6 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/discovery/src/UriFactoryDiscovery.php @@ -0,0 +1,36 @@ +<?php + +namespace Http\Discovery; + +use Http\Discovery\Exception\DiscoveryFailedException; +use Http\Message\UriFactory; + +/** + * Finds a URI Factory. + * + * @author David de Boer <david@ddeboer.nl> + */ +final class UriFactoryDiscovery extends ClassDiscovery +{ + /** + * Finds a URI Factory. + * + * @return UriFactory + * + * @throws Exception\NotFoundException + */ + public static function find() + { + try { + $uriFactory = static::findOneByType(UriFactory::class); + } catch (DiscoveryFailedException $e) { + throw new NotFoundException( + 'No uri factories found. To use Guzzle, Diactoros or Slim Framework factories install php-http/message and the chosen message implementation.', + 0, + $e + ); + } + + return static::instantiateClass($uriFactory); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/CHANGELOG.md b/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/CHANGELOG.md new file mode 100644 index 0000000..8478966 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/CHANGELOG.md @@ -0,0 +1,72 @@ +# Change Log + +## 1.1.0 - 2016-08-31 + +- Added HttpFulfilledPromise and HttpRejectedPromise which respect the HttpAsyncClient interface + +## 1.0.0 - 2016-01-26 + +### Removed + +- Stability configuration from composer + + +## 1.0.0-RC1 - 2016-01-12 + +### Changed + +- Updated package files +- Updated promise dependency to RC1 + + +## 1.0.0-beta - 2015-12-17 + +### Added + +- Puli configuration and binding types + +### Changed + +- Exception concept + + +## 1.0.0-alpha3 - 2015-12-13 + +### Changed + +- Async client does not throw exceptions + +### Removed + +- Promise interface moved to its own repository: [php-http/promise](https://github.com/php-http/promise) + + +## 1.0.0-alpha2 - 2015-11-16 + +### Added + +- Async client and Promise interface + + +## 1.0.0-alpha - 2015-10-26 + +### Added + +- Better domain exceptions. + +### Changed + +- Purpose of the library: general HTTP CLient abstraction. + +### Removed + +- Request options: they should be configured at construction time. +- Multiple request sending: should be done asynchronously using Async Client. +- `getName` method + + +## 0.1.0 - 2015-06-03 + +### Added + +- Initial release diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/LICENSE b/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/LICENSE new file mode 100644 index 0000000..48741e4 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2014-2015 Eric GELOEN <geloen.eric@gmail.com> +Copyright (c) 2015-2016 PHP HTTP Team <team@php-http.org> + +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/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/README.md b/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/README.md new file mode 100644 index 0000000..f46212b --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/README.md @@ -0,0 +1,57 @@ +# HTTPlug + +[![Latest Version](https://img.shields.io/github/release/php-http/httplug.svg?style=flat-square)](https://github.com/php-http/httplug/releases) +[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) +[![Build Status](https://img.shields.io/travis/php-http/httplug.svg?style=flat-square)](https://travis-ci.org/php-http/httplug) +[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/php-http/httplug.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/httplug) +[![Quality Score](https://img.shields.io/scrutinizer/g/php-http/httplug.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/httplug) +[![Total Downloads](https://img.shields.io/packagist/dt/php-http/httplug.svg?style=flat-square)](https://packagist.org/packages/php-http/httplug) + +[![Slack Status](http://slack.httplug.io/badge.svg)](http://slack.httplug.io) +[![Email](https://img.shields.io/badge/email-team@httplug.io-blue.svg?style=flat-square)](mailto:team@httplug.io) + +**HTTPlug, the HTTP client abstraction for PHP.** + + +## Install + +Via Composer + +``` bash +$ composer require php-http/httplug +``` + + +## Intro + +This is the contract package for HTTP Client. +Use it to create HTTP Clients which are interoperable and compatible with [PSR-7](http://www.php-fig.org/psr/psr-7/). + +This library is the official successor of the [ivory http adapter](https://github.com/egeloen/ivory-http-adapter). + + +## Documentation + +Please see the [official documentation](http://docs.php-http.org). + + +## Testing + +``` bash +$ composer test +``` + + +## Contributing + +Please see our [contributing guide](http://docs.php-http.org/en/latest/development/contributing.html). + + +## Security + +If you discover any security related issues, please contact us at [security@php-http.org](mailto:security@php-http.org). + + +## License + +The MIT License (MIT). Please see [License File](LICENSE) for more information. diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/composer.json b/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/composer.json new file mode 100644 index 0000000..f74c4d3 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/composer.json @@ -0,0 +1,40 @@ +{ + "name": "php-http/httplug", + "description": "HTTPlug, the HTTP client abstraction for PHP", + "license": "MIT", + "keywords": ["http", "client"], + "homepage": "http://httplug.io", + "authors": [ + { + "name": "Eric GELOEN", + "email": "geloen.eric@gmail.com" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "require": { + "php": ">=5.4", + "psr/http-message": "^1.0", + "php-http/promise": "^1.0" + }, + "require-dev": { + "phpspec/phpspec": "^2.4", + "henrikbjorn/phpspec-code-coverage" : "^1.0" + }, + "autoload": { + "psr-4": { + "Http\\Client\\": "src/" + } + }, + "scripts": { + "test": "vendor/bin/phpspec run", + "test-ci": "vendor/bin/phpspec run -c phpspec.ci.yml" + }, + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/puli.json b/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/puli.json new file mode 100644 index 0000000..4168331 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/puli.json @@ -0,0 +1,12 @@ +{ + "version": "1.0", + "name": "php-http/httplug", + "binding-types": { + "Http\\Client\\HttpAsyncClient": { + "description": "Async HTTP Client" + }, + "Http\\Client\\HttpClient": { + "description": "HTTP Client" + } + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/src/Exception.php b/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/src/Exception.php new file mode 100644 index 0000000..e7382c3 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/src/Exception.php @@ -0,0 +1,12 @@ +<?php + +namespace Http\Client; + +/** + * Every HTTP Client related Exception must implement this interface. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +interface Exception +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/src/Exception/HttpException.php b/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/src/Exception/HttpException.php new file mode 100644 index 0000000..f4f32a4 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/src/Exception/HttpException.php @@ -0,0 +1,74 @@ +<?php + +namespace Http\Client\Exception; + +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; + +/** + * Thrown when a response was received but the request itself failed. + * + * In addition to the request, this exception always provides access to the response object. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +class HttpException extends RequestException +{ + /** + * @var ResponseInterface + */ + protected $response; + + /** + * @param string $message + * @param RequestInterface $request + * @param ResponseInterface $response + * @param \Exception|null $previous + */ + public function __construct( + $message, + RequestInterface $request, + ResponseInterface $response, + \Exception $previous = null + ) { + parent::__construct($message, $request, $previous); + + $this->response = $response; + $this->code = $response->getStatusCode(); + } + + /** + * Returns the response. + * + * @return ResponseInterface + */ + public function getResponse() + { + return $this->response; + } + + /** + * Factory method to create a new exception with a normalized error message. + * + * @param RequestInterface $request + * @param ResponseInterface $response + * @param \Exception|null $previous + * + * @return HttpException + */ + public static function create( + RequestInterface $request, + ResponseInterface $response, + \Exception $previous = null + ) { + $message = sprintf( + '[url] %s [http method] %s [status code] %s [reason phrase] %s', + $request->getRequestTarget(), + $request->getMethod(), + $response->getStatusCode(), + $response->getReasonPhrase() + ); + + return new self($message, $request, $response, $previous); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/src/Exception/NetworkException.php b/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/src/Exception/NetworkException.php new file mode 100644 index 0000000..f2198e5 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/src/Exception/NetworkException.php @@ -0,0 +1,14 @@ +<?php + +namespace Http\Client\Exception; + +/** + * Thrown when the request cannot be completed because of network issues. + * + * There is no response object as this exception is thrown when no response has been received. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +class NetworkException extends RequestException +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/src/Exception/RequestException.php b/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/src/Exception/RequestException.php new file mode 100644 index 0000000..cdce14b --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/src/Exception/RequestException.php @@ -0,0 +1,43 @@ +<?php + +namespace Http\Client\Exception; + +use Psr\Http\Message\RequestInterface; + +/** + * Exception for when a request failed, providing access to the failed request. + * + * This could be due to an invalid request, or one of the extending exceptions + * for network errors or HTTP error responses. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +class RequestException extends TransferException +{ + /** + * @var RequestInterface + */ + private $request; + + /** + * @param string $message + * @param RequestInterface $request + * @param \Exception|null $previous + */ + public function __construct($message, RequestInterface $request, \Exception $previous = null) + { + $this->request = $request; + + parent::__construct($message, 0, $previous); + } + + /** + * Returns the request. + * + * @return RequestInterface + */ + public function getRequest() + { + return $this->request; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/src/Exception/TransferException.php b/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/src/Exception/TransferException.php new file mode 100644 index 0000000..a858cf5 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/src/Exception/TransferException.php @@ -0,0 +1,14 @@ +<?php + +namespace Http\Client\Exception; + +use Http\Client\Exception; + +/** + * Base exception for transfer related exceptions. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +class TransferException extends \RuntimeException implements Exception +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/src/HttpAsyncClient.php b/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/src/HttpAsyncClient.php new file mode 100644 index 0000000..492e511 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/src/HttpAsyncClient.php @@ -0,0 +1,27 @@ +<?php + +namespace Http\Client; + +use Http\Promise\Promise; +use Psr\Http\Message\RequestInterface; + +/** + * Sends a PSR-7 Request in an asynchronous way by returning a Promise. + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +interface HttpAsyncClient +{ + /** + * Sends a PSR-7 request in an asynchronous way. + * + * Exceptions related to processing the request are available from the returned Promise. + * + * @param RequestInterface $request + * + * @return Promise Resolves a PSR-7 Response or fails with an Http\Client\Exception. + * + * @throws \Exception If processing the request is impossible (eg. bad configuration). + */ + public function sendAsyncRequest(RequestInterface $request); +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/src/HttpClient.php b/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/src/HttpClient.php new file mode 100644 index 0000000..0e51749 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/src/HttpClient.php @@ -0,0 +1,28 @@ +<?php + +namespace Http\Client; + +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; + +/** + * Sends a PSR-7 Request and returns a PSR-7 response. + * + * @author GeLo <geloen.eric@gmail.com> + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + * @author David Buchmann <mail@davidbu.ch> + */ +interface HttpClient +{ + /** + * Sends a PSR-7 request. + * + * @param RequestInterface $request + * + * @return ResponseInterface + * + * @throws \Http\Client\Exception If an error happens during processing the request. + * @throws \Exception If processing the request is impossible (eg. bad configuration). + */ + public function sendRequest(RequestInterface $request); +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/src/Promise/HttpFulfilledPromise.php b/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/src/Promise/HttpFulfilledPromise.php new file mode 100644 index 0000000..6779e44 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/src/Promise/HttpFulfilledPromise.php @@ -0,0 +1,57 @@ +<?php + +namespace Http\Client\Promise; + +use Http\Client\Exception; +use Http\Promise\Promise; +use Psr\Http\Message\ResponseInterface; + +final class HttpFulfilledPromise implements Promise +{ + /** + * @var ResponseInterface + */ + private $response; + + /** + * @param ResponseInterface $response + */ + public function __construct(ResponseInterface $response) + { + $this->response = $response; + } + + /** + * {@inheritdoc} + */ + public function then(callable $onFulfilled = null, callable $onRejected = null) + { + if (null === $onFulfilled) { + return $this; + } + + try { + return new self($onFulfilled($this->response)); + } catch (Exception $e) { + return new HttpRejectedPromise($e); + } + } + + /** + * {@inheritdoc} + */ + public function getState() + { + return Promise::FULFILLED; + } + + /** + * {@inheritdoc} + */ + public function wait($unwrap = true) + { + if ($unwrap) { + return $this->response; + } + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/src/Promise/HttpRejectedPromise.php b/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/src/Promise/HttpRejectedPromise.php new file mode 100644 index 0000000..bfb0738 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/httplug/src/Promise/HttpRejectedPromise.php @@ -0,0 +1,56 @@ +<?php + +namespace Http\Client\Promise; + +use Http\Client\Exception; +use Http\Promise\Promise; + +final class HttpRejectedPromise implements Promise +{ + /** + * @var Exception + */ + private $exception; + + /** + * @param Exception $exception + */ + public function __construct(Exception $exception) + { + $this->exception = $exception; + } + + /** + * {@inheritdoc} + */ + public function then(callable $onFulfilled = null, callable $onRejected = null) + { + if (null === $onRejected) { + return $this; + } + + try { + return new HttpFulfilledPromise($onRejected($this->exception)); + } catch (Exception $e) { + return new self($e); + } + } + + /** + * {@inheritdoc} + */ + public function getState() + { + return Promise::REJECTED; + } + + /** + * {@inheritdoc} + */ + public function wait($unwrap = true) + { + if ($unwrap) { + throw $this->exception; + } + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message-factory/CHANGELOG.md b/Postman/Postman-Mail/mailgun/vendor/php-http/message-factory/CHANGELOG.md new file mode 100644 index 0000000..4711924 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message-factory/CHANGELOG.md @@ -0,0 +1,65 @@ +# Change Log + + +## 1.0.2 - 2015-12-19 + +### Added + +- Request and Response factory binding types to Puli + + +## 1.0.1 - 2015-12-17 + +### Added + +- Puli configuration and binding types + + +## 1.0.0 - 2015-12-15 + +### Added + +- Response Factory in order to be reused in Message and Server Message factories +- Request Factory + +### Changed + +- Message Factory extends Request and Response factories + + +## 1.0.0-RC1 - 2015-12-14 + +### Added + +- CS check + +### Changed + +- RuntimeException is thrown when the StreamFactory cannot write to the underlying stream + + +## 0.3.0 - 2015-11-16 + +### Removed + +- Client Context Factory +- Factory Awares and Templates + + +## 0.2.0 - 2015-11-16 + +### Changed + +- Reordered the parameters when creating a message to have the protocol last, +as its the least likely to need to be changed. + + +## 0.1.0 - 2015-06-01 + +### Added + +- Initial release + +### Changed + +- Helpers are renamed to templates diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message-factory/LICENSE b/Postman/Postman-Mail/mailgun/vendor/php-http/message-factory/LICENSE new file mode 100644 index 0000000..8e2c4a0 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message-factory/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2015 PHP HTTP Team <team@php-http.org> + +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/Postman/Postman-Mail/mailgun/vendor/php-http/message-factory/README.md b/Postman/Postman-Mail/mailgun/vendor/php-http/message-factory/README.md new file mode 100644 index 0000000..4654495 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message-factory/README.md @@ -0,0 +1,36 @@ +# PSR-7 Message Factory + +[![Latest Version](https://img.shields.io/github/release/php-http/message-factory.svg?style=flat-square)](https://github.com/php-http/message-factory/releases) +[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) +[![Total Downloads](https://img.shields.io/packagist/dt/php-http/message-factory.svg?style=flat-square)](https://packagist.org/packages/php-http/message-factory) + +**Factory interfaces for PSR-7 HTTP Message.** + + +## Install + +Via Composer + +``` bash +$ composer require php-http/message-factory +``` + + +## Documentation + +Please see the [official documentation](http://php-http.readthedocs.org/en/latest/message-factory/). + + +## Contributing + +Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details. + + +## Security + +If you discover any security related issues, please contact us at [security@php-http.org](mailto:security@php-http.org). + + +## License + +The MIT License (MIT). Please see [License File](LICENSE) for more information. diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message-factory/composer.json b/Postman/Postman-Mail/mailgun/vendor/php-http/message-factory/composer.json new file mode 100644 index 0000000..7c72feb --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message-factory/composer.json @@ -0,0 +1,27 @@ +{ + "name": "php-http/message-factory", + "description": "Factory interfaces for PSR-7 HTTP Message", + "license": "MIT", + "keywords": ["http", "factory", "message", "stream", "uri"], + "homepage": "http://php-http.org", + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "require": { + "php": ">=5.4", + "psr/http-message": "^1.0" + }, + "autoload": { + "psr-4": { + "Http\\Message\\": "src/" + } + }, + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message-factory/puli.json b/Postman/Postman-Mail/mailgun/vendor/php-http/message-factory/puli.json new file mode 100644 index 0000000..08d3762 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message-factory/puli.json @@ -0,0 +1,43 @@ +{ + "version": "1.0", + "binding-types": { + "Http\\Message\\MessageFactory": { + "description": "PSR-7 Message Factory", + "parameters": { + "depends": { + "description": "Optional class dependency which can be checked by consumers" + } + } + }, + "Http\\Message\\RequestFactory": { + "parameters": { + "depends": { + "description": "Optional class dependency which can be checked by consumers" + } + } + }, + "Http\\Message\\ResponseFactory": { + "parameters": { + "depends": { + "description": "Optional class dependency which can be checked by consumers" + } + } + }, + "Http\\Message\\StreamFactory": { + "description": "PSR-7 Stream Factory", + "parameters": { + "depends": { + "description": "Optional class dependency which can be checked by consumers" + } + } + }, + "Http\\Message\\UriFactory": { + "description": "PSR-7 URI Factory", + "parameters": { + "depends": { + "description": "Optional class dependency which can be checked by consumers" + } + } + } + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message-factory/src/MessageFactory.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message-factory/src/MessageFactory.php new file mode 100644 index 0000000..965aaa8 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message-factory/src/MessageFactory.php @@ -0,0 +1,12 @@ +<?php + +namespace Http\Message; + +/** + * Factory for PSR-7 Request and Response. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +interface MessageFactory extends RequestFactory, ResponseFactory +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message-factory/src/RequestFactory.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message-factory/src/RequestFactory.php new file mode 100644 index 0000000..624e82f --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message-factory/src/RequestFactory.php @@ -0,0 +1,34 @@ +<?php + +namespace Http\Message; + +use Psr\Http\Message\UriInterface; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\StreamInterface; + +/** + * Factory for PSR-7 Request. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +interface RequestFactory +{ + /** + * Creates a new PSR-7 request. + * + * @param string $method + * @param string|UriInterface $uri + * @param array $headers + * @param resource|string|StreamInterface|null $body + * @param string $protocolVersion + * + * @return RequestInterface + */ + public function createRequest( + $method, + $uri, + array $headers = [], + $body = null, + $protocolVersion = '1.1' + ); +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message-factory/src/ResponseFactory.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message-factory/src/ResponseFactory.php new file mode 100644 index 0000000..2411ed3 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message-factory/src/ResponseFactory.php @@ -0,0 +1,35 @@ +<?php + +namespace Http\Message; + +use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\StreamInterface; + +/** + * Factory for PSR-7 Response. + * + * This factory contract can be reused in Message and Server Message factories. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +interface ResponseFactory +{ + /** + * Creates a new PSR-7 response. + * + * @param int $statusCode + * @param string|null $reasonPhrase + * @param array $headers + * @param resource|string|StreamInterface|null $body + * @param string $protocolVersion + * + * @return ResponseInterface + */ + public function createResponse( + $statusCode = 200, + $reasonPhrase = null, + array $headers = [], + $body = null, + $protocolVersion = '1.1' + ); +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message-factory/src/StreamFactory.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message-factory/src/StreamFactory.php new file mode 100644 index 0000000..327a902 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message-factory/src/StreamFactory.php @@ -0,0 +1,25 @@ +<?php + +namespace Http\Message; + +use Psr\Http\Message\StreamInterface; + +/** + * Factory for PSR-7 Stream. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +interface StreamFactory +{ + /** + * Creates a new PSR-7 stream. + * + * @param string|resource|StreamInterface|null $body + * + * @return StreamInterface + * + * @throws \InvalidArgumentException If the stream body is invalid. + * @throws \RuntimeException If creating the stream from $body fails. + */ + public function createStream($body = null); +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message-factory/src/UriFactory.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message-factory/src/UriFactory.php new file mode 100644 index 0000000..f05e625 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message-factory/src/UriFactory.php @@ -0,0 +1,24 @@ +<?php + +namespace Http\Message; + +use Psr\Http\Message\UriInterface; + +/** + * Factory for PSR-7 URI. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +interface UriFactory +{ + /** + * Creates an PSR-7 URI. + * + * @param string|UriInterface $uri + * + * @return UriInterface + * + * @throws \InvalidArgumentException If the $uri argument can not be converted into a valid URI. + */ + public function createUri($uri); +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/CHANGELOG.md b/Postman/Postman-Mail/mailgun/vendor/php-http/message/CHANGELOG.md new file mode 100644 index 0000000..7676349 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/CHANGELOG.md @@ -0,0 +1,139 @@ +# Change Log + + +## 1.6.0 - 2017-07-05 + +### Added + +- CookieUtil::parseDate to create a date from cookie date string + +### Fixed + +- Fix curl command of CurlFormatter when there is an user-agent header + +## 1.5.0 - 2017-02-14 + +### Added + +- Check for empty string in Stream factories +- Cookie::createWithoutValidation Static constructor to create a cookie. Will not perform any attribute validation during instantiation. +- Cookie::isValid Method to check if cookie attributes are valid. + +### Fixed + +- FilteredStream::getSize returns null because the contents size is unknown. +- Stream factories does not rewinds streams. The previous behavior was not coherent between factories and inputs. + +### Deprecated + +- FilteredStream::getReadFilter The read filter is internal and should never be used by consuming code. +- FilteredStream::getWriteFilter We did not implement writing to the streams at all. And if we do, the filter is an internal information and should not be used by consuming code. + + +## 1.4.1 - 2016-12-16 + +### Fixed + +- Cookie::matchPath Cookie with root path (`/`) will not match sub path (e.g. `/cookie`). + + +## 1.4.0 - 2016-10-20 + +### Added + +- Message, stream and URI factories for [Slim Framework](https://github.com/slimphp/Slim) +- BufferedStream that allow you to decorate a non-seekable stream with a seekable one. +- cUrlFormatter to be able to redo the request with a cURL command + + +## 1.3.1 - 2016-07-15 + +### Fixed + +- FullHttpMessageFormatter will not read from streams that you cannot rewind (non-seekable) +- FullHttpMessageFormatter will not read from the stream if $maxBodyLength is zero +- FullHttpMessageFormatter rewinds streams after they are read + + +## 1.3.0 - 2016-07-14 + +### Added + +- FullHttpMessageFormatter to include headers and body in the formatted message + +### Fixed + +- #41: Response builder broke header value + + +## 1.2.0 - 2016-03-29 + +### Added + +- The RequestMatcher is built after the Symfony RequestMatcher and separates + scheme, host and path expressions and provides an option to filter on the + method +- New RequestConditional authentication method using request matchers +- Add automatic basic auth info detection based on the URL + +### Changed + +- Improved ResponseBuilder + +### Deprecated + +- RegexRequestMatcher, use RequestMatcher instead +- Matching authenitcation method, use RequestConditional instead + + +## 1.1.0 - 2016-02-25 + +### Added + + - Add a request matcher interface and regex implementation + - Add a callback request matcher implementation + - Add a ResponseBuilder, to create PSR7 Response from a string + +### Fixed + + - Fix casting string on a FilteredStream not filtering the output + + +## 1.0.0 - 2016-01-27 + + +## 0.2.0 - 2015-12-29 + +### Added + +- Autoregistration of stream filters using Composer autoload +- Cookie +- [Apigen](http://www.apigen.org/) configuration + + +## 0.1.2 - 2015-12-26 + +### Added + +- Request and response factory bindings + +### Fixed + +- Chunk filter namespace in Dechunk stream + + +## 0.1.1 - 2015-12-25 + +### Added + +- Formatter + + +## 0.1.0 - 2015-12-24 + +### Added + +- Authentication +- Encoding +- Message decorator +- Message factory (Guzzle, Diactoros) diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/LICENSE b/Postman/Postman-Mail/mailgun/vendor/php-http/message/LICENSE new file mode 100644 index 0000000..4558d6f --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2015-2016 PHP HTTP Team <team@php-http.org> + +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/Postman/Postman-Mail/mailgun/vendor/php-http/message/README.md b/Postman/Postman-Mail/mailgun/vendor/php-http/message/README.md new file mode 100644 index 0000000..338b415 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/README.md @@ -0,0 +1,61 @@ +# HTTP Message + +[![Latest Version](https://img.shields.io/github/release/php-http/message.svg?style=flat-square)](https://github.com/php-http/message/releases) +[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) +[![Build Status](https://img.shields.io/travis/php-http/message.svg?style=flat-square)](https://travis-ci.org/php-http/message) +[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/php-http/message.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/message) +[![Quality Score](https://img.shields.io/scrutinizer/g/php-http/message.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/message) +[![Total Downloads](https://img.shields.io/packagist/dt/php-http/message.svg?style=flat-square)](https://packagist.org/packages/php-http/message) + +**HTTP Message related tools.** + + +## Install + +Via Composer + +``` bash +$ composer require php-http/message +``` + + +## Intro + +This package contains various PSR-7 tools which might be useful in an HTTP workflow: + +- Authentication method implementations +- Various Stream encoding tools +- Message decorators +- Message factory implementations for Guzzle PSR-7 and Diactoros +- Cookie implementation +- Request matchers + + +## Documentation + +Please see the [official documentation](http://docs.php-http.org/en/latest/message.html). + + +## Testing + +``` bash +$ composer test +``` + + +## Contributing + +Please see our [contributing guide](http://docs.php-http.org/en/latest/development/contributing.html). + +## Cretids + +Thanks to [Cuzzle](https://github.com/namshi/cuzzle) for inpiration for the `CurlCommandFormatter`. + +## Security + +If you discover any security related issues, please contact us at [security@php-http.org](mailto:security@php-http.org). + + +## License + +The MIT License (MIT). Please see [License File](LICENSE) for more information. diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/apigen.neon b/Postman/Postman-Mail/mailgun/vendor/php-http/message/apigen.neon new file mode 100644 index 0000000..0ba1a18 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/apigen.neon @@ -0,0 +1,6 @@ +source: + - src/ + +destination: build/api/ + +templateTheme: bootstrap diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/composer.json b/Postman/Postman-Mail/mailgun/vendor/php-http/message/composer.json new file mode 100644 index 0000000..6fbc5db --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/composer.json @@ -0,0 +1,60 @@ +{ + "name": "php-http/message", + "description": "HTTP Message related tools", + "license": "MIT", + "keywords": ["message", "http", "psr-7"], + "homepage": "http://php-http.org", + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "require": { + "php": ">=5.4", + "psr/http-message": "^1.0", + "php-http/message-factory": "^1.0.2", + "clue/stream-filter": "^1.3" + }, + "provide": { + "php-http/message-factory-implementation": "1.0" + }, + "require-dev": { + "zendframework/zend-diactoros": "^1.0", + "guzzlehttp/psr7": "^1.0", + "ext-zlib": "*", + "phpspec/phpspec": "^2.4", + "henrikbjorn/phpspec-code-coverage" : "^1.0", + "coduo/phpspec-data-provider-extension": "^1.0", + "akeneo/phpspec-skip-example-extension": "^1.0", + "slim/slim": "^3.0" + }, + "suggest": { + "zendframework/zend-diactoros": "Used with Diactoros Factories", + "guzzlehttp/psr7": "Used with Guzzle PSR-7 Factories", + "slim/slim": "Used with Slim Framework PSR-7 implementation", + "ext-zlib": "Used with compressor/decompressor streams" + }, + "autoload": { + "psr-4": { + "Http\\Message\\": "src/" + }, + "files": [ + "src/filters.php" + ] + }, + "autoload-dev": { + "psr-4": { + "spec\\Http\\Message\\": "spec/" + } + }, + "scripts": { + "test": "vendor/bin/phpspec run", + "test-ci": "vendor/bin/phpspec run -c phpspec.ci.yml" + }, + "extra": { + "branch-alias": { + "dev-master": "1.6-dev" + } + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/puli.json b/Postman/Postman-Mail/mailgun/vendor/php-http/message/puli.json new file mode 100644 index 0000000..024a85d --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/puli.json @@ -0,0 +1,111 @@ +{ + "version": "1.0", + "name": "php-http/message", + "bindings": { + "064d003d-78a1-48c4-8f3b-1f92ff25da69": { + "_class": "Puli\\Discovery\\Binding\\ClassBinding", + "class": "Http\\Message\\MessageFactory\\DiactorosMessageFactory", + "type": "Http\\Message\\MessageFactory", + "parameters": { + "depends": "Zend\\Diactoros\\Request" + } + }, + "0836751e-6558-4d1b-8993-4a52012947c3": { + "_class": "Puli\\Discovery\\Binding\\ClassBinding", + "class": "Http\\Message\\MessageFactory\\SlimMessageFactory", + "type": "Http\\Message\\ResponseFactory" + }, + "1d127622-dc61-4bfa-b9da-d221548d72c3": { + "_class": "Puli\\Discovery\\Binding\\ClassBinding", + "class": "Http\\Message\\MessageFactory\\SlimMessageFactory", + "type": "Http\\Message\\RequestFactory" + }, + "2438c2d0-0658-441f-8855-ddaf0f87d54d": { + "_class": "Puli\\Discovery\\Binding\\ClassBinding", + "class": "Http\\Message\\MessageFactory\\GuzzleMessageFactory", + "type": "Http\\Message\\MessageFactory", + "parameters": { + "depends": "GuzzleHttp\\Psr7\\Request" + } + }, + "253aa08c-d705-46e7-b1d2-e28c97eef792": { + "_class": "Puli\\Discovery\\Binding\\ClassBinding", + "class": "Http\\Message\\MessageFactory\\GuzzleMessageFactory", + "type": "Http\\Message\\RequestFactory", + "parameters": { + "depends": "GuzzleHttp\\Psr7\\Request" + } + }, + "273a34f9-62f4-4ba1-9801-b1284d49ff89": { + "_class": "Puli\\Discovery\\Binding\\ClassBinding", + "class": "Http\\Message\\StreamFactory\\GuzzleStreamFactory", + "type": "Http\\Message\\StreamFactory", + "parameters": { + "depends": "GuzzleHttp\\Psr7\\Stream" + } + }, + "304b83db-b594-4d83-ae75-1f633adf92f7": { + "_class": "Puli\\Discovery\\Binding\\ClassBinding", + "class": "Http\\Message\\UriFactory\\GuzzleUriFactory", + "type": "Http\\Message\\UriFactory", + "parameters": { + "depends": "GuzzleHttp\\Psr7\\Uri" + } + }, + "3f4bc1cd-aa95-4702-9fa7-65408e471691": { + "_class": "Puli\\Discovery\\Binding\\ClassBinding", + "class": "Http\\Message\\UriFactory\\DiactorosUriFactory", + "type": "Http\\Message\\UriFactory", + "parameters": { + "depends": "Zend\\Diactoros\\Uri" + } + }, + "4672a6ee-ad9e-4109-a5d1-b7d46f26c7a1": { + "_class": "Puli\\Discovery\\Binding\\ClassBinding", + "class": "Http\\Message\\MessageFactory\\SlimMessageFactory", + "type": "Http\\Message\\MessageFactory" + }, + "6234e947-d3bd-43eb-97d5-7f9e22e6bb1b": { + "_class": "Puli\\Discovery\\Binding\\ClassBinding", + "class": "Http\\Message\\MessageFactory\\DiactorosMessageFactory", + "type": "Http\\Message\\ResponseFactory", + "parameters": { + "depends": "Zend\\Diactoros\\Response" + } + }, + "6a9ad6ce-d82c-470f-8e30-60f21d9d95bf": { + "_class": "Puli\\Discovery\\Binding\\ClassBinding", + "class": "Http\\Message\\UriFactory\\SlimUriFactory", + "type": "Http\\Message\\UriFactory" + }, + "72c2afa0-ea56-4d03-adb6-a9f241a8a734": { + "_class": "Puli\\Discovery\\Binding\\ClassBinding", + "class": "Http\\Message\\StreamFactory\\SlimStreamFactory", + "type": "Http\\Message\\StreamFactory" + }, + "95c1be8f-39fe-4abd-8351-92cb14379a75": { + "_class": "Puli\\Discovery\\Binding\\ClassBinding", + "class": "Http\\Message\\StreamFactory\\DiactorosStreamFactory", + "type": "Http\\Message\\StreamFactory", + "parameters": { + "depends": "Zend\\Diactoros\\Stream" + } + }, + "a018af27-7590-4dcf-83a1-497f95604cd6": { + "_class": "Puli\\Discovery\\Binding\\ClassBinding", + "class": "Http\\Message\\MessageFactory\\GuzzleMessageFactory", + "type": "Http\\Message\\ResponseFactory", + "parameters": { + "depends": "GuzzleHttp\\Psr7\\Response" + } + }, + "c07955b1-de46-43db-923b-d07fae9382cb": { + "_class": "Puli\\Discovery\\Binding\\ClassBinding", + "class": "Http\\Message\\MessageFactory\\DiactorosMessageFactory", + "type": "Http\\Message\\RequestFactory", + "parameters": { + "depends": "Zend\\Diactoros\\Request" + } + } + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Authentication.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Authentication.php new file mode 100644 index 0000000..b50366f --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Authentication.php @@ -0,0 +1,22 @@ +<?php + +namespace Http\Message; + +use Psr\Http\Message\RequestInterface; + +/** + * Authenticate a PSR-7 Request. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +interface Authentication +{ + /** + * Authenticates a request. + * + * @param RequestInterface $request + * + * @return RequestInterface + */ + public function authenticate(RequestInterface $request); +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Authentication/AutoBasicAuth.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Authentication/AutoBasicAuth.php new file mode 100644 index 0000000..7b6a429 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Authentication/AutoBasicAuth.php @@ -0,0 +1,48 @@ +<?php + +namespace Http\Message\Authentication; + +use Http\Message\Authentication; +use Psr\Http\Message\RequestInterface; + +/** + * Authenticate a PSR-7 Request using Basic Auth based on credentials in the URI. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +final class AutoBasicAuth implements Authentication +{ + /** + * Whether user info should be removed from the URI. + * + * @var bool + */ + private $shouldRemoveUserInfo; + + /** + * @param bool|true $shouldRremoveUserInfo + */ + public function __construct($shouldRremoveUserInfo = true) + { + $this->shouldRemoveUserInfo = (bool) $shouldRremoveUserInfo; + } + + /** + * {@inheritdoc} + */ + public function authenticate(RequestInterface $request) + { + $uri = $request->getUri(); + $userInfo = $uri->getUserInfo(); + + if (!empty($userInfo)) { + if ($this->shouldRemoveUserInfo) { + $request = $request->withUri($uri->withUserInfo('')); + } + + $request = $request->withHeader('Authorization', sprintf('Basic %s', base64_encode($userInfo))); + } + + return $request; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Authentication/BasicAuth.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Authentication/BasicAuth.php new file mode 100644 index 0000000..23618a5 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Authentication/BasicAuth.php @@ -0,0 +1,44 @@ +<?php + +namespace Http\Message\Authentication; + +use Http\Message\Authentication; +use Psr\Http\Message\RequestInterface; + +/** + * Authenticate a PSR-7 Request using Basic Auth. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +final class BasicAuth implements Authentication +{ + /** + * @var string + */ + private $username; + + /** + * @var string + */ + private $password; + + /** + * @param string $username + * @param string $password + */ + public function __construct($username, $password) + { + $this->username = $username; + $this->password = $password; + } + + /** + * {@inheritdoc} + */ + public function authenticate(RequestInterface $request) + { + $header = sprintf('Basic %s', base64_encode(sprintf('%s:%s', $this->username, $this->password))); + + return $request->withHeader('Authorization', $header); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Authentication/Bearer.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Authentication/Bearer.php new file mode 100644 index 0000000..a8fb21a --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Authentication/Bearer.php @@ -0,0 +1,37 @@ +<?php + +namespace Http\Message\Authentication; + +use Http\Message\Authentication; +use Psr\Http\Message\RequestInterface; + +/** + * Authenticate a PSR-7 Request using a token. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +final class Bearer implements Authentication +{ + /** + * @var string + */ + private $token; + + /** + * @param string $token + */ + public function __construct($token) + { + $this->token = $token; + } + + /** + * {@inheritdoc} + */ + public function authenticate(RequestInterface $request) + { + $header = sprintf('Bearer %s', $this->token); + + return $request->withHeader('Authorization', $header); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Authentication/Chain.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Authentication/Chain.php new file mode 100644 index 0000000..71002bb --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Authentication/Chain.php @@ -0,0 +1,47 @@ +<?php + +namespace Http\Message\Authentication; + +use Http\Message\Authentication; +use Psr\Http\Message\RequestInterface; + +/** + * Authenticate a PSR-7 Request with a multiple authentication methods. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +final class Chain implements Authentication +{ + /** + * @var Authentication[] + */ + private $authenticationChain = []; + + /** + * @param Authentication[] $authenticationChain + */ + public function __construct(array $authenticationChain = []) + { + foreach ($authenticationChain as $authentication) { + if (!$authentication instanceof Authentication) { + throw new \InvalidArgumentException( + 'Members of the authentication chain must be of type Http\Message\Authentication' + ); + } + } + + $this->authenticationChain = $authenticationChain; + } + + /** + * {@inheritdoc} + */ + public function authenticate(RequestInterface $request) + { + foreach ($this->authenticationChain as $authentication) { + $request = $authentication->authenticate($request); + } + + return $request; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Authentication/Matching.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Authentication/Matching.php new file mode 100644 index 0000000..4b89b50 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Authentication/Matching.php @@ -0,0 +1,74 @@ +<?php + +namespace Http\Message\Authentication; + +use Http\Message\Authentication; +use Http\Message\RequestMatcher\CallbackRequestMatcher; +use Psr\Http\Message\RequestInterface; + +@trigger_error('The '.__NAMESPACE__.'\Matching class is deprecated since version 1.2 and will be removed in 2.0. Use Http\Message\Authentication\RequestConditional instead.', E_USER_DEPRECATED); + +/** + * Authenticate a PSR-7 Request if the request is matching. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + * + * @deprecated since since version 1.2, and will be removed in 2.0. Use {@link RequestConditional} instead. + */ +final class Matching implements Authentication +{ + /** + * @var Authentication + */ + private $authentication; + + /** + * @var CallbackRequestMatcher + */ + private $matcher; + + /** + * @param Authentication $authentication + * @param callable|null $matcher + */ + public function __construct(Authentication $authentication, callable $matcher = null) + { + if (is_null($matcher)) { + $matcher = function () { + return true; + }; + } + + $this->authentication = $authentication; + $this->matcher = new CallbackRequestMatcher($matcher); + } + + /** + * {@inheritdoc} + */ + public function authenticate(RequestInterface $request) + { + if ($this->matcher->matches($request)) { + return $this->authentication->authenticate($request); + } + + return $request; + } + + /** + * Creates a matching authentication for an URL. + * + * @param Authentication $authentication + * @param string $url + * + * @return self + */ + public static function createUrlMatcher(Authentication $authentication, $url) + { + $matcher = function (RequestInterface $request) use ($url) { + return preg_match($url, $request->getRequestTarget()); + }; + + return new static($authentication, $matcher); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Authentication/QueryParam.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Authentication/QueryParam.php new file mode 100644 index 0000000..14b58ff --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Authentication/QueryParam.php @@ -0,0 +1,50 @@ +<?php + +namespace Http\Message\Authentication; + +use Http\Message\Authentication; +use Psr\Http\Message\RequestInterface; + +/** + * Authenticate a PSR-7 Request by adding parameters to its query. + * + * Note: Although in some cases it can be useful, we do not recommend using query parameters for authentication. + * Credentials in the URL is generally unsafe as they are not encrypted, anyone can see them. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +final class QueryParam implements Authentication +{ + /** + * @var array + */ + private $params = []; + + /** + * @param array $params + */ + public function __construct(array $params) + { + $this->params = $params; + } + + /** + * {@inheritdoc} + */ + public function authenticate(RequestInterface $request) + { + $uri = $request->getUri(); + $query = $uri->getQuery(); + $params = []; + + parse_str($query, $params); + + $params = array_merge($params, $this->params); + + $query = http_build_query($params); + + $uri = $uri->withQuery($query); + + return $request->withUri($uri); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Authentication/RequestConditional.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Authentication/RequestConditional.php new file mode 100644 index 0000000..5477440 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Authentication/RequestConditional.php @@ -0,0 +1,47 @@ +<?php + +namespace Http\Message\Authentication; + +use Http\Message\Authentication; +use Http\Message\RequestMatcher; +use Psr\Http\Message\RequestInterface; + +/** + * Authenticate a PSR-7 Request if the request is matching the given request matcher. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +final class RequestConditional implements Authentication +{ + /** + * @var RequestMatcher + */ + private $requestMatcher; + + /** + * @var Authentication + */ + private $authentication; + + /** + * @param RequestMatcher $requestMatcher + * @param Authentication $authentication + */ + public function __construct(RequestMatcher $requestMatcher, Authentication $authentication) + { + $this->requestMatcher = $requestMatcher; + $this->authentication = $authentication; + } + + /** + * {@inheritdoc} + */ + public function authenticate(RequestInterface $request) + { + if ($this->requestMatcher->matches($request)) { + return $this->authentication->authenticate($request); + } + + return $request; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Authentication/Wsse.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Authentication/Wsse.php new file mode 100644 index 0000000..fbbde33 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Authentication/Wsse.php @@ -0,0 +1,58 @@ +<?php + +namespace Http\Message\Authentication; + +use Http\Message\Authentication; +use Psr\Http\Message\RequestInterface; + +/** + * Authenticate a PSR-7 Request using WSSE. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +final class Wsse implements Authentication +{ + /** + * @var string + */ + private $username; + + /** + * @var string + */ + private $password; + + /** + * @param string $username + * @param string $password + */ + public function __construct($username, $password) + { + $this->username = $username; + $this->password = $password; + } + + /** + * {@inheritdoc} + */ + public function authenticate(RequestInterface $request) + { + // TODO: generate better nonce? + $nonce = substr(md5(uniqid(uniqid().'_', true)), 0, 16); + $created = date('c'); + $digest = base64_encode(sha1(base64_decode($nonce).$created.$this->password, true)); + + $wsse = sprintf( + 'UsernameToken Username="%s", PasswordDigest="%s", Nonce="%s", Created="%s"', + $this->username, + $digest, + $nonce, + $created + ); + + return $request + ->withHeader('Authorization', 'WSSE profile="UsernameToken"') + ->withHeader('X-WSSE', $wsse) + ; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Builder/ResponseBuilder.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Builder/ResponseBuilder.php new file mode 100644 index 0000000..e6933a0 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Builder/ResponseBuilder.php @@ -0,0 +1,148 @@ +<?php + +namespace Http\Message\Builder; + +use Psr\Http\Message\ResponseInterface; + +/** + * Fills response object with values. + */ +class ResponseBuilder +{ + /** + * The response to be built. + * + * @var ResponseInterface + */ + protected $response; + + /** + * Create builder for the given response. + * + * @param ResponseInterface $response + */ + public function __construct(ResponseInterface $response) + { + $this->response = $response; + } + + /** + * Return response. + * + * @return ResponseInterface + */ + public function getResponse() + { + return $this->response; + } + + /** + * Add headers represented by an array of header lines. + * + * @param string[] $headers Response headers as array of header lines. + * + * @return $this + * + * @throws \UnexpectedValueException For invalid header values. + * @throws \InvalidArgumentException For invalid status code arguments. + */ + public function setHeadersFromArray(array $headers) + { + $status = array_shift($headers); + $this->setStatus($status); + + foreach ($headers as $headerLine) { + $headerLine = trim($headerLine); + if ('' === $headerLine) { + continue; + } + + $this->addHeader($headerLine); + } + + return $this; + } + + /** + * Add headers represented by a single string. + * + * @param string $headers Response headers as single string. + * + * @return $this + * + * @throws \InvalidArgumentException if $headers is not a string on object with __toString() + * @throws \UnexpectedValueException For invalid header values. + */ + public function setHeadersFromString($headers) + { + if (!(is_string($headers) + || (is_object($headers) && method_exists($headers, '__toString'))) + ) { + throw new \InvalidArgumentException( + sprintf( + '%s expects parameter 1 to be a string, %s given', + __METHOD__, + is_object($headers) ? get_class($headers) : gettype($headers) + ) + ); + } + + $this->setHeadersFromArray(explode("\r\n", $headers)); + + return $this; + } + + /** + * Set response status from a status string. + * + * @param string $statusLine Response status as a string. + * + * @return $this + * + * @throws \InvalidArgumentException For invalid status line. + */ + public function setStatus($statusLine) + { + $parts = explode(' ', $statusLine, 3); + if (count($parts) < 2 || strpos(strtolower($parts[0]), 'http/') !== 0) { + throw new \InvalidArgumentException( + sprintf('"%s" is not a valid HTTP status line', $statusLine) + ); + } + + $reasonPhrase = count($parts) > 2 ? $parts[2] : ''; + $this->response = $this->response + ->withStatus((int) $parts[1], $reasonPhrase) + ->withProtocolVersion(substr($parts[0], 5)); + + return $this; + } + + /** + * Add header represented by a string. + * + * @param string $headerLine Response header as a string. + * + * @return $this + * + * @throws \InvalidArgumentException For invalid header names or values. + */ + public function addHeader($headerLine) + { + $parts = explode(':', $headerLine, 2); + if (count($parts) !== 2) { + throw new \InvalidArgumentException( + sprintf('"%s" is not a valid HTTP header line', $headerLine) + ); + } + $name = trim($parts[0]); + $value = trim($parts[1]); + if ($this->response->hasHeader($name)) { + $this->response = $this->response->withAddedHeader($name, $value); + } else { + $this->response = $this->response->withHeader($name, $value); + } + + return $this; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Cookie.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Cookie.php new file mode 100644 index 0000000..5f61b90 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Cookie.php @@ -0,0 +1,526 @@ +<?php + +namespace Http\Message; + +/** + * Cookie Value Object. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + * + * @see http://tools.ietf.org/search/rfc6265 + */ +final class Cookie +{ + /** + * @var string + */ + private $name; + + /** + * @var string|null + */ + private $value; + + /** + * @var int|null + */ + private $maxAge; + + /** + * @var string|null + */ + private $domain; + + /** + * @var string + */ + private $path; + + /** + * @var bool + */ + private $secure; + + /** + * @var bool + */ + private $httpOnly; + + /** + * Expires attribute is HTTP 1.0 only and should be avoided. + * + * @var \DateTime|null + */ + private $expires; + + /** + * @param string $name + * @param string|null $value + * @param int $maxAge + * @param string|null $domain + * @param string|null $path + * @param bool $secure + * @param bool $httpOnly + * @param \DateTime|null $expires Expires attribute is HTTP 1.0 only and should be avoided. + * + * @throws \InvalidArgumentException If name, value or max age is not valid. + */ + public function __construct( + $name, + $value = null, + $maxAge = null, + $domain = null, + $path = null, + $secure = false, + $httpOnly = false, + \DateTime $expires = null + ) { + $this->validateName($name); + $this->validateValue($value); + $this->validateMaxAge($maxAge); + + $this->name = $name; + $this->value = $value; + $this->maxAge = $maxAge; + $this->expires = $expires; + $this->domain = $this->normalizeDomain($domain); + $this->path = $this->normalizePath($path); + $this->secure = (bool) $secure; + $this->httpOnly = (bool) $httpOnly; + } + + /** + * Creates a new cookie without any attribute validation. + * + * @param string $name + * @param string|null $value + * @param int $maxAge + * @param string|null $domain + * @param string|null $path + * @param bool $secure + * @param bool $httpOnly + * @param \DateTime|null $expires Expires attribute is HTTP 1.0 only and should be avoided. + */ + public static function createWithoutValidation( + $name, + $value = null, + $maxAge = null, + $domain = null, + $path = null, + $secure = false, + $httpOnly = false, + \DateTime $expires = null + ) { + $cookie = new self('name', null, null, $domain, $path, $secure, $httpOnly, $expires); + $cookie->name = $name; + $cookie->value = $value; + $cookie->maxAge = $maxAge; + + return $cookie; + } + + /** + * Returns the name. + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Returns the value. + * + * @return string|null + */ + public function getValue() + { + return $this->value; + } + + /** + * Checks if there is a value. + * + * @return bool + */ + public function hasValue() + { + return isset($this->value); + } + + /** + * Sets the value. + * + * @param string|null $value + * + * @return Cookie + */ + public function withValue($value) + { + $this->validateValue($value); + + $new = clone $this; + $new->value = $value; + + return $new; + } + + /** + * Returns the max age. + * + * @return int|null + */ + public function getMaxAge() + { + return $this->maxAge; + } + + /** + * Checks if there is a max age. + * + * @return bool + */ + public function hasMaxAge() + { + return isset($this->maxAge); + } + + /** + * Sets the max age. + * + * @param int|null $maxAge + * + * @return Cookie + */ + public function withMaxAge($maxAge) + { + $this->validateMaxAge($maxAge); + + $new = clone $this; + $new->maxAge = $maxAge; + + return $new; + } + + /** + * Returns the expiration time. + * + * @return \DateTime|null + */ + public function getExpires() + { + return $this->expires; + } + + /** + * Checks if there is an expiration time. + * + * @return bool + */ + public function hasExpires() + { + return isset($this->expires); + } + + /** + * Sets the expires. + * + * @param \DateTime|null $expires + * + * @return Cookie + */ + public function withExpires(\DateTime $expires = null) + { + $new = clone $this; + $new->expires = $expires; + + return $new; + } + + /** + * Checks if the cookie is expired. + * + * @return bool + */ + public function isExpired() + { + return isset($this->expires) and $this->expires < new \DateTime(); + } + + /** + * Returns the domain. + * + * @return string|null + */ + public function getDomain() + { + return $this->domain; + } + + /** + * Checks if there is a domain. + * + * @return bool + */ + public function hasDomain() + { + return isset($this->domain); + } + + /** + * Sets the domain. + * + * @param string|null $domain + * + * @return Cookie + */ + public function withDomain($domain) + { + $new = clone $this; + $new->domain = $this->normalizeDomain($domain); + + return $new; + } + + /** + * Checks whether this cookie is meant for this domain. + * + * @see http://tools.ietf.org/html/rfc6265#section-5.1.3 + * + * @param string $domain + * + * @return bool + */ + public function matchDomain($domain) + { + // Domain is not set or exact match + if (!$this->hasDomain() || strcasecmp($domain, $this->domain) === 0) { + return true; + } + + // Domain is not an IP address + if (filter_var($domain, FILTER_VALIDATE_IP)) { + return false; + } + + return (bool) preg_match(sprintf('/\b%s$/i', preg_quote($this->domain)), $domain); + } + + /** + * Returns the path. + * + * @return string + */ + public function getPath() + { + return $this->path; + } + + /** + * Sets the path. + * + * @param string|null $path + * + * @return Cookie + */ + public function withPath($path) + { + $new = clone $this; + $new->path = $this->normalizePath($path); + + return $new; + } + + /** + * Checks whether this cookie is meant for this path. + * + * @see http://tools.ietf.org/html/rfc6265#section-5.1.4 + * + * @param string $path + * + * @return bool + */ + public function matchPath($path) + { + return $this->path === $path || (strpos($path, rtrim($this->path, '/').'/') === 0); + } + + /** + * Checks whether this cookie may only be sent over HTTPS. + * + * @return bool + */ + public function isSecure() + { + return $this->secure; + } + + /** + * Sets whether this cookie should only be sent over HTTPS. + * + * @param bool $secure + * + * @return Cookie + */ + public function withSecure($secure) + { + $new = clone $this; + $new->secure = (bool) $secure; + + return $new; + } + + /** + * Check whether this cookie may not be accessed through Javascript. + * + * @return bool + */ + public function isHttpOnly() + { + return $this->httpOnly; + } + + /** + * Sets whether this cookie may not be accessed through Javascript. + * + * @param bool $httpOnly + * + * @return Cookie + */ + public function withHttpOnly($httpOnly) + { + $new = clone $this; + $new->httpOnly = (bool) $httpOnly; + + return $new; + } + + /** + * Checks if this cookie represents the same cookie as $cookie. + * + * This does not compare the values, only name, domain and path. + * + * @param Cookie $cookie + * + * @return bool + */ + public function match(Cookie $cookie) + { + return $this->name === $cookie->name && $this->domain === $cookie->domain and $this->path === $cookie->path; + } + + /** + * Validates cookie attributes. + * + * @return bool + */ + public function isValid() + { + try { + $this->validateName($this->name); + $this->validateValue($this->value); + $this->validateMaxAge($this->maxAge); + } catch (\InvalidArgumentException $e) { + return false; + } + + return true; + } + + /** + * Validates the name attribute. + * + * @see http://tools.ietf.org/search/rfc2616#section-2.2 + * + * @param string $name + * + * @throws \InvalidArgumentException If the name is empty or contains invalid characters. + */ + private function validateName($name) + { + if (strlen($name) < 1) { + throw new \InvalidArgumentException('The name cannot be empty'); + } + + // Name attribute is a token as per spec in RFC 2616 + if (preg_match('/[\x00-\x20\x22\x28-\x29\x2C\x2F\x3A-\x40\x5B-\x5D\x7B\x7D\x7F]/', $name)) { + throw new \InvalidArgumentException(sprintf('The cookie name "%s" contains invalid characters.', $name)); + } + } + + /** + * Validates a value. + * + * @see http://tools.ietf.org/html/rfc6265#section-4.1.1 + * + * @param string|null $value + * + * @throws \InvalidArgumentException If the value contains invalid characters. + */ + private function validateValue($value) + { + if (isset($value)) { + if (preg_match('/[^\x21\x23-\x2B\x2D-\x3A\x3C-\x5B\x5D-\x7E]/', $value)) { + throw new \InvalidArgumentException(sprintf('The cookie value "%s" contains invalid characters.', $value)); + } + } + } + + /** + * Validates a Max-Age attribute. + * + * @param int|null $maxAge + * + * @throws \InvalidArgumentException If the Max-Age is not an empty or integer value. + */ + private function validateMaxAge($maxAge) + { + if (isset($maxAge)) { + if (!is_int($maxAge)) { + throw new \InvalidArgumentException('Max-Age must be integer'); + } + } + } + + /** + * Remove the leading '.' and lowercase the domain as per spec in RFC 6265. + * + * @see http://tools.ietf.org/html/rfc6265#section-4.1.2.3 + * @see http://tools.ietf.org/html/rfc6265#section-5.1.3 + * @see http://tools.ietf.org/html/rfc6265#section-5.2.3 + * + * @param string|null $domain + * + * @return string + */ + private function normalizeDomain($domain) + { + if (isset($domain)) { + $domain = ltrim(strtolower($domain), '.'); + } + + return $domain; + } + + /** + * Processes path as per spec in RFC 6265. + * + * @see http://tools.ietf.org/html/rfc6265#section-5.1.4 + * @see http://tools.ietf.org/html/rfc6265#section-5.2.4 + * + * @param string|null $path + * + * @return string + */ + private function normalizePath($path) + { + $path = rtrim($path, '/'); + + if (empty($path) or substr($path, 0, 1) !== '/') { + $path = '/'; + } + + return $path; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/CookieJar.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/CookieJar.php new file mode 100644 index 0000000..ab267d3 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/CookieJar.php @@ -0,0 +1,220 @@ +<?php + +namespace Http\Message; + +/** + * Cookie Jar holds a set of Cookies. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +final class CookieJar implements \Countable, \IteratorAggregate +{ + /** + * @var \SplObjectStorage + */ + protected $cookies; + + public function __construct() + { + $this->cookies = new \SplObjectStorage(); + } + + /** + * Checks if there is a cookie. + * + * @param Cookie $cookie + * + * @return bool + */ + public function hasCookie(Cookie $cookie) + { + return $this->cookies->contains($cookie); + } + + /** + * Adds a cookie. + * + * @param Cookie $cookie + */ + public function addCookie(Cookie $cookie) + { + if (!$this->hasCookie($cookie)) { + $cookies = $this->getMatchingCookies($cookie); + + foreach ($cookies as $matchingCookie) { + if ($cookie->getValue() !== $matchingCookie->getValue() || $cookie->getMaxAge() > $matchingCookie->getMaxAge()) { + $this->removeCookie($matchingCookie); + + continue; + } + } + + if ($cookie->hasValue()) { + $this->cookies->attach($cookie); + } + } + } + + /** + * Removes a cookie. + * + * @param Cookie $cookie + */ + public function removeCookie(Cookie $cookie) + { + $this->cookies->detach($cookie); + } + + /** + * Returns the cookies. + * + * @return Cookie[] + */ + public function getCookies() + { + $match = function ($matchCookie) { + return true; + }; + + return $this->findMatchingCookies($match); + } + + /** + * Returns all matching cookies. + * + * @param Cookie $cookie + * + * @return Cookie[] + */ + public function getMatchingCookies(Cookie $cookie) + { + $match = function ($matchCookie) use ($cookie) { + return $matchCookie->match($cookie); + }; + + return $this->findMatchingCookies($match); + } + + /** + * Finds matching cookies based on a callable. + * + * @param callable $match + * + * @return Cookie[] + */ + protected function findMatchingCookies(callable $match) + { + $cookies = []; + + foreach ($this->cookies as $cookie) { + if ($match($cookie)) { + $cookies[] = $cookie; + } + } + + return $cookies; + } + + /** + * Checks if there are cookies. + * + * @return bool + */ + public function hasCookies() + { + return $this->cookies->count() > 0; + } + + /** + * Sets the cookies and removes any previous one. + * + * @param Cookie[] $cookies + */ + public function setCookies(array $cookies) + { + $this->clear(); + $this->addCookies($cookies); + } + + /** + * Adds some cookies. + * + * @param Cookie[] $cookies + */ + public function addCookies(array $cookies) + { + foreach ($cookies as $cookie) { + $this->addCookie($cookie); + } + } + + /** + * Removes some cookies. + * + * @param Cookie[] $cookies + */ + public function removeCookies(array $cookies) + { + foreach ($cookies as $cookie) { + $this->removeCookie($cookie); + } + } + + /** + * Removes cookies which match the given parameters. + * + * Null means that parameter should not be matched + * + * @param string|null $name + * @param string|null $domain + * @param string|null $path + */ + public function removeMatchingCookies($name = null, $domain = null, $path = null) + { + $match = function ($cookie) use ($name, $domain, $path) { + $match = true; + + if (isset($name)) { + $match = $match && ($cookie->getName() === $name); + } + + if (isset($domain)) { + $match = $match && $cookie->matchDomain($domain); + } + + if (isset($path)) { + $match = $match && $cookie->matchPath($path); + } + + return $match; + }; + + $cookies = $this->findMatchingCookies($match); + + $this->removeCookies($cookies); + } + + /** + * Removes all cookies. + */ + public function clear() + { + $this->cookies = new \SplObjectStorage(); + } + + /** + * {@inheritdoc} + */ + public function count() + { + return $this->cookies->count(); + } + + /** + * {@inheritdoc} + */ + public function getIterator() + { + return clone $this->cookies; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/CookieUtil.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/CookieUtil.php new file mode 100644 index 0000000..5c670d4 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/CookieUtil.php @@ -0,0 +1,53 @@ +<?php + +namespace Http\Message; + +use Http\Message\Exception\UnexpectedValueException; + +final class CookieUtil +{ + /** + * Handles dates as defined by RFC 2616 section 3.3.1, and also some other + * non-standard, but common formats. + * + * @var array + */ + private static $dateFormats = [ + 'D, d M y H:i:s T', + 'D, d M Y H:i:s T', + 'D, d-M-y H:i:s T', + 'D, d-M-Y H:i:s T', + 'D, d-m-y H:i:s T', + 'D, d-m-Y H:i:s T', + 'D M j G:i:s Y', + 'D M d H:i:s Y T', + ]; + + /** + * @see https://github.com/symfony/symfony/blob/master/src/Symfony/Component/BrowserKit/Cookie.php + * + * @param string $dateValue + * + * @return \DateTime + * + * @throws UnexpectedValueException if we cannot parse the cookie date string. + */ + public static function parseDate($dateValue) + { + foreach (self::$dateFormats as $dateFormat) { + if (false !== $date = \DateTime::createFromFormat($dateFormat, $dateValue, new \DateTimeZone('GMT'))) { + return $date; + } + } + + // attempt a fallback for unusual formatting + if (false !== $date = date_create($dateValue, new \DateTimeZone('GMT'))) { + return $date; + } + + throw new UnexpectedValueException(sprintf( + 'Unparseable cookie date string "%s"', + $dateValue + )); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Decorator/MessageDecorator.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Decorator/MessageDecorator.php new file mode 100644 index 0000000..0ffc7ca --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Decorator/MessageDecorator.php @@ -0,0 +1,133 @@ +<?php + +namespace Http\Message\Decorator; + +use Psr\Http\Message\MessageInterface; +use Psr\Http\Message\StreamInterface; + +/** + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +trait MessageDecorator +{ + /** + * @var MessageInterface + */ + private $message; + + /** + * Returns the decorated message. + * + * Since the underlying Message is immutable as well + * exposing it is not an issue, because it's state cannot be altered + * + * @return MessageInterface + */ + public function getMessage() + { + return $this->message; + } + + /** + * {@inheritdoc} + */ + public function getProtocolVersion() + { + return $this->message->getProtocolVersion(); + } + + /** + * {@inheritdoc} + */ + public function withProtocolVersion($version) + { + $new = clone $this; + $new->message = $this->message->withProtocolVersion($version); + + return $new; + } + + /** + * {@inheritdoc} + */ + public function getHeaders() + { + return $this->message->getHeaders(); + } + + /** + * {@inheritdoc} + */ + public function hasHeader($header) + { + return $this->message->hasHeader($header); + } + + /** + * {@inheritdoc} + */ + public function getHeader($header) + { + return $this->message->getHeader($header); + } + + /** + * {@inheritdoc} + */ + public function getHeaderLine($header) + { + return $this->message->getHeaderLine($header); + } + + /** + * {@inheritdoc} + */ + public function withHeader($header, $value) + { + $new = clone $this; + $new->message = $this->message->withHeader($header, $value); + + return $new; + } + + /** + * {@inheritdoc} + */ + public function withAddedHeader($header, $value) + { + $new = clone $this; + $new->message = $this->message->withAddedHeader($header, $value); + + return $new; + } + + /** + * {@inheritdoc} + */ + public function withoutHeader($header) + { + $new = clone $this; + $new->message = $this->message->withoutHeader($header); + + return $new; + } + + /** + * {@inheritdoc} + */ + public function getBody() + { + return $this->message->getBody(); + } + + /** + * {@inheritdoc} + */ + public function withBody(StreamInterface $body) + { + $new = clone $this; + $new->message = $this->message->withBody($body); + + return $new; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Decorator/RequestDecorator.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Decorator/RequestDecorator.php new file mode 100644 index 0000000..7c50e58 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Decorator/RequestDecorator.php @@ -0,0 +1,88 @@ +<?php + +namespace Http\Message\Decorator; + +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\UriInterface; + +/** + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +trait RequestDecorator +{ + use MessageDecorator { + getMessage as getRequest; + } + + /** + * Exchanges the underlying request with another. + * + * @param RequestInterface $request + * + * @return self + */ + public function withRequest(RequestInterface $request) + { + $new = clone $this; + $new->message = $request; + + return $new; + } + + /** + * {@inheritdoc} + */ + public function getRequestTarget() + { + return $this->message->getRequestTarget(); + } + + /** + * {@inheritdoc} + */ + public function withRequestTarget($requestTarget) + { + $new = clone $this; + $new->message = $this->message->withRequestTarget($requestTarget); + + return $new; + } + + /** + * {@inheritdoc} + */ + public function getMethod() + { + return $this->message->getMethod(); + } + + /** + * {@inheritdoc} + */ + public function withMethod($method) + { + $new = clone $this; + $new->message = $this->message->withMethod($method); + + return $new; + } + + /** + * {@inheritdoc} + */ + public function getUri() + { + return $this->message->getUri(); + } + + /** + * {@inheritdoc} + */ + public function withUri(UriInterface $uri, $preserveHost = false) + { + $new = clone $this; + $new->message = $this->message->withUri($uri, $preserveHost); + + return $new; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Decorator/ResponseDecorator.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Decorator/ResponseDecorator.php new file mode 100644 index 0000000..82d9ae0 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Decorator/ResponseDecorator.php @@ -0,0 +1,57 @@ +<?php + +namespace Http\Message\Decorator; + +use Psr\Http\Message\ResponseInterface; + +/** + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +trait ResponseDecorator +{ + use MessageDecorator { + getMessage as getResponse; + } + + /** + * Exchanges the underlying response with another. + * + * @param ResponseInterface $response + * + * @return self + */ + public function withResponse(ResponseInterface $response) + { + $new = clone $this; + $new->message = $response; + + return $new; + } + + /** + * {@inheritdoc} + */ + public function getStatusCode() + { + return $this->message->getStatusCode(); + } + + /** + * {@inheritdoc} + */ + public function withStatus($code, $reasonPhrase = '') + { + $new = clone $this; + $new->message = $this->message->withStatus($code, $reasonPhrase); + + return $new; + } + + /** + * {@inheritdoc} + */ + public function getReasonPhrase() + { + return $this->message->getReasonPhrase(); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Decorator/StreamDecorator.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Decorator/StreamDecorator.php new file mode 100644 index 0000000..f405c7a --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Decorator/StreamDecorator.php @@ -0,0 +1,138 @@ +<?php + +namespace Http\Message\Decorator; + +use Psr\Http\Message\StreamInterface; + +/** + * Decorates a stream. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +trait StreamDecorator +{ + /** + * @var StreamInterface + */ + protected $stream; + + /** + * {@inheritdoc} + */ + public function __toString() + { + return $this->stream->__toString(); + } + + /** + * {@inheritdoc} + */ + public function close() + { + $this->stream->close(); + } + + /** + * {@inheritdoc} + */ + public function detach() + { + return $this->stream->detach(); + } + + /** + * {@inheritdoc} + */ + public function getSize() + { + return $this->stream->getSize(); + } + + /** + * {@inheritdoc} + */ + public function tell() + { + return $this->stream->tell(); + } + + /** + * {@inheritdoc} + */ + public function eof() + { + return $this->stream->eof(); + } + + /** + * {@inheritdoc} + */ + public function isSeekable() + { + return $this->stream->isSeekable(); + } + + /** + * {@inheritdoc} + */ + public function seek($offset, $whence = SEEK_SET) + { + $this->stream->seek($offset, $whence); + } + + /** + * {@inheritdoc} + */ + public function rewind() + { + $this->stream->rewind(); + } + + /** + * {@inheritdoc} + */ + public function isWritable() + { + return $this->stream->isWritable(); + } + + /** + * {@inheritdoc} + */ + public function write($string) + { + return $this->stream->write($string); + } + + /** + * {@inheritdoc} + */ + public function isReadable() + { + return $this->stream->isReadable(); + } + + /** + * {@inheritdoc} + */ + public function read($length) + { + return $this->stream->read($length); + } + + /** + * {@inheritdoc} + */ + public function getContents() + { + return $this->stream->getContents(); + } + + /** + * {@inheritdoc} + */ + public function getMetadata($key = null) + { + return $this->stream->getMetadata($key); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Encoding/ChunkStream.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Encoding/ChunkStream.php new file mode 100644 index 0000000..74c2fbd --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Encoding/ChunkStream.php @@ -0,0 +1,39 @@ +<?php + +namespace Http\Message\Encoding; + +/** + * Transform a regular stream into a chunked one. + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +class ChunkStream extends FilteredStream +{ + /** + * {@inheritdoc} + */ + protected function readFilter() + { + return 'chunk'; + } + + /** + * {@inheritdoc} + */ + protected function writeFilter() + { + return 'dechunk'; + } + + /** + * {@inheritdoc} + */ + protected function fill() + { + parent::fill(); + + if ($this->stream->eof()) { + $this->buffer .= "0\r\n\r\n"; + } + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Encoding/CompressStream.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Encoding/CompressStream.php new file mode 100644 index 0000000..d1013dc --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Encoding/CompressStream.php @@ -0,0 +1,42 @@ +<?php + +namespace Http\Message\Encoding; + +use Psr\Http\Message\StreamInterface; + +/** + * Stream compress (RFC 1950). + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +class CompressStream extends FilteredStream +{ + /** + * @param StreamInterface $stream + * @param int $level + */ + public function __construct(StreamInterface $stream, $level = -1) + { + if (!extension_loaded('zlib')) { + throw new \RuntimeException('The zlib extension must be enabled to use this stream'); + } + + parent::__construct($stream, ['window' => 15, 'level' => $level], ['window' => 15]); + } + + /** + * {@inheritdoc} + */ + protected function readFilter() + { + return 'zlib.deflate'; + } + + /** + * {@inheritdoc} + */ + protected function writeFilter() + { + return 'zlib.inflate'; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Encoding/DechunkStream.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Encoding/DechunkStream.php new file mode 100644 index 0000000..4cade83 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Encoding/DechunkStream.php @@ -0,0 +1,29 @@ +<?php + +namespace Http\Message\Encoding; + +/** + * Decorate a stream which is chunked. + * + * Allow to decode a chunked stream + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +class DechunkStream extends FilteredStream +{ + /** + * {@inheritdoc} + */ + protected function readFilter() + { + return 'dechunk'; + } + + /** + * {@inheritdoc} + */ + protected function writeFilter() + { + return 'chunk'; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Encoding/DecompressStream.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Encoding/DecompressStream.php new file mode 100644 index 0000000..4e3a723 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Encoding/DecompressStream.php @@ -0,0 +1,42 @@ +<?php + +namespace Http\Message\Encoding; + +use Psr\Http\Message\StreamInterface; + +/** + * Stream decompress (RFC 1950). + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +class DecompressStream extends FilteredStream +{ + /** + * @param StreamInterface $stream + * @param int $level + */ + public function __construct(StreamInterface $stream, $level = -1) + { + if (!extension_loaded('zlib')) { + throw new \RuntimeException('The zlib extension must be enabled to use this stream'); + } + + parent::__construct($stream, ['window' => 15], ['window' => 15, 'level' => $level]); + } + + /** + * {@inheritdoc} + */ + protected function readFilter() + { + return 'zlib.inflate'; + } + + /** + * {@inheritdoc} + */ + protected function writeFilter() + { + return 'zlib.deflate'; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Encoding/DeflateStream.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Encoding/DeflateStream.php new file mode 100644 index 0000000..1d7344b --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Encoding/DeflateStream.php @@ -0,0 +1,38 @@ +<?php + +namespace Http\Message\Encoding; + +use Psr\Http\Message\StreamInterface; + +/** + * Stream deflate (RFC 1951). + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +class DeflateStream extends FilteredStream +{ + /** + * @param StreamInterface $stream + * @param int $level + */ + public function __construct(StreamInterface $stream, $level = -1) + { + parent::__construct($stream, ['window' => -15, 'level' => $level], ['window' => -15]); + } + + /** + * {@inheritdoc} + */ + protected function readFilter() + { + return 'zlib.deflate'; + } + + /** + * {@inheritdoc} + */ + protected function writeFilter() + { + return 'zlib.inflate'; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Encoding/Filter/Chunk.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Encoding/Filter/Chunk.php new file mode 100644 index 0000000..0f8f53b --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Encoding/Filter/Chunk.php @@ -0,0 +1,30 @@ +<?php + +namespace Http\Message\Encoding\Filter; + +/** + * Userland implementation of the chunk stream filter. + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +class Chunk extends \php_user_filter +{ + /** + * {@inheritdoc} + */ + public function filter($in, $out, &$consumed, $closing) + { + while ($bucket = stream_bucket_make_writeable($in)) { + $lenbucket = stream_bucket_new($this->stream, dechex($bucket->datalen)."\r\n"); + stream_bucket_append($out, $lenbucket); + + $consumed += $bucket->datalen; + stream_bucket_append($out, $bucket); + + $lenbucket = stream_bucket_new($this->stream, "\r\n"); + stream_bucket_append($out, $lenbucket); + } + + return PSFS_PASS_ON; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Encoding/FilteredStream.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Encoding/FilteredStream.php new file mode 100644 index 0000000..a32554b --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Encoding/FilteredStream.php @@ -0,0 +1,198 @@ +<?php + +namespace Http\Message\Encoding; + +use Clue\StreamFilter as Filter; +use Http\Message\Decorator\StreamDecorator; +use Psr\Http\Message\StreamInterface; + +/** + * A filtered stream has a filter for filtering output and a filter for filtering input made to a underlying stream. + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +abstract class FilteredStream implements StreamInterface +{ + const BUFFER_SIZE = 8192; + + use StreamDecorator; + + /** + * @var callable + */ + protected $readFilterCallback; + + /** + * @var resource + * + * @deprecated since version 1.5, will be removed in 2.0 + */ + protected $readFilter; + + /** + * @var callable + * + * @deprecated since version 1.5, will be removed in 2.0 + */ + protected $writeFilterCallback; + + /** + * @var resource + * + * @deprecated since version 1.5, will be removed in 2.0 + */ + protected $writeFilter; + + /** + * Internal buffer. + * + * @var string + */ + protected $buffer = ''; + + /** + * @param StreamInterface $stream + * @param mixed|null $readFilterOptions + * @param mixed|null $writeFilterOptions deprecated since 1.5, will be removed in 2.0 + */ + public function __construct(StreamInterface $stream, $readFilterOptions = null, $writeFilterOptions = null) + { + $this->readFilterCallback = Filter\fun($this->readFilter(), $readFilterOptions); + $this->writeFilterCallback = Filter\fun($this->writeFilter(), $writeFilterOptions); + + if (null !== $writeFilterOptions) { + @trigger_error('The $writeFilterOptions argument is deprecated since version 1.5 and will be removed in 2.0.', E_USER_DEPRECATED); + } + + $this->stream = $stream; + } + + /** + * {@inheritdoc} + */ + public function read($length) + { + if (strlen($this->buffer) >= $length) { + $read = substr($this->buffer, 0, $length); + $this->buffer = substr($this->buffer, $length); + + return $read; + } + + if ($this->stream->eof()) { + $buffer = $this->buffer; + $this->buffer = ''; + + return $buffer; + } + + $read = $this->buffer; + $this->buffer = ''; + $this->fill(); + + return $read.$this->read($length - strlen($read)); + } + + /** + * {@inheritdoc} + */ + public function eof() + { + return $this->stream->eof() && $this->buffer === ''; + } + + /** + * Buffer is filled by reading underlying stream. + * + * Callback is reading once more even if the stream is ended. + * This allow to get last data in the PHP buffer otherwise this + * bug is present : https://bugs.php.net/bug.php?id=48725 + */ + protected function fill() + { + $readFilterCallback = $this->readFilterCallback; + $this->buffer .= $readFilterCallback($this->stream->read(self::BUFFER_SIZE)); + + if ($this->stream->eof()) { + $this->buffer .= $readFilterCallback(); + } + } + + /** + * {@inheritdoc} + */ + public function getContents() + { + $buffer = ''; + + while (!$this->eof()) { + $buf = $this->read(self::BUFFER_SIZE); + // Using a loose equality here to match on '' and false. + if ($buf == null) { + break; + } + + $buffer .= $buf; + } + + return $buffer; + } + + /** + * {@inheritdoc} + */ + public function getSize() + { + return; + } + + /** + * {@inheritdoc} + */ + public function __toString() + { + return $this->getContents(); + } + + /** + * Returns the read filter name. + * + * @return string + * + * @deprecated since version 1.5, will be removed in 2.0 + */ + public function getReadFilter() + { + @trigger_error('The '.__CLASS__.'::'.__METHOD__.' method is deprecated since version 1.5 and will be removed in 2.0.', E_USER_DEPRECATED); + + return $this->readFilter(); + } + + /** + * Returns the write filter name. + * + * @return string + */ + abstract protected function readFilter(); + + /** + * Returns the write filter name. + * + * @return string + * + * @deprecated since version 1.5, will be removed in 2.0 + */ + public function getWriteFilter() + { + @trigger_error('The '.__CLASS__.'::'.__METHOD__.' method is deprecated since version 1.5 and will be removed in 2.0.', E_USER_DEPRECATED); + + return $this->writeFilter(); + } + + /** + * Returns the write filter name. + * + * @return string + */ + abstract protected function writeFilter(); +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Encoding/GzipDecodeStream.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Encoding/GzipDecodeStream.php new file mode 100644 index 0000000..4f958ed --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Encoding/GzipDecodeStream.php @@ -0,0 +1,42 @@ +<?php + +namespace Http\Message\Encoding; + +use Psr\Http\Message\StreamInterface; + +/** + * Stream for decoding from gzip format (RFC 1952). + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +class GzipDecodeStream extends FilteredStream +{ + /** + * @param StreamInterface $stream + * @param int $level + */ + public function __construct(StreamInterface $stream, $level = -1) + { + if (!extension_loaded('zlib')) { + throw new \RuntimeException('The zlib extension must be enabled to use this stream'); + } + + parent::__construct($stream, ['window' => 31], ['window' => 31, 'level' => $level]); + } + + /** + * {@inheritdoc} + */ + protected function readFilter() + { + return 'zlib.inflate'; + } + + /** + * {@inheritdoc} + */ + protected function writeFilter() + { + return 'zlib.deflate'; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Encoding/GzipEncodeStream.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Encoding/GzipEncodeStream.php new file mode 100644 index 0000000..1066eec --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Encoding/GzipEncodeStream.php @@ -0,0 +1,42 @@ +<?php + +namespace Http\Message\Encoding; + +use Psr\Http\Message\StreamInterface; + +/** + * Stream for encoding to gzip format (RFC 1952). + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +class GzipEncodeStream extends FilteredStream +{ + /** + * @param StreamInterface $stream + * @param int $level + */ + public function __construct(StreamInterface $stream, $level = -1) + { + if (!extension_loaded('zlib')) { + throw new \RuntimeException('The zlib extension must be enabled to use this stream'); + } + + parent::__construct($stream, ['window' => 31, 'level' => $level], ['window' => 31]); + } + + /** + * {@inheritdoc} + */ + protected function readFilter() + { + return 'zlib.deflate'; + } + + /** + * {@inheritdoc} + */ + protected function writeFilter() + { + return 'zlib.inflate'; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Encoding/InflateStream.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Encoding/InflateStream.php new file mode 100644 index 0000000..7070230 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Encoding/InflateStream.php @@ -0,0 +1,42 @@ +<?php + +namespace Http\Message\Encoding; + +use Psr\Http\Message\StreamInterface; + +/** + * Stream inflate (RFC 1951). + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +class InflateStream extends FilteredStream +{ + /** + * @param StreamInterface $stream + * @param int $level + */ + public function __construct(StreamInterface $stream, $level = -1) + { + if (!extension_loaded('zlib')) { + throw new \RuntimeException('The zlib extension must be enabled to use this stream'); + } + + parent::__construct($stream, ['window' => -15], ['window' => -15, 'level' => $level]); + } + + /** + * {@inheritdoc} + */ + protected function readFilter() + { + return 'zlib.inflate'; + } + + /** + * {@inheritdoc} + */ + protected function writeFilter() + { + return 'zlib.deflate'; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Exception.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Exception.php new file mode 100644 index 0000000..80d4cd9 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Exception.php @@ -0,0 +1,10 @@ +<?php + +namespace Http\Message; + +/** + * An interface implemented by all HTTP message related exceptions. + */ +interface Exception +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Exception/UnexpectedValueException.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Exception/UnexpectedValueException.php new file mode 100644 index 0000000..7788ac7 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Exception/UnexpectedValueException.php @@ -0,0 +1,9 @@ +<?php + +namespace Http\Message\Exception; + +use Http\Message\Exception; + +final class UnexpectedValueException extends \UnexpectedValueException implements Exception +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Formatter.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Formatter.php new file mode 100644 index 0000000..d04d2c3 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Formatter.php @@ -0,0 +1,32 @@ +<?php + +namespace Http\Message; + +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; + +/** + * Formats a request and/or a response as a string. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +interface Formatter +{ + /** + * Formats a request. + * + * @param RequestInterface $request + * + * @return string + */ + public function formatRequest(RequestInterface $request); + + /** + * Formats a response. + * + * @param ResponseInterface $response + * + * @return string + */ + public function formatResponse(ResponseInterface $response); +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Formatter/CurlCommandFormatter.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Formatter/CurlCommandFormatter.php new file mode 100644 index 0000000..a0fe7e5 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Formatter/CurlCommandFormatter.php @@ -0,0 +1,80 @@ +<?php + +namespace Http\Message\Formatter; + +use Http\Message\Formatter; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; + +/** + * A formatter that prints a cURL command for HTTP requests. + * + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +class CurlCommandFormatter implements Formatter +{ + /** + * {@inheritdoc} + */ + public function formatRequest(RequestInterface $request) + { + $command = sprintf('curl %s', escapeshellarg((string) $request->getUri()->withFragment(''))); + if ($request->getProtocolVersion() === '1.0') { + $command .= ' --http1.0'; + } elseif ($request->getProtocolVersion() === '2.0') { + $command .= ' --http2'; + } + + $method = strtoupper($request->getMethod()); + if ('HEAD' === $method) { + $command .= ' --head'; + } elseif ('GET' !== $method) { + $command .= ' --request '.$method; + } + + $command .= $this->getHeadersAsCommandOptions($request); + + $body = $request->getBody(); + if ($body->getSize() > 0) { + if (!$body->isSeekable()) { + return 'Cant format Request as cUrl command if body stream is not seekable.'; + } + $command .= sprintf(' --data %s', escapeshellarg($body->__toString())); + $body->rewind(); + } + + return $command; + } + + /** + * {@inheritdoc} + */ + public function formatResponse(ResponseInterface $response) + { + return ''; + } + + /** + * @param RequestInterface $request + * + * @return string + */ + private function getHeadersAsCommandOptions(RequestInterface $request) + { + $command = ''; + foreach ($request->getHeaders() as $name => $values) { + if ('host' === strtolower($name) && $values[0] === $request->getUri()->getHost()) { + continue; + } + + if ('user-agent' === strtolower($name)) { + $command .= sprintf(' -A %s', escapeshellarg($values[0])); + continue; + } + + $command .= sprintf(' -H %s', escapeshellarg($name.': '.$request->getHeaderLine($name))); + } + + return $command; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Formatter/FullHttpMessageFormatter.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Formatter/FullHttpMessageFormatter.php new file mode 100644 index 0000000..3fa1029 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Formatter/FullHttpMessageFormatter.php @@ -0,0 +1,91 @@ +<?php + +namespace Http\Message\Formatter; + +use Http\Message\Formatter; +use Psr\Http\Message\MessageInterface; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; + +/** + * A formatter that prints the complete HTTP message. + * + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +class FullHttpMessageFormatter implements Formatter +{ + /** + * The maximum length of the body. + * + * @var int + */ + private $maxBodyLength; + + /** + * @param int $maxBodyLength + */ + public function __construct($maxBodyLength = 1000) + { + $this->maxBodyLength = $maxBodyLength; + } + + /** + * {@inheritdoc} + */ + public function formatRequest(RequestInterface $request) + { + $message = sprintf( + "%s %s HTTP/%s\n", + $request->getMethod(), + $request->getRequestTarget(), + $request->getProtocolVersion() + ); + + foreach ($request->getHeaders() as $name => $values) { + $message .= $name.': '.implode(', ', $values)."\n"; + } + + return $this->addBody($request, $message); + } + + /** + * {@inheritdoc} + */ + public function formatResponse(ResponseInterface $response) + { + $message = sprintf( + "HTTP/%s %s %s\n", + $response->getProtocolVersion(), + $response->getStatusCode(), + $response->getReasonPhrase() + ); + + foreach ($response->getHeaders() as $name => $values) { + $message .= $name.': '.implode(', ', $values)."\n"; + } + + return $this->addBody($response, $message); + } + + /** + * Add the message body if the stream is seekable. + * + * @param MessageInterface $request + * @param string $message + * + * @return string + */ + private function addBody(MessageInterface $request, $message) + { + $stream = $request->getBody(); + if (!$stream->isSeekable() || $this->maxBodyLength === 0) { + // Do not read the stream + $message .= "\n"; + } else { + $message .= "\n".mb_substr($stream->__toString(), 0, $this->maxBodyLength); + $stream->rewind(); + } + + return $message; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Formatter/SimpleFormatter.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Formatter/SimpleFormatter.php new file mode 100644 index 0000000..b1fcabd --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Formatter/SimpleFormatter.php @@ -0,0 +1,42 @@ +<?php + +namespace Http\Message\Formatter; + +use Http\Message\Formatter; +use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; + +/** + * Normalize a request or a response into a string or an array. + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +class SimpleFormatter implements Formatter +{ + /** + * {@inheritdoc} + */ + public function formatRequest(RequestInterface $request) + { + return sprintf( + '%s %s %s', + $request->getMethod(), + $request->getUri()->__toString(), + $request->getProtocolVersion() + ); + } + + /** + * {@inheritdoc} + */ + public function formatResponse(ResponseInterface $response) + { + return sprintf( + '%s %s %s', + $response->getStatusCode(), + $response->getReasonPhrase(), + $response->getProtocolVersion() + ); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/MessageFactory/DiactorosMessageFactory.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/MessageFactory/DiactorosMessageFactory.php new file mode 100644 index 0000000..53f08ae --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/MessageFactory/DiactorosMessageFactory.php @@ -0,0 +1,61 @@ +<?php + +namespace Http\Message\MessageFactory; + +use Http\Message\StreamFactory\DiactorosStreamFactory; +use Http\Message\MessageFactory; +use Zend\Diactoros\Request; +use Zend\Diactoros\Response; + +/** + * Creates Diactoros messages. + * + * @author GeLo <geloen.eric@gmail.com> + */ +final class DiactorosMessageFactory implements MessageFactory +{ + /** + * @var DiactorosStreamFactory + */ + private $streamFactory; + + public function __construct() + { + $this->streamFactory = new DiactorosStreamFactory(); + } + + /** + * {@inheritdoc} + */ + public function createRequest( + $method, + $uri, + array $headers = [], + $body = null, + $protocolVersion = '1.1' + ) { + return (new Request( + $uri, + $method, + $this->streamFactory->createStream($body), + $headers + ))->withProtocolVersion($protocolVersion); + } + + /** + * {@inheritdoc} + */ + public function createResponse( + $statusCode = 200, + $reasonPhrase = null, + array $headers = [], + $body = null, + $protocolVersion = '1.1' + ) { + return (new Response( + $this->streamFactory->createStream($body), + $statusCode, + $headers + ))->withProtocolVersion($protocolVersion); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/MessageFactory/GuzzleMessageFactory.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/MessageFactory/GuzzleMessageFactory.php new file mode 100644 index 0000000..59eb655 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/MessageFactory/GuzzleMessageFactory.php @@ -0,0 +1,53 @@ +<?php + +namespace Http\Message\MessageFactory; + +use GuzzleHttp\Psr7\Request; +use GuzzleHttp\Psr7\Response; +use Http\Message\MessageFactory; + +/** + * Creates Guzzle messages. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +final class GuzzleMessageFactory implements MessageFactory +{ + /** + * {@inheritdoc} + */ + public function createRequest( + $method, + $uri, + array $headers = [], + $body = null, + $protocolVersion = '1.1' + ) { + return new Request( + $method, + $uri, + $headers, + $body, + $protocolVersion + ); + } + + /** + * {@inheritdoc} + */ + public function createResponse( + $statusCode = 200, + $reasonPhrase = null, + array $headers = [], + $body = null, + $protocolVersion = '1.1' + ) { + return new Response( + $statusCode, + $headers, + $body, + $protocolVersion, + $reasonPhrase + ); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/MessageFactory/SlimMessageFactory.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/MessageFactory/SlimMessageFactory.php new file mode 100644 index 0000000..cdad2ec --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/MessageFactory/SlimMessageFactory.php @@ -0,0 +1,72 @@ +<?php + +namespace Http\Message\MessageFactory; + +use Http\Message\StreamFactory\SlimStreamFactory; +use Http\Message\UriFactory\SlimUriFactory; +use Http\Message\MessageFactory; +use Slim\Http\Request; +use Slim\Http\Response; +use Slim\Http\Headers; + +/** + * Creates Slim 3 messages. + * + * @author Mika Tuupola <tuupola@appelsiini.net> + */ +final class SlimMessageFactory implements MessageFactory +{ + /** + * @var SlimStreamFactory + */ + private $streamFactory; + + /** + * @var SlimUriFactory + */ + private $uriFactory; + + public function __construct() + { + $this->streamFactory = new SlimStreamFactory(); + $this->uriFactory = new SlimUriFactory(); + } + + /** + * {@inheritdoc} + */ + public function createRequest( + $method, + $uri, + array $headers = [], + $body = null, + $protocolVersion = '1.1' + ) { + return (new Request( + $method, + $this->uriFactory->createUri($uri), + new Headers($headers), + [], + [], + $this->streamFactory->createStream($body), + [] + ))->withProtocolVersion($protocolVersion); + } + + /** + * {@inheritdoc} + */ + public function createResponse( + $statusCode = 200, + $reasonPhrase = null, + array $headers = [], + $body = null, + $protocolVersion = '1.1' + ) { + return (new Response( + $statusCode, + new Headers($headers), + $this->streamFactory->createStream($body) + ))->withProtocolVersion($protocolVersion); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/RequestMatcher.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/RequestMatcher.php new file mode 100644 index 0000000..94fe532 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/RequestMatcher.php @@ -0,0 +1,26 @@ +<?php + +namespace Http\Message; + +use Psr\Http\Message\RequestInterface; + +/** + * Match a request. + * + * PSR-7 equivalent of Symfony's RequestMatcher + * + * @see https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/RequestMatcherInterface.php + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +interface RequestMatcher +{ + /** + * Decides whether the rule(s) implemented by the strategy matches the supplied request. + * + * @param RequestInterface $request The PSR7 request to check for a match + * + * @return bool true if the request matches, false otherwise + */ + public function matches(RequestInterface $request); +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/RequestMatcher/CallbackRequestMatcher.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/RequestMatcher/CallbackRequestMatcher.php new file mode 100644 index 0000000..4d45e32 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/RequestMatcher/CallbackRequestMatcher.php @@ -0,0 +1,35 @@ +<?php + +namespace Http\Message\RequestMatcher; + +use Http\Message\RequestMatcher; +use Psr\Http\Message\RequestInterface; + +/** + * Match a request with a callback. + * + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +final class CallbackRequestMatcher implements RequestMatcher +{ + /** + * @var callable + */ + private $callback; + + /** + * @param callable $callback + */ + public function __construct(callable $callback) + { + $this->callback = $callback; + } + + /** + * {@inheritdoc} + */ + public function matches(RequestInterface $request) + { + return (bool) call_user_func($this->callback, $request); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/RequestMatcher/RegexRequestMatcher.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/RequestMatcher/RegexRequestMatcher.php new file mode 100644 index 0000000..91f3729 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/RequestMatcher/RegexRequestMatcher.php @@ -0,0 +1,41 @@ +<?php + +namespace Http\Message\RequestMatcher; + +use Http\Message\RequestMatcher; +use Psr\Http\Message\RequestInterface; + +@trigger_error('The '.__NAMESPACE__.'\RegexRequestMatcher class is deprecated since version 1.2 and will be removed in 2.0. Use Http\Message\RequestMatcher\RequestMatcher instead.', E_USER_DEPRECATED); + +/** + * Match a request with a regex on the uri. + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + * + * @deprecated since version 1.2 and will be removed in 2.0. Use {@link RequestMatcher} instead. + */ +final class RegexRequestMatcher implements RequestMatcher +{ + /** + * Matching regex. + * + * @var string + */ + private $regex; + + /** + * @param string $regex + */ + public function __construct($regex) + { + $this->regex = $regex; + } + + /** + * {@inheritdoc} + */ + public function matches(RequestInterface $request) + { + return (bool) preg_match($this->regex, (string) $request->getUri()); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/RequestMatcher/RequestMatcher.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/RequestMatcher/RequestMatcher.php new file mode 100644 index 0000000..e2aa021 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/RequestMatcher/RequestMatcher.php @@ -0,0 +1,78 @@ +<?php + +namespace Http\Message\RequestMatcher; + +use Http\Message\RequestMatcher as RequestMatcherInterface; +use Psr\Http\Message\RequestInterface; + +/** + * A port of the Symfony RequestMatcher for PSR-7. + * + * @author Fabien Potencier <fabien@symfony.com> + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +final class RequestMatcher implements RequestMatcherInterface +{ + /** + * @var string + */ + private $path; + + /** + * @var string + */ + private $host; + + /** + * @var array + */ + private $methods = []; + + /** + * @var string[] + */ + private $schemes = []; + + /** + * The regular expressions used for path or host must be specified without delimiter. + * You do not need to escape the forward slash / to match it. + * + * @param string|null $path Regular expression for the path + * @param string|null $host Regular expression for the hostname + * @param string|string[]|null $methods Method or list of methods to match + * @param string|string[]|null $schemes Scheme or list of schemes to match (e.g. http or https) + */ + public function __construct($path = null, $host = null, $methods = [], $schemes = []) + { + $this->path = $path; + $this->host = $host; + $this->methods = array_map('strtoupper', (array) $methods); + $this->schemes = array_map('strtolower', (array) $schemes); + } + + /** + * {@inheritdoc} + * + * @api + */ + public function matches(RequestInterface $request) + { + if ($this->schemes && !in_array($request->getUri()->getScheme(), $this->schemes)) { + return false; + } + + if ($this->methods && !in_array($request->getMethod(), $this->methods)) { + return false; + } + + if (null !== $this->path && !preg_match('{'.$this->path.'}', rawurldecode($request->getUri()->getPath()))) { + return false; + } + + if (null !== $this->host && !preg_match('{'.$this->host.'}i', $request->getUri()->getHost())) { + return false; + } + + return true; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Stream/BufferedStream.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Stream/BufferedStream.php new file mode 100644 index 0000000..1eac974 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/Stream/BufferedStream.php @@ -0,0 +1,270 @@ +<?php + +namespace Http\Message\Stream; + +use Psr\Http\Message\StreamInterface; + +/** + * Decorator to make any stream seekable. + * + * Internally it buffers an existing StreamInterface into a php://temp resource (or memory). By default it will use + * 2 megabytes of memory before writing to a temporary disk file. + * + * Due to this, very large stream can suffer performance issue (i/o slowdown). + */ +class BufferedStream implements StreamInterface +{ + /** @var resource The buffered resource used to seek previous data */ + private $resource; + + /** @var int size of the stream if available */ + private $size; + + /** @var StreamInterface The underlying stream decorated by this class */ + private $stream; + + /** @var int How many bytes were written */ + private $written = 0; + + /** + * @param StreamInterface $stream Decorated stream + * @param bool $useFileBuffer Whether to use a file buffer (write to a file, if data exceed a certain size) + * by default, set this to false to only use memory + * @param int $memoryBuffer In conjunction with using file buffer, limit (in bytes) from which it begins to buffer + * the data in a file + */ + public function __construct(StreamInterface $stream, $useFileBuffer = true, $memoryBuffer = 2097152) + { + $this->stream = $stream; + $this->size = $stream->getSize(); + + if ($useFileBuffer) { + $this->resource = fopen('php://temp/maxmemory:'.$memoryBuffer, 'rw+'); + } else { + $this->resource = fopen('php://memory', 'rw+'); + } + + if (false === $this->resource) { + throw new \RuntimeException('Cannot create a resource over temp or memory implementation'); + } + } + + /** + * {@inheritdoc} + */ + public function __toString() + { + try { + $this->rewind(); + + return $this->getContents(); + } catch (\Throwable $throwable) { + return ''; + } catch (\Exception $exception) { // Layer to be BC with PHP 5, remove this when we only support PHP 7+ + return ''; + } + } + + /** + * {@inheritdoc} + */ + public function close() + { + if (null === $this->resource) { + throw new \RuntimeException('Cannot close on a detached stream'); + } + + $this->stream->close(); + fclose($this->resource); + } + + /** + * {@inheritdoc} + */ + public function detach() + { + if (null === $this->resource) { + return; + } + + // Force reading the remaining data of the stream + $this->getContents(); + + $resource = $this->resource; + $this->stream->close(); + $this->stream = null; + $this->resource = null; + + return $resource; + } + + /** + * {@inheritdoc} + */ + public function getSize() + { + if (null === $this->resource) { + return; + } + + if (null === $this->size && $this->stream->eof()) { + return $this->written; + } + + return $this->size; + } + + /** + * {@inheritdoc} + */ + public function tell() + { + if (null === $this->resource) { + throw new \RuntimeException('Cannot tell on a detached stream'); + } + + return ftell($this->resource); + } + + /** + * {@inheritdoc} + */ + public function eof() + { + if (null === $this->resource) { + throw new \RuntimeException('Cannot call eof on a detached stream'); + } + + // We are at the end only when both our resource and underlying stream are at eof + return $this->stream->eof() && (ftell($this->resource) === $this->written); + } + + /** + * {@inheritdoc} + */ + public function isSeekable() + { + return null !== $this->resource; + } + + /** + * {@inheritdoc} + */ + public function seek($offset, $whence = SEEK_SET) + { + if (null === $this->resource) { + throw new \RuntimeException('Cannot seek on a detached stream'); + } + + fseek($this->resource, $offset, $whence); + } + + /** + * {@inheritdoc} + */ + public function rewind() + { + if (null === $this->resource) { + throw new \RuntimeException('Cannot rewind on a detached stream'); + } + + rewind($this->resource); + } + + /** + * {@inheritdoc} + */ + public function isWritable() + { + return false; + } + + /** + * {@inheritdoc} + */ + public function write($string) + { + throw new \RuntimeException('Cannot write on this stream'); + } + + /** + * {@inheritdoc} + */ + public function isReadable() + { + return null !== $this->resource; + } + + /** + * {@inheritdoc} + */ + public function read($length) + { + if (null === $this->resource) { + throw new \RuntimeException('Cannot read on a detached stream'); + } + + $read = ''; + + // First read from the resource + if (ftell($this->resource) !== $this->written) { + $read = fread($this->resource, $length); + } + + $bytesRead = strlen($read); + + if ($bytesRead < $length) { + $streamRead = $this->stream->read($length - $bytesRead); + + // Write on the underlying stream what we read + $this->written += fwrite($this->resource, $streamRead); + $read .= $streamRead; + } + + return $read; + } + + /** + * {@inheritdoc} + */ + public function getContents() + { + if (null === $this->resource) { + throw new \RuntimeException('Cannot read on a detached stream'); + } + + $read = ''; + + while (!$this->eof()) { + $read .= $this->read(8192); + } + + return $read; + } + + /** + * {@inheritdoc} + */ + public function getMetadata($key = null) + { + if (null === $this->resource) { + if (null === $key) { + return []; + } + + return; + } + + $metadata = stream_get_meta_data($this->resource); + + if (null === $key) { + return $metadata; + } + + if (!array_key_exists($key, $metadata)) { + return; + } + + return $metadata[$key]; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/StreamFactory/DiactorosStreamFactory.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/StreamFactory/DiactorosStreamFactory.php new file mode 100644 index 0000000..a75ec98 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/StreamFactory/DiactorosStreamFactory.php @@ -0,0 +1,36 @@ +<?php + +namespace Http\Message\StreamFactory; + +use Http\Message\StreamFactory; +use Psr\Http\Message\StreamInterface; +use Zend\Diactoros\Stream; + +/** + * Creates Diactoros streams. + * + * @author Михаил Красильников <m.krasilnikov@yandex.ru> + */ +final class DiactorosStreamFactory implements StreamFactory +{ + /** + * {@inheritdoc} + */ + public function createStream($body = null) + { + if ($body instanceof StreamInterface) { + return $body; + } + + if (is_resource($body)) { + return new Stream($body); + } + + $stream = new Stream('php://memory', 'rw'); + if (null !== $body && '' !== $body) { + $stream->write((string) $body); + } + + return $stream; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/StreamFactory/GuzzleStreamFactory.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/StreamFactory/GuzzleStreamFactory.php new file mode 100644 index 0000000..10f4d3f --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/StreamFactory/GuzzleStreamFactory.php @@ -0,0 +1,21 @@ +<?php + +namespace Http\Message\StreamFactory; + +use Http\Message\StreamFactory; + +/** + * Creates Guzzle streams. + * + * @author Михаил Красильников <m.krasilnikov@yandex.ru> + */ +final class GuzzleStreamFactory implements StreamFactory +{ + /** + * {@inheritdoc} + */ + public function createStream($body = null) + { + return \GuzzleHttp\Psr7\stream_for($body); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/StreamFactory/SlimStreamFactory.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/StreamFactory/SlimStreamFactory.php new file mode 100644 index 0000000..efcadc4 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/StreamFactory/SlimStreamFactory.php @@ -0,0 +1,37 @@ +<?php + +namespace Http\Message\StreamFactory; + +use Http\Message\StreamFactory; +use Psr\Http\Message\StreamInterface; +use Slim\Http\Stream; + +/** + * Creates Slim 3 streams. + * + * @author Mika Tuupola <tuupola@appelsiini.net> + */ +final class SlimStreamFactory implements StreamFactory +{ + /** + * {@inheritdoc} + */ + public function createStream($body = null) + { + if ($body instanceof StreamInterface) { + return $body; + } + + if (is_resource($body)) { + return new Stream($body); + } + + $resource = fopen('php://memory', 'r+'); + $stream = new Stream($resource); + if (null !== $body && '' !== $body) { + $stream->write((string) $body); + } + + return $stream; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/UriFactory/DiactorosUriFactory.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/UriFactory/DiactorosUriFactory.php new file mode 100644 index 0000000..268c361 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/UriFactory/DiactorosUriFactory.php @@ -0,0 +1,29 @@ +<?php + +namespace Http\Message\UriFactory; + +use Http\Message\UriFactory; +use Psr\Http\Message\UriInterface; +use Zend\Diactoros\Uri; + +/** + * Creates Diactoros URI. + * + * @author David de Boer <david@ddeboer.nl> + */ +final class DiactorosUriFactory implements UriFactory +{ + /** + * {@inheritdoc} + */ + public function createUri($uri) + { + if ($uri instanceof UriInterface) { + return $uri; + } elseif (is_string($uri)) { + return new Uri($uri); + } + + throw new \InvalidArgumentException('URI must be a string or UriInterface'); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/UriFactory/GuzzleUriFactory.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/UriFactory/GuzzleUriFactory.php new file mode 100644 index 0000000..4c1c286 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/UriFactory/GuzzleUriFactory.php @@ -0,0 +1,22 @@ +<?php + +namespace Http\Message\UriFactory; + +use GuzzleHttp\Psr7; +use Http\Message\UriFactory; + +/** + * Creates Guzzle URI. + * + * @author David de Boer <david@ddeboer.nl> + */ +final class GuzzleUriFactory implements UriFactory +{ + /** + * {@inheritdoc} + */ + public function createUri($uri) + { + return Psr7\uri_for($uri); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/UriFactory/SlimUriFactory.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/UriFactory/SlimUriFactory.php new file mode 100644 index 0000000..c013d54 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/UriFactory/SlimUriFactory.php @@ -0,0 +1,31 @@ +<?php + +namespace Http\Message\UriFactory; + +use Http\Message\UriFactory; +use Psr\Http\Message\UriInterface; +use Slim\Http\Uri; + +/** + * Creates Slim 3 URI. + * + * @author Mika Tuupola <tuupola@appelsiini.net> + */ +final class SlimUriFactory implements UriFactory +{ + /** + * {@inheritdoc} + */ + public function createUri($uri) + { + if ($uri instanceof UriInterface) { + return $uri; + } + + if (is_string($uri)) { + return Uri::createFromString($uri); + } + + throw new \InvalidArgumentException('URI must be a string or UriInterface'); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/filters.php b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/filters.php new file mode 100644 index 0000000..15ed73d --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/message/src/filters.php @@ -0,0 +1,6 @@ +<?php + +// Register chunk filter if not found +if (!array_key_exists('chunk', stream_get_filters())) { + stream_filter_register('chunk', 'Http\Message\Encoding\Filter\Chunk'); +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/multipart-stream-builder/CHANGELOG.md b/Postman/Postman-Mail/mailgun/vendor/php-http/multipart-stream-builder/CHANGELOG.md new file mode 100644 index 0000000..1f0ee3d --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/multipart-stream-builder/CHANGELOG.md @@ -0,0 +1,60 @@ +# Change Log + +## 1.0.0 - 2017-05-21 + +No changes from 0.2.0. + +## 0.2.0 - 2017-02-20 + +You may do a BC update to version 0.2.0 if you are sure that you are not adding +multiple resources with the same name to the Builder. + +### Fixed + +- Make sure one can add resources with same name without overwrite. + +## 0.1.6 - 2017-02-16 + +### Fixed + +- Performance improvements by avoid using `uniqid()`. + +## 0.1.5 - 2017-02-14 + +### Fixed + +- Support for non-readable streams. This fix was needed because flaws in Guzzle, Zend and Slims implementations of PSR-7. + +## 0.1.4 - 2016-12-31 + +### Added + +- Added support for resetting the builder + +## 0.1.3 - 2016-12-22 + +### Added + +- Added `CustomMimetypeHelper` to allow you to configure custom mimetypes. + +### Changed + +- Using regular expression instead of `basename($filename)` because basename is depending on locale. + +## 0.1.2 - 2016-08-31 + +### Added + +- Support for Outlook msg files. + +## 0.1.1 - 2016-08-10 + +### Added + +- Support for Apple passbook. + +## 0.1.0 - 2016-07-19 + +### Added + +- Initial release diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/multipart-stream-builder/LICENSE b/Postman/Postman-Mail/mailgun/vendor/php-http/multipart-stream-builder/LICENSE new file mode 100644 index 0000000..8e2c4a0 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/multipart-stream-builder/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2015 PHP HTTP Team <team@php-http.org> + +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/Postman/Postman-Mail/mailgun/vendor/php-http/multipart-stream-builder/README.md b/Postman/Postman-Mail/mailgun/vendor/php-http/multipart-stream-builder/README.md new file mode 100644 index 0000000..10ad058 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/multipart-stream-builder/README.md @@ -0,0 +1,37 @@ +# PSR-7 Multipart Stream Builder + +[![Latest Version](https://img.shields.io/github/release/php-http/multipart-stream-builder.svg?style=flat-square)](https://github.com/php-http/multipart-stream-builder/releases) +[![Build Status](https://img.shields.io/travis/php-http/multipart-stream-builder.svg?style=flat-square)](https://travis-ci.org/php-http/multipart-stream-builder) +[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/php-http/multipart-stream-builder.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/multipart-stream-builder) +[![Quality Score](https://img.shields.io/scrutinizer/g/php-http/multipart-stream-builder.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/multipart-stream-builder) +[![Total Downloads](https://img.shields.io/packagist/dt/php-http/multipart-stream-builder.svg?style=flat-square)](https://packagist.org/packages/php-http/multipart-stream-builder) + +**A builder for Multipart PSR-7 Streams. The builder create streams independenly form any PSR-7 implementation.** + + +## Install + +Via Composer + +``` bash +$ composer require php-http/multipart-stream-builder +``` + +## Documentation + +Please see the [official documentation](http://php-http.readthedocs.org/en/latest/components/multipart-stream-builder.html). + + +## Contributing + +Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details. + + +## Security + +If you discover any security related issues, please contact us at [security@php-http.org](mailto:security@php-http.org). + + +## License + +The MIT License (MIT). Please see [License File](LICENSE) for more information. diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/multipart-stream-builder/appveyor.yml b/Postman/Postman-Mail/mailgun/vendor/php-http/multipart-stream-builder/appveyor.yml new file mode 100644 index 0000000..8d7af73 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/multipart-stream-builder/appveyor.yml @@ -0,0 +1,39 @@ +build: false +platform: + - x86 + - x64 + +clone_folder: c:\projects\php-http\multipart-stream-builder + +cache: + - c:\tools\php -> appveyor.yml + +init: + - SET PATH=c:\php;%PATH% + - SET COMPOSER_NO_INTERACTION=1 + - SET PHP=1 + + +install: + - IF EXIST c:\php (SET PHP=0) ELSE (mkdir c:\php) + - cd c:\php + - IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/releases/archives/php-7.0.0-nts-Win32-VC14-x86.zip + - IF %PHP%==1 7z x php-7.0.0-nts-Win32-VC14-x86.zip -y >nul + - IF %PHP%==1 del /Q *.zip + - IF %PHP%==1 echo @php %%~dp0composer.phar %%* > composer.bat + - IF %PHP%==1 copy /Y php.ini-development php.ini + - IF %PHP%==1 echo max_execution_time=1200 >> php.ini + - IF %PHP%==1 echo date.timezone="UTC" >> php.ini + - IF %PHP%==1 echo extension_dir=ext >> php.ini + - IF %PHP%==1 echo extension=php_openssl.dll >> php.ini + - IF %PHP%==1 echo extension=php_mbstring.dll >> php.ini + - IF %PHP%==1 echo extension=php_fileinfo.dll >> php.ini + - appveyor DownloadFile https://getcomposer.org/composer.phar + - cd c:\projects\php-http\multipart-stream-builder + - mkdir %APPDATA%\Composer + - composer update --prefer-dist --no-progress --ansi + +test_script: + - cd c:\projects\php-http\multipart-stream-builder + - vendor\bin\phpunit.bat --verbose + diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/multipart-stream-builder/composer.json b/Postman/Postman-Mail/mailgun/vendor/php-http/multipart-stream-builder/composer.json new file mode 100644 index 0000000..1ada360 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/multipart-stream-builder/composer.json @@ -0,0 +1,43 @@ +{ + "name": "php-http/multipart-stream-builder", + "description": "A builder class that help you create a multipart stream", + "license": "MIT", + "keywords": ["http", "factory", "message", "stream", "multipart stream"], + "homepage": "http://php-http.org", + "authors": [ + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com" + } + ], + "require": { + "php": "^5.5 || ^7.0", + "psr/http-message": "^1.0", + "php-http/message-factory": "^1.0.2", + "php-http/discovery": "^1.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8 || ^5.4", + "php-http/message": "^1.5", + "zendframework/zend-diactoros": "^1.3.5" + }, + "autoload": { + "psr-4": { + "Http\\Message\\MultipartStream\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "tests\\Http\\Message\\MultipartStream\\": "tests/" + } + }, + "scripts": { + "test": "vendor/bin/phpunit", + "test-ci": "vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml" + }, + "extra": { + "branch-alias": { + "dev-master": "0.3-dev" + } + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/multipart-stream-builder/src/ApacheMimetypeHelper.php b/Postman/Postman-Mail/mailgun/vendor/php-http/multipart-stream-builder/src/ApacheMimetypeHelper.php new file mode 100644 index 0000000..6e4ca66 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/multipart-stream-builder/src/ApacheMimetypeHelper.php @@ -0,0 +1,142 @@ +<?php + +namespace Http\Message\MultipartStream; + +/** + * This class helps to find the proper mime types. The source of this file is taken + * from Guzzle. + * + * @author Michael Dowling and contributors to guzzlehttp/psr7 + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +class ApacheMimetypeHelper implements MimetypeHelper +{ + /** + * {@inheritdoc} + * + * @see http://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x/conf/mime.types + */ + public function getMimetypeFromFilename($filename) + { + return $this->getMimetypeFromExtension(pathinfo($filename, PATHINFO_EXTENSION)); + } + + /** + * {@inheritdoc} + * + * @see http://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x/conf/mime.types + */ + public function getMimetypeFromExtension($extension) + { + static $mimetypes = [ + '7z' => 'application/x-7z-compressed', + 'aac' => 'audio/x-aac', + 'ai' => 'application/postscript', + 'aif' => 'audio/x-aiff', + 'asc' => 'text/plain', + 'asf' => 'video/x-ms-asf', + 'atom' => 'application/atom+xml', + 'avi' => 'video/x-msvideo', + 'bmp' => 'image/bmp', + 'bz2' => 'application/x-bzip2', + 'cer' => 'application/pkix-cert', + 'crl' => 'application/pkix-crl', + 'crt' => 'application/x-x509-ca-cert', + 'css' => 'text/css', + 'csv' => 'text/csv', + 'cu' => 'application/cu-seeme', + 'deb' => 'application/x-debian-package', + 'doc' => 'application/msword', + 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'dvi' => 'application/x-dvi', + 'eot' => 'application/vnd.ms-fontobject', + 'eps' => 'application/postscript', + 'epub' => 'application/epub+zip', + 'etx' => 'text/x-setext', + 'flac' => 'audio/flac', + 'flv' => 'video/x-flv', + 'gif' => 'image/gif', + 'gz' => 'application/gzip', + 'htm' => 'text/html', + 'html' => 'text/html', + 'ico' => 'image/x-icon', + 'ics' => 'text/calendar', + 'ini' => 'text/plain', + 'iso' => 'application/x-iso9660-image', + 'jar' => 'application/java-archive', + 'jpe' => 'image/jpeg', + 'jpeg' => 'image/jpeg', + 'jpg' => 'image/jpeg', + 'js' => 'text/javascript', + 'json' => 'application/json', + 'latex' => 'application/x-latex', + 'log' => 'text/plain', + 'm4a' => 'audio/mp4', + 'm4v' => 'video/mp4', + 'mid' => 'audio/midi', + 'midi' => 'audio/midi', + 'mov' => 'video/quicktime', + 'mp3' => 'audio/mpeg', + 'mp4' => 'video/mp4', + 'mp4a' => 'audio/mp4', + 'mp4v' => 'video/mp4', + 'mpe' => 'video/mpeg', + 'mpeg' => 'video/mpeg', + 'mpg' => 'video/mpeg', + 'mpg4' => 'video/mp4', + 'oga' => 'audio/ogg', + 'ogg' => 'audio/ogg', + 'ogv' => 'video/ogg', + 'ogx' => 'application/ogg', + 'pbm' => 'image/x-portable-bitmap', + 'pdf' => 'application/pdf', + 'pgm' => 'image/x-portable-graymap', + 'png' => 'image/png', + 'pnm' => 'image/x-portable-anymap', + 'ppm' => 'image/x-portable-pixmap', + 'ppt' => 'application/vnd.ms-powerpoint', + 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'ps' => 'application/postscript', + 'qt' => 'video/quicktime', + 'rar' => 'application/x-rar-compressed', + 'ras' => 'image/x-cmu-raster', + 'rss' => 'application/rss+xml', + 'rtf' => 'application/rtf', + 'sgm' => 'text/sgml', + 'sgml' => 'text/sgml', + 'svg' => 'image/svg+xml', + 'swf' => 'application/x-shockwave-flash', + 'tar' => 'application/x-tar', + 'tif' => 'image/tiff', + 'tiff' => 'image/tiff', + 'torrent' => 'application/x-bittorrent', + 'ttf' => 'application/x-font-ttf', + 'txt' => 'text/plain', + 'wav' => 'audio/x-wav', + 'webm' => 'video/webm', + 'wma' => 'audio/x-ms-wma', + 'wmv' => 'video/x-ms-wmv', + 'woff' => 'application/x-font-woff', + 'wsdl' => 'application/wsdl+xml', + 'xbm' => 'image/x-xbitmap', + 'xls' => 'application/vnd.ms-excel', + 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'xml' => 'application/xml', + 'xpm' => 'image/x-xpixmap', + 'xwd' => 'image/x-xwindowdump', + 'yaml' => 'text/yaml', + 'yml' => 'text/yaml', + 'zip' => 'application/zip', + + // Non-Apache standard + 'pkpass' => 'application/vnd.apple.pkpass', + 'msg' => 'application/vnd.ms-outlook', + ]; + + $extension = strtolower($extension); + + return isset($mimetypes[$extension]) + ? $mimetypes[$extension] + : null; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/multipart-stream-builder/src/CustomMimetypeHelper.php b/Postman/Postman-Mail/mailgun/vendor/php-http/multipart-stream-builder/src/CustomMimetypeHelper.php new file mode 100644 index 0000000..9f3f0d9 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/multipart-stream-builder/src/CustomMimetypeHelper.php @@ -0,0 +1,51 @@ +<?php + +namespace Http\Message\MultipartStream; + +/** + * Let you add your own mimetypes. The mimetype lookup will fallback on the ApacheMimeTypeHelper. + * + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +class CustomMimetypeHelper extends ApacheMimetypeHelper +{ + /** + * @var array + */ + private $mimetypes = []; + + /** + * @param array $mimetypes should be of type extension => mimetype + */ + public function __construct(array $mimetypes = []) + { + $this->mimetypes = $mimetypes; + } + + /** + * @param string $extension + * @param string $mimetype + * + * @return $this + */ + public function addMimetype($extension, $mimetype) + { + $this->mimetypes[$extension] = $mimetype; + + return $this; + } + + /** + * {@inheritdoc} + * + * Check if we have any defined mimetypes and of not fallback to ApacheMimetypeHelper + */ + public function getMimetypeFromExtension($extension) + { + $extension = strtolower($extension); + + return isset($this->mimetypes[$extension]) + ? $this->mimetypes[$extension] + : parent::getMimetypeFromExtension($extension); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/multipart-stream-builder/src/MimetypeHelper.php b/Postman/Postman-Mail/mailgun/vendor/php-http/multipart-stream-builder/src/MimetypeHelper.php new file mode 100644 index 0000000..fa7cf18 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/multipart-stream-builder/src/MimetypeHelper.php @@ -0,0 +1,27 @@ +<?php + +namespace Http\Message\MultipartStream; + +/** + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +interface MimetypeHelper +{ + /** + * Determines the mimetype of a file by looking at its extension. + * + * @param string $filename + * + * @return null|string + */ + public function getMimetypeFromFilename($filename); + + /** + * Maps a file extensions to a mimetype. + * + * @param string $extension The file extension + * + * @return string|null + */ + public function getMimetypeFromExtension($extension); +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/multipart-stream-builder/src/MultipartStreamBuilder.php b/Postman/Postman-Mail/mailgun/vendor/php-http/multipart-stream-builder/src/MultipartStreamBuilder.php new file mode 100644 index 0000000..3421d73 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/multipart-stream-builder/src/MultipartStreamBuilder.php @@ -0,0 +1,278 @@ +<?php + +namespace Http\Message\MultipartStream; + +use Http\Discovery\StreamFactoryDiscovery; +use Http\Message\StreamFactory; +use Psr\Http\Message\StreamInterface; + +/** + * Build your own Multipart stream. A Multipart stream is a collection of streams separated with a $bounary. This + * class helps you to create a Multipart stream with stream implementations from any PSR7 library. + * + * @author Michael Dowling and contributors to guzzlehttp/psr7 + * @author Tobias Nyholm <tobias.nyholm@gmail.com> + */ +class MultipartStreamBuilder +{ + /** + * @var StreamFactory + */ + private $streamFactory; + + /** + * @var MimetypeHelper + */ + private $mimetypeHelper; + + /** + * @var string + */ + private $boundary; + + /** + * @var array Element where each Element is an array with keys ['contents', 'headers', 'filename'] + */ + private $data = []; + + /** + * @param StreamFactory|null $streamFactory + */ + public function __construct(StreamFactory $streamFactory = null) + { + $this->streamFactory = $streamFactory ?: StreamFactoryDiscovery::find(); + } + + /** + * Add a resource to the Multipart Stream. + * + * @param string $name the formpost name + * @param string|resource|StreamInterface $resource + * @param array $options { + * + * @var array $headers additional headers ['header-name' => 'header-value'] + * @var string $filename + * } + * + * @return MultipartStreamBuilder + */ + public function addResource($name, $resource, array $options = []) + { + $stream = $this->streamFactory->createStream($resource); + + // validate options['headers'] exists + if (!isset($options['headers'])) { + $options['headers'] = []; + } + + // Try to add filename if it is missing + if (empty($options['filename'])) { + $options['filename'] = null; + $uri = $stream->getMetadata('uri'); + if (substr($uri, 0, 6) !== 'php://') { + $options['filename'] = $uri; + } + } + + $this->prepareHeaders($name, $stream, $options['filename'], $options['headers']); + $this->data[] = ['contents' => $stream, 'headers' => $options['headers'], 'filename' => $options['filename']]; + + return $this; + } + + /** + * Build the stream. + * + * @return StreamInterface + */ + public function build() + { + $streams = ''; + foreach ($this->data as $data) { + // Add start and headers + $streams .= "--{$this->getBoundary()}\r\n". + $this->getHeaders($data['headers'])."\r\n"; + + // Convert the stream to string + /* @var $contentStream StreamInterface */ + $contentStream = $data['contents']; + if ($contentStream->isSeekable()) { + $streams .= $contentStream->__toString(); + } else { + $streams .= $contentStream->getContents(); + } + + $streams .= "\r\n"; + } + + // Append end + $streams .= "--{$this->getBoundary()}--\r\n"; + + return $this->streamFactory->createStream($streams); + } + + /** + * Add extra headers if they are missing. + * + * @param string $name + * @param StreamInterface $stream + * @param string $filename + * @param array &$headers + */ + private function prepareHeaders($name, StreamInterface $stream, $filename, array &$headers) + { + $hasFilename = $filename === '0' || $filename; + + // Set a default content-disposition header if one was not provided + if (!$this->hasHeader($headers, 'content-disposition')) { + $headers['Content-Disposition'] = sprintf('form-data; name="%s"', $name); + if ($hasFilename) { + $headers['Content-Disposition'] .= sprintf('; filename="%s"', $this->basename($filename)); + } + } + + // Set a default content-length header if one was not provided + if (!$this->hasHeader($headers, 'content-length')) { + if ($length = $stream->getSize()) { + $headers['Content-Length'] = (string) $length; + } + } + + // Set a default Content-Type if one was not provided + if (!$this->hasHeader($headers, 'content-type') && $hasFilename) { + if ($type = $this->getMimetypeHelper()->getMimetypeFromFilename($filename)) { + $headers['Content-Type'] = $type; + } + } + } + + /** + * Get the headers formatted for the HTTP message. + * + * @param array $headers + * + * @return string + */ + private function getHeaders(array $headers) + { + $str = ''; + foreach ($headers as $key => $value) { + $str .= sprintf("%s: %s\r\n", $key, $value); + } + + return $str; + } + + /** + * Check if header exist. + * + * @param array $headers + * @param string $key case insensitive + * + * @return bool + */ + private function hasHeader(array $headers, $key) + { + $lowercaseHeader = strtolower($key); + foreach ($headers as $k => $v) { + if (strtolower($k) === $lowercaseHeader) { + return true; + } + } + + return false; + } + + /** + * Get the boundary that separates the streams. + * + * @return string + */ + public function getBoundary() + { + if ($this->boundary === null) { + $this->boundary = uniqid('', true); + } + + return $this->boundary; + } + + /** + * @param string $boundary + * + * @return MultipartStreamBuilder + */ + public function setBoundary($boundary) + { + $this->boundary = $boundary; + + return $this; + } + + /** + * @return MimetypeHelper + */ + private function getMimetypeHelper() + { + if ($this->mimetypeHelper === null) { + $this->mimetypeHelper = new ApacheMimetypeHelper(); + } + + return $this->mimetypeHelper; + } + + /** + * If you have custom file extension you may overwrite the default MimetypeHelper with your own. + * + * @param MimetypeHelper $mimetypeHelper + * + * @return MultipartStreamBuilder + */ + public function setMimetypeHelper(MimetypeHelper $mimetypeHelper) + { + $this->mimetypeHelper = $mimetypeHelper; + + return $this; + } + + /** + * Reset and clear all stored data. This allows you to use builder for a subsequent request. + * + * @return MultipartStreamBuilder + */ + public function reset() + { + $this->data = []; + $this->boundary = null; + + return $this; + } + + /** + * Gets the filename from a given path. + * + * PHP's basename() does not properly support streams or filenames beginning with a non-US-ASCII character. + * + * @author Drupal 8.2 + * + * @param string $path + * + * @return string + */ + private function basename($path) + { + $separators = '/'; + if (DIRECTORY_SEPARATOR != '/') { + // For Windows OS add special separator. + $separators .= DIRECTORY_SEPARATOR; + } + + // Remove right-most slashes when $path points to directory. + $path = rtrim($path, $separators); + + // Returns the trailing part of the $path starting after one of the directory separators. + $filename = preg_match('@[^'.preg_quote($separators, '@').']+$@', $path, $matches) ? $matches[0] : ''; + + return $filename; + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/promise/CHANGELOG.md b/Postman/Postman-Mail/mailgun/vendor/php-http/promise/CHANGELOG.md new file mode 100644 index 0000000..336e140 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/promise/CHANGELOG.md @@ -0,0 +1,35 @@ +# Change Log + + +## 1.0.0 - 2016-01-26 + +### Removed + +- PSR-7 dependency + + +## 1.0.0-RC1 - 2016-01-12 + +### Added + +- Tests for full coverage + +## Changed + +- Updated package files +- Clarified wait method behavior +- Contributing guide moved to the documentation + + +## 0.1.1 - 2015-12-24 + +## Added + +- Fulfilled and Rejected promise implementations + + +## 0.1.0 - 2015-12-13 + +## Added + +- Promise interface diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/promise/LICENSE b/Postman/Postman-Mail/mailgun/vendor/php-http/promise/LICENSE new file mode 100644 index 0000000..4558d6f --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/promise/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2015-2016 PHP HTTP Team <team@php-http.org> + +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/Postman/Postman-Mail/mailgun/vendor/php-http/promise/README.md b/Postman/Postman-Mail/mailgun/vendor/php-http/promise/README.md new file mode 100644 index 0000000..adda2ae --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/promise/README.md @@ -0,0 +1,49 @@ +# Promise + +[![Latest Version](https://img.shields.io/github/release/php-http/promise.svg?style=flat-square)](https://github.com/php-http/promise/releases) +[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) +[![Build Status](https://img.shields.io/travis/php-http/promise.svg?style=flat-square)](https://travis-ci.org/php-http/promise) +[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/php-http/promise.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/promise) +[![Quality Score](https://img.shields.io/scrutinizer/g/php-http/promise.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/promise) +[![Total Downloads](https://img.shields.io/packagist/dt/php-http/promise.svg?style=flat-square)](https://packagist.org/packages/php-http/promise) + +**Promise used for asynchronous HTTP requests.** + +**Note:** This will eventually be removed/deprecated and replaced with the upcoming Promise PSR. + + +## Install + +Via Composer + +``` bash +$ composer require php-http/promise +``` + + +## Documentation + +Please see the [official documentation](http://docs.php-http.org). + + +## Testing + +``` bash +$ composer test +``` + + +## Contributing + +Please see our [contributing guide](http://docs.php-http.org/en/latest/development/contributing.html). + + +## Security + +If you discover any security related issues, please contact us at [security@httplug.io](mailto:security@httplug.io) +or [security@php-http.org](mailto:security@php-http.org). + + +## License + +The MIT License (MIT). Please see [License File](LICENSE) for more information. diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/promise/composer.json b/Postman/Postman-Mail/mailgun/vendor/php-http/promise/composer.json new file mode 100644 index 0000000..ff1d2ce --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/promise/composer.json @@ -0,0 +1,35 @@ +{ + "name": "php-http/promise", + "description": "Promise used for asynchronous HTTP requests", + "license": "MIT", + "keywords": ["promise"], + "homepage": "http://httplug.io", + "authors": [ + { + "name": "Joel Wurtz", + "email": "joel.wurtz@gmail.com" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "require-dev": { + "phpspec/phpspec": "^2.4", + "henrikbjorn/phpspec-code-coverage" : "^1.0" + }, + "autoload": { + "psr-4": { + "Http\\Promise\\": "src/" + } + }, + "scripts": { + "test": "vendor/bin/phpspec run", + "test-ci": "vendor/bin/phpspec run -c phpspec.yml.ci" + }, + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/promise/src/FulfilledPromise.php b/Postman/Postman-Mail/mailgun/vendor/php-http/promise/src/FulfilledPromise.php new file mode 100644 index 0000000..f60f686 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/promise/src/FulfilledPromise.php @@ -0,0 +1,58 @@ +<?php + +namespace Http\Promise; + +/** + * A promise already fulfilled. + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +final class FulfilledPromise implements Promise +{ + /** + * @var mixed + */ + private $result; + + /** + * @param $result + */ + public function __construct($result) + { + $this->result = $result; + } + + /** + * {@inheritdoc} + */ + public function then(callable $onFulfilled = null, callable $onRejected = null) + { + if (null === $onFulfilled) { + return $this; + } + + try { + return new self($onFulfilled($this->result)); + } catch (\Exception $e) { + return new RejectedPromise($e); + } + } + + /** + * {@inheritdoc} + */ + public function getState() + { + return Promise::FULFILLED; + } + + /** + * {@inheritdoc} + */ + public function wait($unwrap = true) + { + if ($unwrap) { + return $this->result; + } + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/promise/src/Promise.php b/Postman/Postman-Mail/mailgun/vendor/php-http/promise/src/Promise.php new file mode 100644 index 0000000..e2cf5f8 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/promise/src/Promise.php @@ -0,0 +1,69 @@ +<?php + +namespace Http\Promise; + +/** + * Promise represents a value that may not be available yet, but will be resolved at some point in future. + * It acts like a proxy to the actual value. + * + * This interface is an extension of the promises/a+ specification. + * + * @see https://promisesaplus.com/ + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + * @author Márk Sági-Kazár <mark.sagikazar@gmail.com> + */ +interface Promise +{ + /** + * Promise has not been fulfilled or rejected. + */ + const PENDING = 'pending'; + + /** + * Promise has been fulfilled. + */ + const FULFILLED = 'fulfilled'; + + /** + * Promise has been rejected. + */ + const REJECTED = 'rejected'; + + /** + * Adds behavior for when the promise is resolved or rejected (response will be available, or error happens). + * + * If you do not care about one of the cases, you can set the corresponding callable to null + * The callback will be called when the value arrived and never more than once. + * + * @param callable $onFulfilled Called when a response will be available. + * @param callable $onRejected Called when an exception occurs. + * + * @return Promise A new resolved promise with value of the executed callback (onFulfilled / onRejected). + */ + public function then(callable $onFulfilled = null, callable $onRejected = null); + + /** + * Returns the state of the promise, one of PENDING, FULFILLED or REJECTED. + * + * @return string + */ + public function getState(); + + /** + * Wait for the promise to be fulfilled or rejected. + * + * When this method returns, the request has been resolved and if callables have been + * specified, the appropriate one has terminated. + * + * When $unwrap is true (the default), the response is returned, or the exception thrown + * on failure. Otherwise, nothing is returned or thrown. + * + * @param bool $unwrap Whether to return resolved value / throw reason or not + * + * @return mixed Resolved value, null if $unwrap is set to false + * + * @throws \Exception The rejection reason if $unwrap is set to true and the request failed. + */ + public function wait($unwrap = true); +} diff --git a/Postman/Postman-Mail/mailgun/vendor/php-http/promise/src/RejectedPromise.php b/Postman/Postman-Mail/mailgun/vendor/php-http/promise/src/RejectedPromise.php new file mode 100644 index 0000000..e396a40 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/php-http/promise/src/RejectedPromise.php @@ -0,0 +1,58 @@ +<?php + +namespace Http\Promise; + +/** + * A rejected promise. + * + * @author Joel Wurtz <joel.wurtz@gmail.com> + */ +final class RejectedPromise implements Promise +{ + /** + * @var \Exception + */ + private $exception; + + /** + * @param \Exception $exception + */ + public function __construct(\Exception $exception) + { + $this->exception = $exception; + } + + /** + * {@inheritdoc} + */ + public function then(callable $onFulfilled = null, callable $onRejected = null) + { + if (null === $onRejected) { + return $this; + } + + try { + return new FulfilledPromise($onRejected($this->exception)); + } catch (\Exception $e) { + return new self($e); + } + } + + /** + * {@inheritdoc} + */ + public function getState() + { + return Promise::REJECTED; + } + + /** + * {@inheritdoc} + */ + public function wait($unwrap = true) + { + if ($unwrap) { + throw $this->exception; + } + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/psr/http-message/CHANGELOG.md b/Postman/Postman-Mail/mailgun/vendor/psr/http-message/CHANGELOG.md new file mode 100644 index 0000000..74b1ef9 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/psr/http-message/CHANGELOG.md @@ -0,0 +1,36 @@ +# Changelog + +All notable changes to this project will be documented in this file, in reverse chronological order by release. + +## 1.0.1 - 2016-08-06 + +### Added + +- Nothing. + +### Deprecated + +- Nothing. + +### Removed + +- Nothing. + +### Fixed + +- Updated all `@return self` annotation references in interfaces to use + `@return static`, which more closelly follows the semantics of the + specification. +- Updated the `MessageInterface::getHeaders()` return annotation to use the + value `string[][]`, indicating the format is a nested array of strings. +- Updated the `@link` annotation for `RequestInterface::withRequestTarget()` + to point to the correct section of RFC 7230. +- Updated the `ServerRequestInterface::withUploadedFiles()` parameter annotation + to add the parameter name (`$uploadedFiles`). +- Updated a `@throws` annotation for the `UploadedFileInterface::moveTo()` + method to correctly reference the method parameter (it was referencing an + incorrect parameter name previously). + +## 1.0.0 - 2016-05-18 + +Initial stable release; reflects accepted PSR-7 specification. diff --git a/Postman/Postman-Mail/mailgun/vendor/psr/http-message/LICENSE b/Postman/Postman-Mail/mailgun/vendor/psr/http-message/LICENSE new file mode 100644 index 0000000..c2d8e45 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/psr/http-message/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2014 PHP Framework Interoperability Group + +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/Postman/Postman-Mail/mailgun/vendor/psr/http-message/README.md b/Postman/Postman-Mail/mailgun/vendor/psr/http-message/README.md new file mode 100644 index 0000000..2818533 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/psr/http-message/README.md @@ -0,0 +1,13 @@ +PSR Http Message +================ + +This repository holds all interfaces/classes/traits related to +[PSR-7](http://www.php-fig.org/psr/psr-7/). + +Note that this is not a HTTP message implementation of its own. It is merely an +interface that describes a HTTP message. See the specification for more details. + +Usage +----- + +We'll certainly need some stuff in here.
\ No newline at end of file diff --git a/Postman/Postman-Mail/mailgun/vendor/psr/http-message/composer.json b/Postman/Postman-Mail/mailgun/vendor/psr/http-message/composer.json new file mode 100644 index 0000000..b0d2937 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/psr/http-message/composer.json @@ -0,0 +1,26 @@ +{ + "name": "psr/http-message", + "description": "Common interface for HTTP messages", + "keywords": ["psr", "psr-7", "http", "http-message", "request", "response"], + "homepage": "https://github.com/php-fig/http-message", + "license": "MIT", + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "require": { + "php": ">=5.3.0" + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/psr/http-message/src/MessageInterface.php b/Postman/Postman-Mail/mailgun/vendor/psr/http-message/src/MessageInterface.php new file mode 100644 index 0000000..dd46e5e --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/psr/http-message/src/MessageInterface.php @@ -0,0 +1,187 @@ +<?php + +namespace Psr\Http\Message; + +/** + * HTTP messages consist of requests from a client to a server and responses + * from a server to a client. This interface defines the methods common to + * each. + * + * Messages are considered immutable; all methods that might change state MUST + * be implemented such that they retain the internal state of the current + * message and return an instance that contains the changed state. + * + * @link http://www.ietf.org/rfc/rfc7230.txt + * @link http://www.ietf.org/rfc/rfc7231.txt + */ +interface MessageInterface +{ + /** + * Retrieves the HTTP protocol version as a string. + * + * The string MUST contain only the HTTP version number (e.g., "1.1", "1.0"). + * + * @return string HTTP protocol version. + */ + public function getProtocolVersion(); + + /** + * Return an instance with the specified HTTP protocol version. + * + * The version string MUST contain only the HTTP version number (e.g., + * "1.1", "1.0"). + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * new protocol version. + * + * @param string $version HTTP protocol version + * @return static + */ + public function withProtocolVersion($version); + + /** + * Retrieves all message header values. + * + * The keys represent the header name as it will be sent over the wire, and + * each value is an array of strings associated with the header. + * + * // Represent the headers as a string + * foreach ($message->getHeaders() as $name => $values) { + * echo $name . ": " . implode(", ", $values); + * } + * + * // Emit headers iteratively: + * foreach ($message->getHeaders() as $name => $values) { + * foreach ($values as $value) { + * header(sprintf('%s: %s', $name, $value), false); + * } + * } + * + * While header names are not case-sensitive, getHeaders() will preserve the + * exact case in which headers were originally specified. + * + * @return string[][] Returns an associative array of the message's headers. Each + * key MUST be a header name, and each value MUST be an array of strings + * for that header. + */ + public function getHeaders(); + + /** + * Checks if a header exists by the given case-insensitive name. + * + * @param string $name Case-insensitive header field name. + * @return bool Returns true if any header names match the given header + * name using a case-insensitive string comparison. Returns false if + * no matching header name is found in the message. + */ + public function hasHeader($name); + + /** + * Retrieves a message header value by the given case-insensitive name. + * + * This method returns an array of all the header values of the given + * case-insensitive header name. + * + * If the header does not appear in the message, this method MUST return an + * empty array. + * + * @param string $name Case-insensitive header field name. + * @return string[] An array of string values as provided for the given + * header. If the header does not appear in the message, this method MUST + * return an empty array. + */ + public function getHeader($name); + + /** + * Retrieves a comma-separated string of the values for a single header. + * + * This method returns all of the header values of the given + * case-insensitive header name as a string concatenated together using + * a comma. + * + * NOTE: Not all header values may be appropriately represented using + * comma concatenation. For such headers, use getHeader() instead + * and supply your own delimiter when concatenating. + * + * If the header does not appear in the message, this method MUST return + * an empty string. + * + * @param string $name Case-insensitive header field name. + * @return string A string of values as provided for the given header + * concatenated together using a comma. If the header does not appear in + * the message, this method MUST return an empty string. + */ + public function getHeaderLine($name); + + /** + * Return an instance with the provided value replacing the specified header. + * + * While header names are case-insensitive, the casing of the header will + * be preserved by this function, and returned from getHeaders(). + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * new and/or updated header and value. + * + * @param string $name Case-insensitive header field name. + * @param string|string[] $value Header value(s). + * @return static + * @throws \InvalidArgumentException for invalid header names or values. + */ + public function withHeader($name, $value); + + /** + * Return an instance with the specified header appended with the given value. + * + * Existing values for the specified header will be maintained. The new + * value(s) will be appended to the existing list. If the header did not + * exist previously, it will be added. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * new header and/or value. + * + * @param string $name Case-insensitive header field name to add. + * @param string|string[] $value Header value(s). + * @return static + * @throws \InvalidArgumentException for invalid header names or values. + */ + public function withAddedHeader($name, $value); + + /** + * Return an instance without the specified header. + * + * Header resolution MUST be done without case-sensitivity. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that removes + * the named header. + * + * @param string $name Case-insensitive header field name to remove. + * @return static + */ + public function withoutHeader($name); + + /** + * Gets the body of the message. + * + * @return StreamInterface Returns the body as a stream. + */ + public function getBody(); + + /** + * Return an instance with the specified message body. + * + * The body MUST be a StreamInterface object. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return a new instance that has the + * new body stream. + * + * @param StreamInterface $body Body. + * @return static + * @throws \InvalidArgumentException When the body is not valid. + */ + public function withBody(StreamInterface $body); +} diff --git a/Postman/Postman-Mail/mailgun/vendor/psr/http-message/src/RequestInterface.php b/Postman/Postman-Mail/mailgun/vendor/psr/http-message/src/RequestInterface.php new file mode 100644 index 0000000..a96d4fd --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/psr/http-message/src/RequestInterface.php @@ -0,0 +1,129 @@ +<?php + +namespace Psr\Http\Message; + +/** + * Representation of an outgoing, client-side request. + * + * Per the HTTP specification, this interface includes properties for + * each of the following: + * + * - Protocol version + * - HTTP method + * - URI + * - Headers + * - Message body + * + * During construction, implementations MUST attempt to set the Host header from + * a provided URI if no Host header is provided. + * + * Requests are considered immutable; all methods that might change state MUST + * be implemented such that they retain the internal state of the current + * message and return an instance that contains the changed state. + */ +interface RequestInterface extends MessageInterface +{ + /** + * Retrieves the message's request target. + * + * Retrieves the message's request-target either as it will appear (for + * clients), as it appeared at request (for servers), or as it was + * specified for the instance (see withRequestTarget()). + * + * In most cases, this will be the origin-form of the composed URI, + * unless a value was provided to the concrete implementation (see + * withRequestTarget() below). + * + * If no URI is available, and no request-target has been specifically + * provided, this method MUST return the string "/". + * + * @return string + */ + public function getRequestTarget(); + + /** + * Return an instance with the specific request-target. + * + * If the request needs a non-origin-form request-target — e.g., for + * specifying an absolute-form, authority-form, or asterisk-form — + * this method may be used to create an instance with the specified + * request-target, verbatim. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * changed request target. + * + * @link http://tools.ietf.org/html/rfc7230#section-5.3 (for the various + * request-target forms allowed in request messages) + * @param mixed $requestTarget + * @return static + */ + public function withRequestTarget($requestTarget); + + /** + * Retrieves the HTTP method of the request. + * + * @return string Returns the request method. + */ + public function getMethod(); + + /** + * Return an instance with the provided HTTP method. + * + * While HTTP method names are typically all uppercase characters, HTTP + * method names are case-sensitive and thus implementations SHOULD NOT + * modify the given string. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * changed request method. + * + * @param string $method Case-sensitive method. + * @return static + * @throws \InvalidArgumentException for invalid HTTP methods. + */ + public function withMethod($method); + + /** + * Retrieves the URI instance. + * + * This method MUST return a UriInterface instance. + * + * @link http://tools.ietf.org/html/rfc3986#section-4.3 + * @return UriInterface Returns a UriInterface instance + * representing the URI of the request. + */ + public function getUri(); + + /** + * Returns an instance with the provided URI. + * + * This method MUST update the Host header of the returned request by + * default if the URI contains a host component. If the URI does not + * contain a host component, any pre-existing Host header MUST be carried + * over to the returned request. + * + * You can opt-in to preserving the original state of the Host header by + * setting `$preserveHost` to `true`. When `$preserveHost` is set to + * `true`, this method interacts with the Host header in the following ways: + * + * - If the Host header is missing or empty, and the new URI contains + * a host component, this method MUST update the Host header in the returned + * request. + * - If the Host header is missing or empty, and the new URI does not contain a + * host component, this method MUST NOT update the Host header in the returned + * request. + * - If a Host header is present and non-empty, this method MUST NOT update + * the Host header in the returned request. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * new UriInterface instance. + * + * @link http://tools.ietf.org/html/rfc3986#section-4.3 + * @param UriInterface $uri New request URI to use. + * @param bool $preserveHost Preserve the original state of the Host header. + * @return static + */ + public function withUri(UriInterface $uri, $preserveHost = false); +} diff --git a/Postman/Postman-Mail/mailgun/vendor/psr/http-message/src/ResponseInterface.php b/Postman/Postman-Mail/mailgun/vendor/psr/http-message/src/ResponseInterface.php new file mode 100644 index 0000000..c306514 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/psr/http-message/src/ResponseInterface.php @@ -0,0 +1,68 @@ +<?php + +namespace Psr\Http\Message; + +/** + * Representation of an outgoing, server-side response. + * + * Per the HTTP specification, this interface includes properties for + * each of the following: + * + * - Protocol version + * - Status code and reason phrase + * - Headers + * - Message body + * + * Responses are considered immutable; all methods that might change state MUST + * be implemented such that they retain the internal state of the current + * message and return an instance that contains the changed state. + */ +interface ResponseInterface extends MessageInterface +{ + /** + * Gets the response status code. + * + * The status code is a 3-digit integer result code of the server's attempt + * to understand and satisfy the request. + * + * @return int Status code. + */ + public function getStatusCode(); + + /** + * Return an instance with the specified status code and, optionally, reason phrase. + * + * If no reason phrase is specified, implementations MAY choose to default + * to the RFC 7231 or IANA recommended reason phrase for the response's + * status code. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * updated status and reason phrase. + * + * @link http://tools.ietf.org/html/rfc7231#section-6 + * @link http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml + * @param int $code The 3-digit integer result code to set. + * @param string $reasonPhrase The reason phrase to use with the + * provided status code; if none is provided, implementations MAY + * use the defaults as suggested in the HTTP specification. + * @return static + * @throws \InvalidArgumentException For invalid status code arguments. + */ + public function withStatus($code, $reasonPhrase = ''); + + /** + * Gets the response reason phrase associated with the status code. + * + * Because a reason phrase is not a required element in a response + * status line, the reason phrase value MAY be null. Implementations MAY + * choose to return the default RFC 7231 recommended reason phrase (or those + * listed in the IANA HTTP Status Code Registry) for the response's + * status code. + * + * @link http://tools.ietf.org/html/rfc7231#section-6 + * @link http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml + * @return string Reason phrase; must return an empty string if none present. + */ + public function getReasonPhrase(); +} diff --git a/Postman/Postman-Mail/mailgun/vendor/psr/http-message/src/ServerRequestInterface.php b/Postman/Postman-Mail/mailgun/vendor/psr/http-message/src/ServerRequestInterface.php new file mode 100644 index 0000000..0251234 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/psr/http-message/src/ServerRequestInterface.php @@ -0,0 +1,261 @@ +<?php + +namespace Psr\Http\Message; + +/** + * Representation of an incoming, server-side HTTP request. + * + * Per the HTTP specification, this interface includes properties for + * each of the following: + * + * - Protocol version + * - HTTP method + * - URI + * - Headers + * - Message body + * + * Additionally, it encapsulates all data as it has arrived to the + * application from the CGI and/or PHP environment, including: + * + * - The values represented in $_SERVER. + * - Any cookies provided (generally via $_COOKIE) + * - Query string arguments (generally via $_GET, or as parsed via parse_str()) + * - Upload files, if any (as represented by $_FILES) + * - Deserialized body parameters (generally from $_POST) + * + * $_SERVER values MUST be treated as immutable, as they represent application + * state at the time of request; as such, no methods are provided to allow + * modification of those values. The other values provide such methods, as they + * can be restored from $_SERVER or the request body, and may need treatment + * during the application (e.g., body parameters may be deserialized based on + * content type). + * + * Additionally, this interface recognizes the utility of introspecting a + * request to derive and match additional parameters (e.g., via URI path + * matching, decrypting cookie values, deserializing non-form-encoded body + * content, matching authorization headers to users, etc). These parameters + * are stored in an "attributes" property. + * + * Requests are considered immutable; all methods that might change state MUST + * be implemented such that they retain the internal state of the current + * message and return an instance that contains the changed state. + */ +interface ServerRequestInterface extends RequestInterface +{ + /** + * Retrieve server parameters. + * + * Retrieves data related to the incoming request environment, + * typically derived from PHP's $_SERVER superglobal. The data IS NOT + * REQUIRED to originate from $_SERVER. + * + * @return array + */ + public function getServerParams(); + + /** + * Retrieve cookies. + * + * Retrieves cookies sent by the client to the server. + * + * The data MUST be compatible with the structure of the $_COOKIE + * superglobal. + * + * @return array + */ + public function getCookieParams(); + + /** + * Return an instance with the specified cookies. + * + * The data IS NOT REQUIRED to come from the $_COOKIE superglobal, but MUST + * be compatible with the structure of $_COOKIE. Typically, this data will + * be injected at instantiation. + * + * This method MUST NOT update the related Cookie header of the request + * instance, nor related values in the server params. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * updated cookie values. + * + * @param array $cookies Array of key/value pairs representing cookies. + * @return static + */ + public function withCookieParams(array $cookies); + + /** + * Retrieve query string arguments. + * + * Retrieves the deserialized query string arguments, if any. + * + * Note: the query params might not be in sync with the URI or server + * params. If you need to ensure you are only getting the original + * values, you may need to parse the query string from `getUri()->getQuery()` + * or from the `QUERY_STRING` server param. + * + * @return array + */ + public function getQueryParams(); + + /** + * Return an instance with the specified query string arguments. + * + * These values SHOULD remain immutable over the course of the incoming + * request. They MAY be injected during instantiation, such as from PHP's + * $_GET superglobal, or MAY be derived from some other value such as the + * URI. In cases where the arguments are parsed from the URI, the data + * MUST be compatible with what PHP's parse_str() would return for + * purposes of how duplicate query parameters are handled, and how nested + * sets are handled. + * + * Setting query string arguments MUST NOT change the URI stored by the + * request, nor the values in the server params. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * updated query string arguments. + * + * @param array $query Array of query string arguments, typically from + * $_GET. + * @return static + */ + public function withQueryParams(array $query); + + /** + * Retrieve normalized file upload data. + * + * This method returns upload metadata in a normalized tree, with each leaf + * an instance of Psr\Http\Message\UploadedFileInterface. + * + * These values MAY be prepared from $_FILES or the message body during + * instantiation, or MAY be injected via withUploadedFiles(). + * + * @return array An array tree of UploadedFileInterface instances; an empty + * array MUST be returned if no data is present. + */ + public function getUploadedFiles(); + + /** + * Create a new instance with the specified uploaded files. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * updated body parameters. + * + * @param array $uploadedFiles An array tree of UploadedFileInterface instances. + * @return static + * @throws \InvalidArgumentException if an invalid structure is provided. + */ + public function withUploadedFiles(array $uploadedFiles); + + /** + * Retrieve any parameters provided in the request body. + * + * If the request Content-Type is either application/x-www-form-urlencoded + * or multipart/form-data, and the request method is POST, this method MUST + * return the contents of $_POST. + * + * Otherwise, this method may return any results of deserializing + * the request body content; as parsing returns structured content, the + * potential types MUST be arrays or objects only. A null value indicates + * the absence of body content. + * + * @return null|array|object The deserialized body parameters, if any. + * These will typically be an array or object. + */ + public function getParsedBody(); + + /** + * Return an instance with the specified body parameters. + * + * These MAY be injected during instantiation. + * + * If the request Content-Type is either application/x-www-form-urlencoded + * or multipart/form-data, and the request method is POST, use this method + * ONLY to inject the contents of $_POST. + * + * The data IS NOT REQUIRED to come from $_POST, but MUST be the results of + * deserializing the request body content. Deserialization/parsing returns + * structured data, and, as such, this method ONLY accepts arrays or objects, + * or a null value if nothing was available to parse. + * + * As an example, if content negotiation determines that the request data + * is a JSON payload, this method could be used to create a request + * instance with the deserialized parameters. + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * updated body parameters. + * + * @param null|array|object $data The deserialized body data. This will + * typically be in an array or object. + * @return static + * @throws \InvalidArgumentException if an unsupported argument type is + * provided. + */ + public function withParsedBody($data); + + /** + * Retrieve attributes derived from the request. + * + * The request "attributes" may be used to allow injection of any + * parameters derived from the request: e.g., the results of path + * match operations; the results of decrypting cookies; the results of + * deserializing non-form-encoded message bodies; etc. Attributes + * will be application and request specific, and CAN be mutable. + * + * @return array Attributes derived from the request. + */ + public function getAttributes(); + + /** + * Retrieve a single derived request attribute. + * + * Retrieves a single derived request attribute as described in + * getAttributes(). If the attribute has not been previously set, returns + * the default value as provided. + * + * This method obviates the need for a hasAttribute() method, as it allows + * specifying a default value to return if the attribute is not found. + * + * @see getAttributes() + * @param string $name The attribute name. + * @param mixed $default Default value to return if the attribute does not exist. + * @return mixed + */ + public function getAttribute($name, $default = null); + + /** + * Return an instance with the specified derived request attribute. + * + * This method allows setting a single derived request attribute as + * described in getAttributes(). + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that has the + * updated attribute. + * + * @see getAttributes() + * @param string $name The attribute name. + * @param mixed $value The value of the attribute. + * @return static + */ + public function withAttribute($name, $value); + + /** + * Return an instance that removes the specified derived request attribute. + * + * This method allows removing a single derived request attribute as + * described in getAttributes(). + * + * This method MUST be implemented in such a way as to retain the + * immutability of the message, and MUST return an instance that removes + * the attribute. + * + * @see getAttributes() + * @param string $name The attribute name. + * @return static + */ + public function withoutAttribute($name); +} diff --git a/Postman/Postman-Mail/mailgun/vendor/psr/http-message/src/StreamInterface.php b/Postman/Postman-Mail/mailgun/vendor/psr/http-message/src/StreamInterface.php new file mode 100644 index 0000000..f68f391 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/psr/http-message/src/StreamInterface.php @@ -0,0 +1,158 @@ +<?php + +namespace Psr\Http\Message; + +/** + * Describes a data stream. + * + * Typically, an instance will wrap a PHP stream; this interface provides + * a wrapper around the most common operations, including serialization of + * the entire stream to a string. + */ +interface StreamInterface +{ + /** + * Reads all data from the stream into a string, from the beginning to end. + * + * This method MUST attempt to seek to the beginning of the stream before + * reading data and read the stream until the end is reached. + * + * Warning: This could attempt to load a large amount of data into memory. + * + * This method MUST NOT raise an exception in order to conform with PHP's + * string casting operations. + * + * @see http://php.net/manual/en/language.oop5.magic.php#object.tostring + * @return string + */ + public function __toString(); + + /** + * Closes the stream and any underlying resources. + * + * @return void + */ + public function close(); + + /** + * Separates any underlying resources from the stream. + * + * After the stream has been detached, the stream is in an unusable state. + * + * @return resource|null Underlying PHP stream, if any + */ + public function detach(); + + /** + * Get the size of the stream if known. + * + * @return int|null Returns the size in bytes if known, or null if unknown. + */ + public function getSize(); + + /** + * Returns the current position of the file read/write pointer + * + * @return int Position of the file pointer + * @throws \RuntimeException on error. + */ + public function tell(); + + /** + * Returns true if the stream is at the end of the stream. + * + * @return bool + */ + public function eof(); + + /** + * Returns whether or not the stream is seekable. + * + * @return bool + */ + public function isSeekable(); + + /** + * Seek to a position in the stream. + * + * @link http://www.php.net/manual/en/function.fseek.php + * @param int $offset Stream offset + * @param int $whence Specifies how the cursor position will be calculated + * based on the seek offset. Valid values are identical to the built-in + * PHP $whence values for `fseek()`. SEEK_SET: Set position equal to + * offset bytes SEEK_CUR: Set position to current location plus offset + * SEEK_END: Set position to end-of-stream plus offset. + * @throws \RuntimeException on failure. + */ + public function seek($offset, $whence = SEEK_SET); + + /** + * Seek to the beginning of the stream. + * + * If the stream is not seekable, this method will raise an exception; + * otherwise, it will perform a seek(0). + * + * @see seek() + * @link http://www.php.net/manual/en/function.fseek.php + * @throws \RuntimeException on failure. + */ + public function rewind(); + + /** + * Returns whether or not the stream is writable. + * + * @return bool + */ + public function isWritable(); + + /** + * Write data to the stream. + * + * @param string $string The string that is to be written. + * @return int Returns the number of bytes written to the stream. + * @throws \RuntimeException on failure. + */ + public function write($string); + + /** + * Returns whether or not the stream is readable. + * + * @return bool + */ + public function isReadable(); + + /** + * Read data from the stream. + * + * @param int $length Read up to $length bytes from the object and return + * them. Fewer than $length bytes may be returned if underlying stream + * call returns fewer bytes. + * @return string Returns the data read from the stream, or an empty string + * if no bytes are available. + * @throws \RuntimeException if an error occurs. + */ + public function read($length); + + /** + * Returns the remaining contents in a string + * + * @return string + * @throws \RuntimeException if unable to read or an error occurs while + * reading. + */ + public function getContents(); + + /** + * Get stream metadata as an associative array or retrieve a specific key. + * + * The keys returned are identical to the keys returned from PHP's + * stream_get_meta_data() function. + * + * @link http://php.net/manual/en/function.stream-get-meta-data.php + * @param string $key Specific metadata to retrieve. + * @return array|mixed|null Returns an associative array if no key is + * provided. Returns a specific key value if a key is provided and the + * value is found, or null if the key is not found. + */ + public function getMetadata($key = null); +} diff --git a/Postman/Postman-Mail/mailgun/vendor/psr/http-message/src/UploadedFileInterface.php b/Postman/Postman-Mail/mailgun/vendor/psr/http-message/src/UploadedFileInterface.php new file mode 100644 index 0000000..f8a6901 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/psr/http-message/src/UploadedFileInterface.php @@ -0,0 +1,123 @@ +<?php + +namespace Psr\Http\Message; + +/** + * Value object representing a file uploaded through an HTTP request. + * + * Instances of this interface are considered immutable; all methods that + * might change state MUST be implemented such that they retain the internal + * state of the current instance and return an instance that contains the + * changed state. + */ +interface UploadedFileInterface +{ + /** + * Retrieve a stream representing the uploaded file. + * + * This method MUST return a StreamInterface instance, representing the + * uploaded file. The purpose of this method is to allow utilizing native PHP + * stream functionality to manipulate the file upload, such as + * stream_copy_to_stream() (though the result will need to be decorated in a + * native PHP stream wrapper to work with such functions). + * + * If the moveTo() method has been called previously, this method MUST raise + * an exception. + * + * @return StreamInterface Stream representation of the uploaded file. + * @throws \RuntimeException in cases when no stream is available or can be + * created. + */ + public function getStream(); + + /** + * Move the uploaded file to a new location. + * + * Use this method as an alternative to move_uploaded_file(). This method is + * guaranteed to work in both SAPI and non-SAPI environments. + * Implementations must determine which environment they are in, and use the + * appropriate method (move_uploaded_file(), rename(), or a stream + * operation) to perform the operation. + * + * $targetPath may be an absolute path, or a relative path. If it is a + * relative path, resolution should be the same as used by PHP's rename() + * function. + * + * The original file or stream MUST be removed on completion. + * + * If this method is called more than once, any subsequent calls MUST raise + * an exception. + * + * When used in an SAPI environment where $_FILES is populated, when writing + * files via moveTo(), is_uploaded_file() and move_uploaded_file() SHOULD be + * used to ensure permissions and upload status are verified correctly. + * + * If you wish to move to a stream, use getStream(), as SAPI operations + * cannot guarantee writing to stream destinations. + * + * @see http://php.net/is_uploaded_file + * @see http://php.net/move_uploaded_file + * @param string $targetPath Path to which to move the uploaded file. + * @throws \InvalidArgumentException if the $targetPath specified is invalid. + * @throws \RuntimeException on any error during the move operation, or on + * the second or subsequent call to the method. + */ + public function moveTo($targetPath); + + /** + * Retrieve the file size. + * + * Implementations SHOULD return the value stored in the "size" key of + * the file in the $_FILES array if available, as PHP calculates this based + * on the actual size transmitted. + * + * @return int|null The file size in bytes or null if unknown. + */ + public function getSize(); + + /** + * Retrieve the error associated with the uploaded file. + * + * The return value MUST be one of PHP's UPLOAD_ERR_XXX constants. + * + * If the file was uploaded successfully, this method MUST return + * UPLOAD_ERR_OK. + * + * Implementations SHOULD return the value stored in the "error" key of + * the file in the $_FILES array. + * + * @see http://php.net/manual/en/features.file-upload.errors.php + * @return int One of PHP's UPLOAD_ERR_XXX constants. + */ + public function getError(); + + /** + * Retrieve the filename sent by the client. + * + * Do not trust the value returned by this method. A client could send + * a malicious filename with the intention to corrupt or hack your + * application. + * + * Implementations SHOULD return the value stored in the "name" key of + * the file in the $_FILES array. + * + * @return string|null The filename sent by the client or null if none + * was provided. + */ + public function getClientFilename(); + + /** + * Retrieve the media type sent by the client. + * + * Do not trust the value returned by this method. A client could send + * a malicious media type with the intention to corrupt or hack your + * application. + * + * Implementations SHOULD return the value stored in the "type" key of + * the file in the $_FILES array. + * + * @return string|null The media type sent by the client or null if none + * was provided. + */ + public function getClientMediaType(); +} diff --git a/Postman/Postman-Mail/mailgun/vendor/psr/http-message/src/UriInterface.php b/Postman/Postman-Mail/mailgun/vendor/psr/http-message/src/UriInterface.php new file mode 100644 index 0000000..9d7ab9e --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/psr/http-message/src/UriInterface.php @@ -0,0 +1,323 @@ +<?php +namespace Psr\Http\Message; + +/** + * Value object representing a URI. + * + * This interface is meant to represent URIs according to RFC 3986 and to + * provide methods for most common operations. Additional functionality for + * working with URIs can be provided on top of the interface or externally. + * Its primary use is for HTTP requests, but may also be used in other + * contexts. + * + * Instances of this interface are considered immutable; all methods that + * might change state MUST be implemented such that they retain the internal + * state of the current instance and return an instance that contains the + * changed state. + * + * Typically the Host header will be also be present in the request message. + * For server-side requests, the scheme will typically be discoverable in the + * server parameters. + * + * @link http://tools.ietf.org/html/rfc3986 (the URI specification) + */ +interface UriInterface +{ + /** + * Retrieve the scheme component of the URI. + * + * If no scheme is present, this method MUST return an empty string. + * + * The value returned MUST be normalized to lowercase, per RFC 3986 + * Section 3.1. + * + * The trailing ":" character is not part of the scheme and MUST NOT be + * added. + * + * @see https://tools.ietf.org/html/rfc3986#section-3.1 + * @return string The URI scheme. + */ + public function getScheme(); + + /** + * Retrieve the authority component of the URI. + * + * If no authority information is present, this method MUST return an empty + * string. + * + * The authority syntax of the URI is: + * + * <pre> + * [user-info@]host[:port] + * </pre> + * + * If the port component is not set or is the standard port for the current + * scheme, it SHOULD NOT be included. + * + * @see https://tools.ietf.org/html/rfc3986#section-3.2 + * @return string The URI authority, in "[user-info@]host[:port]" format. + */ + public function getAuthority(); + + /** + * Retrieve the user information component of the URI. + * + * If no user information is present, this method MUST return an empty + * string. + * + * If a user is present in the URI, this will return that value; + * additionally, if the password is also present, it will be appended to the + * user value, with a colon (":") separating the values. + * + * The trailing "@" character is not part of the user information and MUST + * NOT be added. + * + * @return string The URI user information, in "username[:password]" format. + */ + public function getUserInfo(); + + /** + * Retrieve the host component of the URI. + * + * If no host is present, this method MUST return an empty string. + * + * The value returned MUST be normalized to lowercase, per RFC 3986 + * Section 3.2.2. + * + * @see http://tools.ietf.org/html/rfc3986#section-3.2.2 + * @return string The URI host. + */ + public function getHost(); + + /** + * Retrieve the port component of the URI. + * + * If a port is present, and it is non-standard for the current scheme, + * this method MUST return it as an integer. If the port is the standard port + * used with the current scheme, this method SHOULD return null. + * + * If no port is present, and no scheme is present, this method MUST return + * a null value. + * + * If no port is present, but a scheme is present, this method MAY return + * the standard port for that scheme, but SHOULD return null. + * + * @return null|int The URI port. + */ + public function getPort(); + + /** + * Retrieve the path component of the URI. + * + * The path can either be empty or absolute (starting with a slash) or + * rootless (not starting with a slash). Implementations MUST support all + * three syntaxes. + * + * Normally, the empty path "" and absolute path "/" are considered equal as + * defined in RFC 7230 Section 2.7.3. But this method MUST NOT automatically + * do this normalization because in contexts with a trimmed base path, e.g. + * the front controller, this difference becomes significant. It's the task + * of the user to handle both "" and "/". + * + * The value returned MUST be percent-encoded, but MUST NOT double-encode + * any characters. To determine what characters to encode, please refer to + * RFC 3986, Sections 2 and 3.3. + * + * As an example, if the value should include a slash ("/") not intended as + * delimiter between path segments, that value MUST be passed in encoded + * form (e.g., "%2F") to the instance. + * + * @see https://tools.ietf.org/html/rfc3986#section-2 + * @see https://tools.ietf.org/html/rfc3986#section-3.3 + * @return string The URI path. + */ + public function getPath(); + + /** + * Retrieve the query string of the URI. + * + * If no query string is present, this method MUST return an empty string. + * + * The leading "?" character is not part of the query and MUST NOT be + * added. + * + * The value returned MUST be percent-encoded, but MUST NOT double-encode + * any characters. To determine what characters to encode, please refer to + * RFC 3986, Sections 2 and 3.4. + * + * As an example, if a value in a key/value pair of the query string should + * include an ampersand ("&") not intended as a delimiter between values, + * that value MUST be passed in encoded form (e.g., "%26") to the instance. + * + * @see https://tools.ietf.org/html/rfc3986#section-2 + * @see https://tools.ietf.org/html/rfc3986#section-3.4 + * @return string The URI query string. + */ + public function getQuery(); + + /** + * Retrieve the fragment component of the URI. + * + * If no fragment is present, this method MUST return an empty string. + * + * The leading "#" character is not part of the fragment and MUST NOT be + * added. + * + * The value returned MUST be percent-encoded, but MUST NOT double-encode + * any characters. To determine what characters to encode, please refer to + * RFC 3986, Sections 2 and 3.5. + * + * @see https://tools.ietf.org/html/rfc3986#section-2 + * @see https://tools.ietf.org/html/rfc3986#section-3.5 + * @return string The URI fragment. + */ + public function getFragment(); + + /** + * Return an instance with the specified scheme. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified scheme. + * + * Implementations MUST support the schemes "http" and "https" case + * insensitively, and MAY accommodate other schemes if required. + * + * An empty scheme is equivalent to removing the scheme. + * + * @param string $scheme The scheme to use with the new instance. + * @return static A new instance with the specified scheme. + * @throws \InvalidArgumentException for invalid or unsupported schemes. + */ + public function withScheme($scheme); + + /** + * Return an instance with the specified user information. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified user information. + * + * Password is optional, but the user information MUST include the + * user; an empty string for the user is equivalent to removing user + * information. + * + * @param string $user The user name to use for authority. + * @param null|string $password The password associated with $user. + * @return static A new instance with the specified user information. + */ + public function withUserInfo($user, $password = null); + + /** + * Return an instance with the specified host. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified host. + * + * An empty host value is equivalent to removing the host. + * + * @param string $host The hostname to use with the new instance. + * @return static A new instance with the specified host. + * @throws \InvalidArgumentException for invalid hostnames. + */ + public function withHost($host); + + /** + * Return an instance with the specified port. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified port. + * + * Implementations MUST raise an exception for ports outside the + * established TCP and UDP port ranges. + * + * A null value provided for the port is equivalent to removing the port + * information. + * + * @param null|int $port The port to use with the new instance; a null value + * removes the port information. + * @return static A new instance with the specified port. + * @throws \InvalidArgumentException for invalid ports. + */ + public function withPort($port); + + /** + * Return an instance with the specified path. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified path. + * + * The path can either be empty or absolute (starting with a slash) or + * rootless (not starting with a slash). Implementations MUST support all + * three syntaxes. + * + * If the path is intended to be domain-relative rather than path relative then + * it must begin with a slash ("/"). Paths not starting with a slash ("/") + * are assumed to be relative to some base path known to the application or + * consumer. + * + * Users can provide both encoded and decoded path characters. + * Implementations ensure the correct encoding as outlined in getPath(). + * + * @param string $path The path to use with the new instance. + * @return static A new instance with the specified path. + * @throws \InvalidArgumentException for invalid paths. + */ + public function withPath($path); + + /** + * Return an instance with the specified query string. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified query string. + * + * Users can provide both encoded and decoded query characters. + * Implementations ensure the correct encoding as outlined in getQuery(). + * + * An empty query string value is equivalent to removing the query string. + * + * @param string $query The query string to use with the new instance. + * @return static A new instance with the specified query string. + * @throws \InvalidArgumentException for invalid query strings. + */ + public function withQuery($query); + + /** + * Return an instance with the specified URI fragment. + * + * This method MUST retain the state of the current instance, and return + * an instance that contains the specified URI fragment. + * + * Users can provide both encoded and decoded fragment characters. + * Implementations ensure the correct encoding as outlined in getFragment(). + * + * An empty fragment value is equivalent to removing the fragment. + * + * @param string $fragment The fragment to use with the new instance. + * @return static A new instance with the specified fragment. + */ + public function withFragment($fragment); + + /** + * Return the string representation as a URI reference. + * + * Depending on which components of the URI are present, the resulting + * string is either a full URI or relative reference according to RFC 3986, + * Section 4.1. The method concatenates the various components of the URI, + * using the appropriate delimiters: + * + * - If a scheme is present, it MUST be suffixed by ":". + * - If an authority is present, it MUST be prefixed by "//". + * - The path can be concatenated without delimiters. But there are two + * cases where the path has to be adjusted to make the URI reference + * valid as PHP does not allow to throw an exception in __toString(): + * - If the path is rootless and an authority is present, the path MUST + * be prefixed by "/". + * - If the path is starting with more than one "/" and no authority is + * present, the starting slashes MUST be reduced to one. + * - If a query is present, it MUST be prefixed by "?". + * - If a fragment is present, it MUST be prefixed by "#". + * + * @see http://tools.ietf.org/html/rfc3986#section-4.1 + * @return string + */ + public function __toString(); +} diff --git a/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/.gitignore b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/.gitignore new file mode 100644 index 0000000..c49a5d8 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/.gitignore @@ -0,0 +1,3 @@ +vendor/ +composer.lock +phpunit.xml diff --git a/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/CHANGELOG.md b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/CHANGELOG.md new file mode 100644 index 0000000..c8f0244 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/CHANGELOG.md @@ -0,0 +1,52 @@ +CHANGELOG +========= + +3.4.0 +----- + + * added `OptionsResolverIntrospector` to inspect options definitions inside an `OptionsResolver` instance + * added array of types support in allowed types (e.g int[]) + +2.6.0 +----- + + * deprecated OptionsResolverInterface + * [BC BREAK] removed "array" type hint from OptionsResolverInterface methods + setRequired(), setAllowedValues(), addAllowedValues(), setAllowedTypes() and + addAllowedTypes() + * added OptionsResolver::setDefault() + * added OptionsResolver::hasDefault() + * added OptionsResolver::setNormalizer() + * added OptionsResolver::isRequired() + * added OptionsResolver::getRequiredOptions() + * added OptionsResolver::isMissing() + * added OptionsResolver::getMissingOptions() + * added OptionsResolver::setDefined() + * added OptionsResolver::isDefined() + * added OptionsResolver::getDefinedOptions() + * added OptionsResolver::remove() + * added OptionsResolver::clear() + * deprecated OptionsResolver::replaceDefaults() + * deprecated OptionsResolver::setOptional() in favor of setDefined() + * deprecated OptionsResolver::isKnown() in favor of isDefined() + * [BC BREAK] OptionsResolver::isRequired() returns true now if a required + option has a default value set + * [BC BREAK] merged Options into OptionsResolver and turned Options into an + interface + * deprecated Options::overload() (now in OptionsResolver) + * deprecated Options::set() (now in OptionsResolver) + * deprecated Options::get() (now in OptionsResolver) + * deprecated Options::has() (now in OptionsResolver) + * deprecated Options::replace() (now in OptionsResolver) + * [BC BREAK] Options::get() (now in OptionsResolver) can only be used within + lazy option/normalizer closures now + * [BC BREAK] removed Traversable interface from Options since using within + lazy option/normalizer closures resulted in exceptions + * [BC BREAK] removed Options::all() since using within lazy option/normalizer + closures resulted in exceptions + * [BC BREAK] OptionDefinitionException now extends LogicException instead of + RuntimeException + * [BC BREAK] normalizers are not executed anymore for unset options + * normalizers are executed after validating the options now + * [BC BREAK] an UndefinedOptionsException is now thrown instead of an + InvalidOptionsException when non-existing options are passed diff --git a/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Debug/OptionsResolverIntrospector.php b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Debug/OptionsResolverIntrospector.php new file mode 100644 index 0000000..6031724 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Debug/OptionsResolverIntrospector.php @@ -0,0 +1,102 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\OptionsResolver\Debug; + +use Symfony\Component\OptionsResolver\Exception\NoConfigurationException; +use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException; +use Symfony\Component\OptionsResolver\OptionsResolver; + +/** + * @author Maxime Steinhausser <maxime.steinhausser@gmail.com> + * + * @final + */ +class OptionsResolverIntrospector +{ + private $get; + + public function __construct(OptionsResolver $optionsResolver) + { + $this->get = \Closure::bind(function ($property, $option, $message) { + /** @var OptionsResolver $this */ + if (!$this->isDefined($option)) { + throw new UndefinedOptionsException(sprintf('The option "%s" does not exist.', $option)); + } + + if (!array_key_exists($option, $this->{$property})) { + throw new NoConfigurationException($message); + } + + return $this->{$property}[$option]; + }, $optionsResolver, $optionsResolver); + } + + /** + * @param string $option + * + * @return mixed + * + * @throws NoConfigurationException on no configured value + */ + public function getDefault($option) + { + return call_user_func($this->get, 'defaults', $option, sprintf('No default value was set for the "%s" option.', $option)); + } + + /** + * @param string $option + * + * @return \Closure[] + * + * @throws NoConfigurationException on no configured closures + */ + public function getLazyClosures($option) + { + return call_user_func($this->get, 'lazy', $option, sprintf('No lazy closures were set for the "%s" option.', $option)); + } + + /** + * @param string $option + * + * @return string[] + * + * @throws NoConfigurationException on no configured types + */ + public function getAllowedTypes($option) + { + return call_user_func($this->get, 'allowedTypes', $option, sprintf('No allowed types were set for the "%s" option.', $option)); + } + + /** + * @param string $option + * + * @return mixed[] + * + * @throws NoConfigurationException on no configured values + */ + public function getAllowedValues($option) + { + return call_user_func($this->get, 'allowedValues', $option, sprintf('No allowed values were set for the "%s" option.', $option)); + } + + /** + * @param string $option + * + * @return \Closure + * + * @throws NoConfigurationException on no configured normalizer + */ + public function getNormalizer($option) + { + return call_user_func($this->get, 'normalizers', $option, sprintf('No normalizer was set for the "%s" option.', $option)); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Exception/AccessException.php b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Exception/AccessException.php new file mode 100644 index 0000000..c12b680 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Exception/AccessException.php @@ -0,0 +1,22 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\OptionsResolver\Exception; + +/** + * Thrown when trying to read an option outside of or write it inside of + * {@link \Symfony\Component\OptionsResolver\Options::resolve()}. + * + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class AccessException extends \LogicException implements ExceptionInterface +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Exception/ExceptionInterface.php b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Exception/ExceptionInterface.php new file mode 100644 index 0000000..b62bb51 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Exception/ExceptionInterface.php @@ -0,0 +1,21 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\OptionsResolver\Exception; + +/** + * Marker interface for all exceptions thrown by the OptionsResolver component. + * + * @author Bernhard Schussek <bschussek@gmail.com> + */ +interface ExceptionInterface +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Exception/InvalidArgumentException.php b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Exception/InvalidArgumentException.php new file mode 100644 index 0000000..6d421d6 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Exception/InvalidArgumentException.php @@ -0,0 +1,21 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\OptionsResolver\Exception; + +/** + * Thrown when an argument is invalid. + * + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Exception/InvalidOptionsException.php b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Exception/InvalidOptionsException.php new file mode 100644 index 0000000..6fd4f12 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Exception/InvalidOptionsException.php @@ -0,0 +1,23 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\OptionsResolver\Exception; + +/** + * Thrown when the value of an option does not match its validation rules. + * + * You should make sure a valid value is passed to the option. + * + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class InvalidOptionsException extends InvalidArgumentException +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Exception/MissingOptionsException.php b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Exception/MissingOptionsException.php new file mode 100644 index 0000000..faa487f --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Exception/MissingOptionsException.php @@ -0,0 +1,23 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\OptionsResolver\Exception; + +/** + * Exception thrown when a required option is missing. + * + * Add the option to the passed options array. + * + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class MissingOptionsException extends InvalidArgumentException +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Exception/NoConfigurationException.php b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Exception/NoConfigurationException.php new file mode 100644 index 0000000..6693ec1 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Exception/NoConfigurationException.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\OptionsResolver\Exception; + +use Symfony\Component\OptionsResolver\Debug\OptionsResolverIntrospector; + +/** + * Thrown when trying to introspect an option definition property + * for which no value was configured inside the OptionsResolver instance. + * + * @see OptionsResolverIntrospector + * + * @author Maxime Steinhausser <maxime.steinhausser@gmail.com> + */ +class NoConfigurationException extends \RuntimeException implements ExceptionInterface +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Exception/NoSuchOptionException.php b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Exception/NoSuchOptionException.php new file mode 100644 index 0000000..4c3280f --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Exception/NoSuchOptionException.php @@ -0,0 +1,26 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\OptionsResolver\Exception; + +/** + * Thrown when trying to read an option that has no value set. + * + * When accessing optional options from within a lazy option or normalizer you should first + * check whether the optional option is set. You can do this with `isset($options['optional'])`. + * In contrast to the {@link UndefinedOptionsException}, this is a runtime exception that can + * occur when evaluating lazy options. + * + * @author Tobias Schultze <http://tobion.de> + */ +class NoSuchOptionException extends \OutOfBoundsException implements ExceptionInterface +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Exception/OptionDefinitionException.php b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Exception/OptionDefinitionException.php new file mode 100644 index 0000000..e8e339d --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Exception/OptionDefinitionException.php @@ -0,0 +1,21 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\OptionsResolver\Exception; + +/** + * Thrown when two lazy options have a cyclic dependency. + * + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class OptionDefinitionException extends \LogicException implements ExceptionInterface +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Exception/UndefinedOptionsException.php b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Exception/UndefinedOptionsException.php new file mode 100644 index 0000000..6ca3fce --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Exception/UndefinedOptionsException.php @@ -0,0 +1,24 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\OptionsResolver\Exception; + +/** + * Exception thrown when an undefined option is passed. + * + * You should remove the options in question from your code or define them + * beforehand. + * + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class UndefinedOptionsException extends InvalidArgumentException +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/LICENSE b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/LICENSE new file mode 100644 index 0000000..17d16a1 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2004-2017 Fabien Potencier + +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/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Options.php b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Options.php new file mode 100644 index 0000000..d444ec4 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Options.php @@ -0,0 +1,22 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\OptionsResolver; + +/** + * Contains resolved option values. + * + * @author Bernhard Schussek <bschussek@gmail.com> + * @author Tobias Schultze <http://tobion.de> + */ +interface Options extends \ArrayAccess, \Countable +{ +} diff --git a/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/OptionsResolver.php b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/OptionsResolver.php new file mode 100644 index 0000000..f5b84f0 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/OptionsResolver.php @@ -0,0 +1,1076 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\OptionsResolver; + +use Symfony\Component\OptionsResolver\Exception\AccessException; +use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; +use Symfony\Component\OptionsResolver\Exception\MissingOptionsException; +use Symfony\Component\OptionsResolver\Exception\NoSuchOptionException; +use Symfony\Component\OptionsResolver\Exception\OptionDefinitionException; +use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException; + +/** + * Validates options and merges them with default values. + * + * @author Bernhard Schussek <bschussek@gmail.com> + * @author Tobias Schultze <http://tobion.de> + */ +class OptionsResolver implements Options +{ + /** + * The names of all defined options. + */ + private $defined = array(); + + /** + * The default option values. + */ + private $defaults = array(); + + /** + * The names of required options. + */ + private $required = array(); + + /** + * The resolved option values. + */ + private $resolved = array(); + + /** + * A list of normalizer closures. + * + * @var \Closure[] + */ + private $normalizers = array(); + + /** + * A list of accepted values for each option. + */ + private $allowedValues = array(); + + /** + * A list of accepted types for each option. + */ + private $allowedTypes = array(); + + /** + * A list of closures for evaluating lazy options. + */ + private $lazy = array(); + + /** + * A list of lazy options whose closure is currently being called. + * + * This list helps detecting circular dependencies between lazy options. + */ + private $calling = array(); + + /** + * Whether the instance is locked for reading. + * + * Once locked, the options cannot be changed anymore. This is + * necessary in order to avoid inconsistencies during the resolving + * process. If any option is changed after being read, all evaluated + * lazy options that depend on this option would become invalid. + */ + private $locked = false; + + private static $typeAliases = array( + 'boolean' => 'bool', + 'integer' => 'int', + 'double' => 'float', + ); + + /** + * Sets the default value of a given option. + * + * If the default value should be set based on other options, you can pass + * a closure with the following signature: + * + * function (Options $options) { + * // ... + * } + * + * The closure will be evaluated when {@link resolve()} is called. The + * closure has access to the resolved values of other options through the + * passed {@link Options} instance: + * + * function (Options $options) { + * if (isset($options['port'])) { + * // ... + * } + * } + * + * If you want to access the previously set default value, add a second + * argument to the closure's signature: + * + * $options->setDefault('name', 'Default Name'); + * + * $options->setDefault('name', function (Options $options, $previousValue) { + * // 'Default Name' === $previousValue + * }); + * + * This is mostly useful if the configuration of the {@link Options} object + * is spread across different locations of your code, such as base and + * sub-classes. + * + * @param string $option The name of the option + * @param mixed $value The default value of the option + * + * @return $this + * + * @throws AccessException If called from a lazy option or normalizer + */ + public function setDefault($option, $value) + { + // Setting is not possible once resolving starts, because then lazy + // options could manipulate the state of the object, leading to + // inconsistent results. + if ($this->locked) { + throw new AccessException('Default values cannot be set from a lazy option or normalizer.'); + } + + // If an option is a closure that should be evaluated lazily, store it + // in the "lazy" property. + if ($value instanceof \Closure) { + $reflClosure = new \ReflectionFunction($value); + $params = $reflClosure->getParameters(); + + if (isset($params[0]) && null !== ($class = $params[0]->getClass()) && Options::class === $class->name) { + // Initialize the option if no previous value exists + if (!isset($this->defaults[$option])) { + $this->defaults[$option] = null; + } + + // Ignore previous lazy options if the closure has no second parameter + if (!isset($this->lazy[$option]) || !isset($params[1])) { + $this->lazy[$option] = array(); + } + + // Store closure for later evaluation + $this->lazy[$option][] = $value; + $this->defined[$option] = true; + + // Make sure the option is processed + unset($this->resolved[$option]); + + return $this; + } + } + + // This option is not lazy anymore + unset($this->lazy[$option]); + + // Yet undefined options can be marked as resolved, because we only need + // to resolve options with lazy closures, normalizers or validation + // rules, none of which can exist for undefined options + // If the option was resolved before, update the resolved value + if (!isset($this->defined[$option]) || array_key_exists($option, $this->resolved)) { + $this->resolved[$option] = $value; + } + + $this->defaults[$option] = $value; + $this->defined[$option] = true; + + return $this; + } + + /** + * Sets a list of default values. + * + * @param array $defaults The default values to set + * + * @return $this + * + * @throws AccessException If called from a lazy option or normalizer + */ + public function setDefaults(array $defaults) + { + foreach ($defaults as $option => $value) { + $this->setDefault($option, $value); + } + + return $this; + } + + /** + * Returns whether a default value is set for an option. + * + * Returns true if {@link setDefault()} was called for this option. + * An option is also considered set if it was set to null. + * + * @param string $option The option name + * + * @return bool Whether a default value is set + */ + public function hasDefault($option) + { + return array_key_exists($option, $this->defaults); + } + + /** + * Marks one or more options as required. + * + * @param string|string[] $optionNames One or more option names + * + * @return $this + * + * @throws AccessException If called from a lazy option or normalizer + */ + public function setRequired($optionNames) + { + if ($this->locked) { + throw new AccessException('Options cannot be made required from a lazy option or normalizer.'); + } + + foreach ((array) $optionNames as $option) { + $this->defined[$option] = true; + $this->required[$option] = true; + } + + return $this; + } + + /** + * Returns whether an option is required. + * + * An option is required if it was passed to {@link setRequired()}. + * + * @param string $option The name of the option + * + * @return bool Whether the option is required + */ + public function isRequired($option) + { + return isset($this->required[$option]); + } + + /** + * Returns the names of all required options. + * + * @return string[] The names of the required options + * + * @see isRequired() + */ + public function getRequiredOptions() + { + return array_keys($this->required); + } + + /** + * Returns whether an option is missing a default value. + * + * An option is missing if it was passed to {@link setRequired()}, but not + * to {@link setDefault()}. This option must be passed explicitly to + * {@link resolve()}, otherwise an exception will be thrown. + * + * @param string $option The name of the option + * + * @return bool Whether the option is missing + */ + public function isMissing($option) + { + return isset($this->required[$option]) && !array_key_exists($option, $this->defaults); + } + + /** + * Returns the names of all options missing a default value. + * + * @return string[] The names of the missing options + * + * @see isMissing() + */ + public function getMissingOptions() + { + return array_keys(array_diff_key($this->required, $this->defaults)); + } + + /** + * Defines a valid option name. + * + * Defines an option name without setting a default value. The option will + * be accepted when passed to {@link resolve()}. When not passed, the + * option will not be included in the resolved options. + * + * @param string|string[] $optionNames One or more option names + * + * @return $this + * + * @throws AccessException If called from a lazy option or normalizer + */ + public function setDefined($optionNames) + { + if ($this->locked) { + throw new AccessException('Options cannot be defined from a lazy option or normalizer.'); + } + + foreach ((array) $optionNames as $option) { + $this->defined[$option] = true; + } + + return $this; + } + + /** + * Returns whether an option is defined. + * + * Returns true for any option passed to {@link setDefault()}, + * {@link setRequired()} or {@link setDefined()}. + * + * @param string $option The option name + * + * @return bool Whether the option is defined + */ + public function isDefined($option) + { + return isset($this->defined[$option]); + } + + /** + * Returns the names of all defined options. + * + * @return string[] The names of the defined options + * + * @see isDefined() + */ + public function getDefinedOptions() + { + return array_keys($this->defined); + } + + /** + * Sets the normalizer for an option. + * + * The normalizer should be a closure with the following signature: + * + * ```php + * function (Options $options, $value) { + * // ... + * } + * ``` + * + * The closure is invoked when {@link resolve()} is called. The closure + * has access to the resolved values of other options through the passed + * {@link Options} instance. + * + * The second parameter passed to the closure is the value of + * the option. + * + * The resolved option value is set to the return value of the closure. + * + * @param string $option The option name + * @param \Closure $normalizer The normalizer + * + * @return $this + * + * @throws UndefinedOptionsException If the option is undefined + * @throws AccessException If called from a lazy option or normalizer + */ + public function setNormalizer($option, \Closure $normalizer) + { + if ($this->locked) { + throw new AccessException('Normalizers cannot be set from a lazy option or normalizer.'); + } + + if (!isset($this->defined[$option])) { + throw new UndefinedOptionsException(sprintf( + 'The option "%s" does not exist. Defined options are: "%s".', + $option, + implode('", "', array_keys($this->defined)) + )); + } + + $this->normalizers[$option] = $normalizer; + + // Make sure the option is processed + unset($this->resolved[$option]); + + return $this; + } + + /** + * Sets allowed values for an option. + * + * Instead of passing values, you may also pass a closures with the + * following signature: + * + * function ($value) { + * // return true or false + * } + * + * The closure receives the value as argument and should return true to + * accept the value and false to reject the value. + * + * @param string $option The option name + * @param mixed $allowedValues One or more acceptable values/closures + * + * @return $this + * + * @throws UndefinedOptionsException If the option is undefined + * @throws AccessException If called from a lazy option or normalizer + */ + public function setAllowedValues($option, $allowedValues) + { + if ($this->locked) { + throw new AccessException('Allowed values cannot be set from a lazy option or normalizer.'); + } + + if (!isset($this->defined[$option])) { + throw new UndefinedOptionsException(sprintf( + 'The option "%s" does not exist. Defined options are: "%s".', + $option, + implode('", "', array_keys($this->defined)) + )); + } + + $this->allowedValues[$option] = is_array($allowedValues) ? $allowedValues : array($allowedValues); + + // Make sure the option is processed + unset($this->resolved[$option]); + + return $this; + } + + /** + * Adds allowed values for an option. + * + * The values are merged with the allowed values defined previously. + * + * Instead of passing values, you may also pass a closures with the + * following signature: + * + * function ($value) { + * // return true or false + * } + * + * The closure receives the value as argument and should return true to + * accept the value and false to reject the value. + * + * @param string $option The option name + * @param mixed $allowedValues One or more acceptable values/closures + * + * @return $this + * + * @throws UndefinedOptionsException If the option is undefined + * @throws AccessException If called from a lazy option or normalizer + */ + public function addAllowedValues($option, $allowedValues) + { + if ($this->locked) { + throw new AccessException('Allowed values cannot be added from a lazy option or normalizer.'); + } + + if (!isset($this->defined[$option])) { + throw new UndefinedOptionsException(sprintf( + 'The option "%s" does not exist. Defined options are: "%s".', + $option, + implode('", "', array_keys($this->defined)) + )); + } + + if (!is_array($allowedValues)) { + $allowedValues = array($allowedValues); + } + + if (!isset($this->allowedValues[$option])) { + $this->allowedValues[$option] = $allowedValues; + } else { + $this->allowedValues[$option] = array_merge($this->allowedValues[$option], $allowedValues); + } + + // Make sure the option is processed + unset($this->resolved[$option]); + + return $this; + } + + /** + * Sets allowed types for an option. + * + * Any type for which a corresponding is_<type>() function exists is + * acceptable. Additionally, fully-qualified class or interface names may + * be passed. + * + * @param string $option The option name + * @param string|string[] $allowedTypes One or more accepted types + * + * @return $this + * + * @throws UndefinedOptionsException If the option is undefined + * @throws AccessException If called from a lazy option or normalizer + */ + public function setAllowedTypes($option, $allowedTypes) + { + if ($this->locked) { + throw new AccessException('Allowed types cannot be set from a lazy option or normalizer.'); + } + + if (!isset($this->defined[$option])) { + throw new UndefinedOptionsException(sprintf( + 'The option "%s" does not exist. Defined options are: "%s".', + $option, + implode('", "', array_keys($this->defined)) + )); + } + + $this->allowedTypes[$option] = (array) $allowedTypes; + + // Make sure the option is processed + unset($this->resolved[$option]); + + return $this; + } + + /** + * Adds allowed types for an option. + * + * The types are merged with the allowed types defined previously. + * + * Any type for which a corresponding is_<type>() function exists is + * acceptable. Additionally, fully-qualified class or interface names may + * be passed. + * + * @param string $option The option name + * @param string|string[] $allowedTypes One or more accepted types + * + * @return $this + * + * @throws UndefinedOptionsException If the option is undefined + * @throws AccessException If called from a lazy option or normalizer + */ + public function addAllowedTypes($option, $allowedTypes) + { + if ($this->locked) { + throw new AccessException('Allowed types cannot be added from a lazy option or normalizer.'); + } + + if (!isset($this->defined[$option])) { + throw new UndefinedOptionsException(sprintf( + 'The option "%s" does not exist. Defined options are: "%s".', + $option, + implode('", "', array_keys($this->defined)) + )); + } + + if (!isset($this->allowedTypes[$option])) { + $this->allowedTypes[$option] = (array) $allowedTypes; + } else { + $this->allowedTypes[$option] = array_merge($this->allowedTypes[$option], (array) $allowedTypes); + } + + // Make sure the option is processed + unset($this->resolved[$option]); + + return $this; + } + + /** + * Removes the option with the given name. + * + * Undefined options are ignored. + * + * @param string|string[] $optionNames One or more option names + * + * @return $this + * + * @throws AccessException If called from a lazy option or normalizer + */ + public function remove($optionNames) + { + if ($this->locked) { + throw new AccessException('Options cannot be removed from a lazy option or normalizer.'); + } + + foreach ((array) $optionNames as $option) { + unset($this->defined[$option], $this->defaults[$option], $this->required[$option], $this->resolved[$option]); + unset($this->lazy[$option], $this->normalizers[$option], $this->allowedTypes[$option], $this->allowedValues[$option]); + } + + return $this; + } + + /** + * Removes all options. + * + * @return $this + * + * @throws AccessException If called from a lazy option or normalizer + */ + public function clear() + { + if ($this->locked) { + throw new AccessException('Options cannot be cleared from a lazy option or normalizer.'); + } + + $this->defined = array(); + $this->defaults = array(); + $this->required = array(); + $this->resolved = array(); + $this->lazy = array(); + $this->normalizers = array(); + $this->allowedTypes = array(); + $this->allowedValues = array(); + + return $this; + } + + /** + * Merges options with the default values stored in the container and + * validates them. + * + * Exceptions are thrown if: + * + * - Undefined options are passed; + * - Required options are missing; + * - Options have invalid types; + * - Options have invalid values. + * + * @param array $options A map of option names to values + * + * @return array The merged and validated options + * + * @throws UndefinedOptionsException If an option name is undefined + * @throws InvalidOptionsException If an option doesn't fulfill the + * specified validation rules + * @throws MissingOptionsException If a required option is missing + * @throws OptionDefinitionException If there is a cyclic dependency between + * lazy options and/or normalizers + * @throws NoSuchOptionException If a lazy option reads an unavailable option + * @throws AccessException If called from a lazy option or normalizer + */ + public function resolve(array $options = array()) + { + if ($this->locked) { + throw new AccessException('Options cannot be resolved from a lazy option or normalizer.'); + } + + // Allow this method to be called multiple times + $clone = clone $this; + + // Make sure that no unknown options are passed + $diff = array_diff_key($options, $clone->defined); + + if (count($diff) > 0) { + ksort($clone->defined); + ksort($diff); + + throw new UndefinedOptionsException(sprintf( + (count($diff) > 1 ? 'The options "%s" do not exist.' : 'The option "%s" does not exist.').' Defined options are: "%s".', + implode('", "', array_keys($diff)), + implode('", "', array_keys($clone->defined)) + )); + } + + // Override options set by the user + foreach ($options as $option => $value) { + $clone->defaults[$option] = $value; + unset($clone->resolved[$option], $clone->lazy[$option]); + } + + // Check whether any required option is missing + $diff = array_diff_key($clone->required, $clone->defaults); + + if (count($diff) > 0) { + ksort($diff); + + throw new MissingOptionsException(sprintf( + count($diff) > 1 ? 'The required options "%s" are missing.' : 'The required option "%s" is missing.', + implode('", "', array_keys($diff)) + )); + } + + // Lock the container + $clone->locked = true; + + // Now process the individual options. Use offsetGet(), which resolves + // the option itself and any options that the option depends on + foreach ($clone->defaults as $option => $_) { + $clone->offsetGet($option); + } + + return $clone->resolved; + } + + /** + * Returns the resolved value of an option. + * + * @param string $option The option name + * + * @return mixed The option value + * + * @throws AccessException If accessing this method outside of + * {@link resolve()} + * @throws NoSuchOptionException If the option is not set + * @throws InvalidOptionsException If the option doesn't fulfill the + * specified validation rules + * @throws OptionDefinitionException If there is a cyclic dependency between + * lazy options and/or normalizers + */ + public function offsetGet($option) + { + if (!$this->locked) { + throw new AccessException('Array access is only supported within closures of lazy options and normalizers.'); + } + + // Shortcut for resolved options + if (array_key_exists($option, $this->resolved)) { + return $this->resolved[$option]; + } + + // Check whether the option is set at all + if (!array_key_exists($option, $this->defaults)) { + if (!isset($this->defined[$option])) { + throw new NoSuchOptionException(sprintf( + 'The option "%s" does not exist. Defined options are: "%s".', + $option, + implode('", "', array_keys($this->defined)) + )); + } + + throw new NoSuchOptionException(sprintf( + 'The optional option "%s" has no value set. You should make sure it is set with "isset" before reading it.', + $option + )); + } + + $value = $this->defaults[$option]; + + // Resolve the option if the default value is lazily evaluated + if (isset($this->lazy[$option])) { + // If the closure is already being called, we have a cyclic + // dependency + if (isset($this->calling[$option])) { + throw new OptionDefinitionException(sprintf( + 'The options "%s" have a cyclic dependency.', + implode('", "', array_keys($this->calling)) + )); + } + + // The following section must be protected from cyclic + // calls. Set $calling for the current $option to detect a cyclic + // dependency + // BEGIN + $this->calling[$option] = true; + try { + foreach ($this->lazy[$option] as $closure) { + $value = $closure($this, $value); + } + } finally { + unset($this->calling[$option]); + } + // END + } + + // Validate the type of the resolved option + if (isset($this->allowedTypes[$option])) { + $valid = false; + $invalidTypes = array(); + + foreach ($this->allowedTypes[$option] as $type) { + $type = isset(self::$typeAliases[$type]) ? self::$typeAliases[$type] : $type; + + if ($valid = $this->verifyTypes($type, $value, $invalidTypes)) { + break; + } + } + + if (!$valid) { + throw new InvalidOptionsException(sprintf( + 'The option "%s" with value %s is expected to be of type '. + '"%s", but is of type "%s".', + $option, + $this->formatValue($value), + implode('" or "', $this->allowedTypes[$option]), + implode('|', array_keys($invalidTypes)) + )); + } + } + + // Validate the value of the resolved option + if (isset($this->allowedValues[$option])) { + $success = false; + $printableAllowedValues = array(); + + foreach ($this->allowedValues[$option] as $allowedValue) { + if ($allowedValue instanceof \Closure) { + if ($allowedValue($value)) { + $success = true; + break; + } + + // Don't include closures in the exception message + continue; + } elseif ($value === $allowedValue) { + $success = true; + break; + } + + $printableAllowedValues[] = $allowedValue; + } + + if (!$success) { + $message = sprintf( + 'The option "%s" with value %s is invalid.', + $option, + $this->formatValue($value) + ); + + if (count($printableAllowedValues) > 0) { + $message .= sprintf( + ' Accepted values are: %s.', + $this->formatValues($printableAllowedValues) + ); + } + + throw new InvalidOptionsException($message); + } + } + + // Normalize the validated option + if (isset($this->normalizers[$option])) { + // If the closure is already being called, we have a cyclic + // dependency + if (isset($this->calling[$option])) { + throw new OptionDefinitionException(sprintf( + 'The options "%s" have a cyclic dependency.', + implode('", "', array_keys($this->calling)) + )); + } + + $normalizer = $this->normalizers[$option]; + + // The following section must be protected from cyclic + // calls. Set $calling for the current $option to detect a cyclic + // dependency + // BEGIN + $this->calling[$option] = true; + try { + $value = $normalizer($this, $value); + } finally { + unset($this->calling[$option]); + } + // END + } + + // Mark as resolved + $this->resolved[$option] = $value; + + return $value; + } + + /** + * @param string $type + * @param mixed $value + * @param array &$invalidTypes + * + * @return bool + */ + private function verifyTypes($type, $value, array &$invalidTypes) + { + if ('[]' === substr($type, -2) && is_array($value)) { + $originalType = $type; + $type = substr($type, 0, -2); + $invalidValues = array_filter( // Filter out valid values, keeping invalid values in the resulting array + $value, + function ($value) use ($type) { + return (function_exists($isFunction = 'is_'.$type) && !$isFunction($value)) || !$value instanceof $type; + } + ); + + if (!$invalidValues) { + return true; + } + + $invalidTypes[$this->formatTypeOf($value, $originalType)] = true; + + return false; + } + + if ((function_exists($isFunction = 'is_'.$type) && $isFunction($value)) || $value instanceof $type) { + return true; + } + + if (!$invalidTypes) { + $invalidTypes[$this->formatTypeOf($value, null)] = true; + } + + return false; + } + + /** + * Returns whether a resolved option with the given name exists. + * + * @param string $option The option name + * + * @return bool Whether the option is set + * + * @throws AccessException If accessing this method outside of {@link resolve()} + * + * @see \ArrayAccess::offsetExists() + */ + public function offsetExists($option) + { + if (!$this->locked) { + throw new AccessException('Array access is only supported within closures of lazy options and normalizers.'); + } + + return array_key_exists($option, $this->defaults); + } + + /** + * Not supported. + * + * @throws AccessException + */ + public function offsetSet($option, $value) + { + throw new AccessException('Setting options via array access is not supported. Use setDefault() instead.'); + } + + /** + * Not supported. + * + * @throws AccessException + */ + public function offsetUnset($option) + { + throw new AccessException('Removing options via array access is not supported. Use remove() instead.'); + } + + /** + * Returns the number of set options. + * + * This may be only a subset of the defined options. + * + * @return int Number of options + * + * @throws AccessException If accessing this method outside of {@link resolve()} + * + * @see \Countable::count() + */ + public function count() + { + if (!$this->locked) { + throw new AccessException('Counting is only supported within closures of lazy options and normalizers.'); + } + + return count($this->defaults); + } + + /** + * Returns a string representation of the type of the value. + * + * This method should be used if you pass the type of a value as + * message parameter to a constraint violation. Note that such + * parameters should usually not be included in messages aimed at + * non-technical people. + * + * @param mixed $value The value to return the type of + * @param string $type + * + * @return string The type of the value + */ + private function formatTypeOf($value, $type) + { + $suffix = ''; + + if ('[]' === substr($type, -2)) { + $suffix = '[]'; + $type = substr($type, 0, -2); + while ('[]' === substr($type, -2)) { + $type = substr($type, 0, -2); + $value = array_shift($value); + if (!is_array($value)) { + break; + } + $suffix .= '[]'; + } + + if (is_array($value)) { + $subTypes = array(); + foreach ($value as $val) { + $subTypes[$this->formatTypeOf($val, null)] = true; + } + + return implode('|', array_keys($subTypes)).$suffix; + } + } + + return (is_object($value) ? get_class($value) : gettype($value)).$suffix; + } + + /** + * Returns a string representation of the value. + * + * This method returns the equivalent PHP tokens for most scalar types + * (i.e. "false" for false, "1" for 1 etc.). Strings are always wrapped + * in double quotes ("). + * + * @param mixed $value The value to format as string + * + * @return string The string representation of the passed value + */ + private function formatValue($value) + { + if (is_object($value)) { + return get_class($value); + } + + if (is_array($value)) { + return 'array'; + } + + if (is_string($value)) { + return '"'.$value.'"'; + } + + if (is_resource($value)) { + return 'resource'; + } + + if (null === $value) { + return 'null'; + } + + if (false === $value) { + return 'false'; + } + + if (true === $value) { + return 'true'; + } + + return (string) $value; + } + + /** + * Returns a string representation of a list of values. + * + * Each of the values is converted to a string using + * {@link formatValue()}. The values are then concatenated with commas. + * + * @param array $values A list of values + * + * @return string The string representation of the value list + * + * @see formatValue() + */ + private function formatValues(array $values) + { + foreach ($values as $key => $value) { + $values[$key] = $this->formatValue($value); + } + + return implode(', ', $values); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/README.md b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/README.md new file mode 100644 index 0000000..245e69b --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/README.md @@ -0,0 +1,15 @@ +OptionsResolver Component +========================= + +The OptionsResolver component is `array_replace` on steroids. It allows you to +create an options system with required options, defaults, validation (type, +value), normalization and more. + +Resources +--------- + + * [Documentation](https://symfony.com/doc/current/components/options_resolver.html) + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Tests/Debug/OptionsResolverIntrospectorTest.php b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Tests/Debug/OptionsResolverIntrospectorTest.php new file mode 100644 index 0000000..7c4753a --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Tests/Debug/OptionsResolverIntrospectorTest.php @@ -0,0 +1,203 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\OptionsResolver\Tests\Debug; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\OptionsResolver\Debug\OptionsResolverIntrospector; +use Symfony\Component\OptionsResolver\Options; +use Symfony\Component\OptionsResolver\OptionsResolver; + +class OptionsResolverIntrospectorTest extends TestCase +{ + public function testGetDefault() + { + $resolver = new OptionsResolver(); + $resolver->setDefault($option = 'foo', 'bar'); + + $debug = new OptionsResolverIntrospector($resolver); + $this->assertSame('bar', $debug->getDefault($option)); + } + + public function testGetDefaultNull() + { + $resolver = new OptionsResolver(); + $resolver->setDefault($option = 'foo', null); + + $debug = new OptionsResolverIntrospector($resolver); + $this->assertNull($debug->getDefault($option)); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\NoConfigurationException + * @expectedExceptionMessage No default value was set for the "foo" option. + */ + public function testGetDefaultThrowsOnNoConfiguredValue() + { + $resolver = new OptionsResolver(); + $resolver->setDefined($option = 'foo'); + + $debug = new OptionsResolverIntrospector($resolver); + $this->assertSame('bar', $debug->getDefault($option)); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException + * @expectedExceptionMessage The option "foo" does not exist. + */ + public function testGetDefaultThrowsOnNotDefinedOption() + { + $resolver = new OptionsResolver(); + + $debug = new OptionsResolverIntrospector($resolver); + $this->assertSame('bar', $debug->getDefault('foo')); + } + + public function testGetLazyClosures() + { + $resolver = new OptionsResolver(); + $closures = array(); + $resolver->setDefault($option = 'foo', $closures[] = function (Options $options) {}); + + $debug = new OptionsResolverIntrospector($resolver); + $this->assertSame($closures, $debug->getLazyClosures($option)); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\NoConfigurationException + * @expectedExceptionMessage No lazy closures were set for the "foo" option. + */ + public function testGetLazyClosuresThrowsOnNoConfiguredValue() + { + $resolver = new OptionsResolver(); + $resolver->setDefined($option = 'foo'); + + $debug = new OptionsResolverIntrospector($resolver); + $this->assertSame('bar', $debug->getLazyClosures($option)); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException + * @expectedExceptionMessage The option "foo" does not exist. + */ + public function testGetLazyClosuresThrowsOnNotDefinedOption() + { + $resolver = new OptionsResolver(); + + $debug = new OptionsResolverIntrospector($resolver); + $this->assertSame('bar', $debug->getLazyClosures('foo')); + } + + public function testGetAllowedTypes() + { + $resolver = new OptionsResolver(); + $resolver->setDefined($option = 'foo'); + $resolver->setAllowedTypes($option = 'foo', $allowedTypes = array('string', 'bool')); + + $debug = new OptionsResolverIntrospector($resolver); + $this->assertSame($allowedTypes, $debug->getAllowedTypes($option)); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\NoConfigurationException + * @expectedExceptionMessage No allowed types were set for the "foo" option. + */ + public function testGetAllowedTypesThrowsOnNoConfiguredValue() + { + $resolver = new OptionsResolver(); + $resolver->setDefined($option = 'foo'); + + $debug = new OptionsResolverIntrospector($resolver); + $this->assertSame('bar', $debug->getAllowedTypes($option)); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException + * @expectedExceptionMessage The option "foo" does not exist. + */ + public function testGetAllowedTypesThrowsOnNotDefinedOption() + { + $resolver = new OptionsResolver(); + + $debug = new OptionsResolverIntrospector($resolver); + $this->assertSame('bar', $debug->getAllowedTypes('foo')); + } + + public function testGetAllowedValues() + { + $resolver = new OptionsResolver(); + $resolver->setDefined($option = 'foo'); + $resolver->setAllowedValues($option = 'foo', $allowedValues = array('bar', 'baz')); + + $debug = new OptionsResolverIntrospector($resolver); + $this->assertSame($allowedValues, $debug->getAllowedValues($option)); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\NoConfigurationException + * @expectedExceptionMessage No allowed values were set for the "foo" option. + */ + public function testGetAllowedValuesThrowsOnNoConfiguredValue() + { + $resolver = new OptionsResolver(); + $resolver->setDefined($option = 'foo'); + + $debug = new OptionsResolverIntrospector($resolver); + $this->assertSame('bar', $debug->getAllowedValues($option)); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException + * @expectedExceptionMessage The option "foo" does not exist. + */ + public function testGetAllowedValuesThrowsOnNotDefinedOption() + { + $resolver = new OptionsResolver(); + + $debug = new OptionsResolverIntrospector($resolver); + $this->assertSame('bar', $debug->getAllowedValues('foo')); + } + + public function testGetNormalizer() + { + $resolver = new OptionsResolver(); + $resolver->setDefined($option = 'foo'); + $resolver->setNormalizer($option = 'foo', $normalizer = function () {}); + + $debug = new OptionsResolverIntrospector($resolver); + $this->assertSame($normalizer, $debug->getNormalizer($option)); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\NoConfigurationException + * @expectedExceptionMessage No normalizer was set for the "foo" option. + */ + public function testGetNormalizerThrowsOnNoConfiguredValue() + { + $resolver = new OptionsResolver(); + $resolver->setDefined($option = 'foo'); + + $debug = new OptionsResolverIntrospector($resolver); + $this->assertSame('bar', $debug->getNormalizer($option)); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException + * @expectedExceptionMessage The option "foo" does not exist. + */ + public function testGetNormalizerThrowsOnNotDefinedOption() + { + $resolver = new OptionsResolver(); + + $debug = new OptionsResolverIntrospector($resolver); + $this->assertSame('bar', $debug->getNormalizer('foo')); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Tests/OptionsResolverTest.php b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Tests/OptionsResolverTest.php new file mode 100644 index 0000000..b95e039 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/Tests/OptionsResolverTest.php @@ -0,0 +1,1644 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\OptionsResolver\Tests; + +use PHPUnit\Framework\Assert; +use PHPUnit\Framework\TestCase; +use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; +use Symfony\Component\OptionsResolver\Options; +use Symfony\Component\OptionsResolver\OptionsResolver; + +class OptionsResolverTest extends TestCase +{ + /** + * @var OptionsResolver + */ + private $resolver; + + protected function setUp() + { + $this->resolver = new OptionsResolver(); + } + + //////////////////////////////////////////////////////////////////////////// + // resolve() + //////////////////////////////////////////////////////////////////////////// + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException + * @expectedExceptionMessage The option "foo" does not exist. Defined options are: "a", "z". + */ + public function testResolveFailsIfNonExistingOption() + { + $this->resolver->setDefault('z', '1'); + $this->resolver->setDefault('a', '2'); + + $this->resolver->resolve(array('foo' => 'bar')); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException + * @expectedExceptionMessage The options "baz", "foo", "ping" do not exist. Defined options are: "a", "z". + */ + public function testResolveFailsIfMultipleNonExistingOptions() + { + $this->resolver->setDefault('z', '1'); + $this->resolver->setDefault('a', '2'); + + $this->resolver->resolve(array('ping' => 'pong', 'foo' => 'bar', 'baz' => 'bam')); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException + */ + public function testResolveFailsFromLazyOption() + { + $this->resolver->setDefault('foo', function (Options $options) { + $options->resolve(array()); + }); + + $this->resolver->resolve(); + } + + //////////////////////////////////////////////////////////////////////////// + // setDefault()/hasDefault() + //////////////////////////////////////////////////////////////////////////// + + public function testSetDefaultReturnsThis() + { + $this->assertSame($this->resolver, $this->resolver->setDefault('foo', 'bar')); + } + + public function testSetDefault() + { + $this->resolver->setDefault('one', '1'); + $this->resolver->setDefault('two', '20'); + + $this->assertEquals(array( + 'one' => '1', + 'two' => '20', + ), $this->resolver->resolve()); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException + */ + public function testFailIfSetDefaultFromLazyOption() + { + $this->resolver->setDefault('lazy', function (Options $options) { + $options->setDefault('default', 42); + }); + + $this->resolver->resolve(); + } + + public function testHasDefault() + { + $this->assertFalse($this->resolver->hasDefault('foo')); + $this->resolver->setDefault('foo', 42); + $this->assertTrue($this->resolver->hasDefault('foo')); + } + + public function testHasDefaultWithNullValue() + { + $this->assertFalse($this->resolver->hasDefault('foo')); + $this->resolver->setDefault('foo', null); + $this->assertTrue($this->resolver->hasDefault('foo')); + } + + //////////////////////////////////////////////////////////////////////////// + // lazy setDefault() + //////////////////////////////////////////////////////////////////////////// + + public function testSetLazyReturnsThis() + { + $this->assertSame($this->resolver, $this->resolver->setDefault('foo', function (Options $options) {})); + } + + public function testSetLazyClosure() + { + $this->resolver->setDefault('foo', function (Options $options) { + return 'lazy'; + }); + + $this->assertEquals(array('foo' => 'lazy'), $this->resolver->resolve()); + } + + public function testClosureWithoutTypeHintNotInvoked() + { + $closure = function ($options) { + Assert::fail('Should not be called'); + }; + + $this->resolver->setDefault('foo', $closure); + + $this->assertSame(array('foo' => $closure), $this->resolver->resolve()); + } + + public function testClosureWithoutParametersNotInvoked() + { + $closure = function () { + Assert::fail('Should not be called'); + }; + + $this->resolver->setDefault('foo', $closure); + + $this->assertSame(array('foo' => $closure), $this->resolver->resolve()); + } + + public function testAccessPreviousDefaultValue() + { + // defined by superclass + $this->resolver->setDefault('foo', 'bar'); + + // defined by subclass + $this->resolver->setDefault('foo', function (Options $options, $previousValue) { + Assert::assertEquals('bar', $previousValue); + + return 'lazy'; + }); + + $this->assertEquals(array('foo' => 'lazy'), $this->resolver->resolve()); + } + + public function testAccessPreviousLazyDefaultValue() + { + // defined by superclass + $this->resolver->setDefault('foo', function (Options $options) { + return 'bar'; + }); + + // defined by subclass + $this->resolver->setDefault('foo', function (Options $options, $previousValue) { + Assert::assertEquals('bar', $previousValue); + + return 'lazy'; + }); + + $this->assertEquals(array('foo' => 'lazy'), $this->resolver->resolve()); + } + + public function testPreviousValueIsNotEvaluatedIfNoSecondArgument() + { + // defined by superclass + $this->resolver->setDefault('foo', function () { + Assert::fail('Should not be called'); + }); + + // defined by subclass, no $previousValue argument defined! + $this->resolver->setDefault('foo', function (Options $options) { + return 'lazy'; + }); + + $this->assertEquals(array('foo' => 'lazy'), $this->resolver->resolve()); + } + + public function testOverwrittenLazyOptionNotEvaluated() + { + $this->resolver->setDefault('foo', function (Options $options) { + Assert::fail('Should not be called'); + }); + + $this->resolver->setDefault('foo', 'bar'); + + $this->assertSame(array('foo' => 'bar'), $this->resolver->resolve()); + } + + public function testInvokeEachLazyOptionOnlyOnce() + { + $calls = 0; + + $this->resolver->setDefault('lazy1', function (Options $options) use (&$calls) { + Assert::assertSame(1, ++$calls); + + $options['lazy2']; + }); + + $this->resolver->setDefault('lazy2', function (Options $options) use (&$calls) { + Assert::assertSame(2, ++$calls); + }); + + $this->resolver->resolve(); + + $this->assertSame(2, $calls); + } + + //////////////////////////////////////////////////////////////////////////// + // setRequired()/isRequired()/getRequiredOptions() + //////////////////////////////////////////////////////////////////////////// + + public function testSetRequiredReturnsThis() + { + $this->assertSame($this->resolver, $this->resolver->setRequired('foo')); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException + */ + public function testFailIfSetRequiredFromLazyOption() + { + $this->resolver->setDefault('foo', function (Options $options) { + $options->setRequired('bar'); + }); + + $this->resolver->resolve(); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\MissingOptionsException + */ + public function testResolveFailsIfRequiredOptionMissing() + { + $this->resolver->setRequired('foo'); + + $this->resolver->resolve(); + } + + public function testResolveSucceedsIfRequiredOptionSet() + { + $this->resolver->setRequired('foo'); + $this->resolver->setDefault('foo', 'bar'); + + $this->assertNotEmpty($this->resolver->resolve()); + } + + public function testResolveSucceedsIfRequiredOptionPassed() + { + $this->resolver->setRequired('foo'); + + $this->assertNotEmpty($this->resolver->resolve(array('foo' => 'bar'))); + } + + public function testIsRequired() + { + $this->assertFalse($this->resolver->isRequired('foo')); + $this->resolver->setRequired('foo'); + $this->assertTrue($this->resolver->isRequired('foo')); + } + + public function testRequiredIfSetBefore() + { + $this->assertFalse($this->resolver->isRequired('foo')); + + $this->resolver->setDefault('foo', 'bar'); + $this->resolver->setRequired('foo'); + + $this->assertTrue($this->resolver->isRequired('foo')); + } + + public function testStillRequiredAfterSet() + { + $this->assertFalse($this->resolver->isRequired('foo')); + + $this->resolver->setRequired('foo'); + $this->resolver->setDefault('foo', 'bar'); + + $this->assertTrue($this->resolver->isRequired('foo')); + } + + public function testIsNotRequiredAfterRemove() + { + $this->assertFalse($this->resolver->isRequired('foo')); + $this->resolver->setRequired('foo'); + $this->resolver->remove('foo'); + $this->assertFalse($this->resolver->isRequired('foo')); + } + + public function testIsNotRequiredAfterClear() + { + $this->assertFalse($this->resolver->isRequired('foo')); + $this->resolver->setRequired('foo'); + $this->resolver->clear(); + $this->assertFalse($this->resolver->isRequired('foo')); + } + + public function testGetRequiredOptions() + { + $this->resolver->setRequired(array('foo', 'bar')); + $this->resolver->setDefault('bam', 'baz'); + $this->resolver->setDefault('foo', 'boo'); + + $this->assertSame(array('foo', 'bar'), $this->resolver->getRequiredOptions()); + } + + //////////////////////////////////////////////////////////////////////////// + // isMissing()/getMissingOptions() + //////////////////////////////////////////////////////////////////////////// + + public function testIsMissingIfNotSet() + { + $this->assertFalse($this->resolver->isMissing('foo')); + $this->resolver->setRequired('foo'); + $this->assertTrue($this->resolver->isMissing('foo')); + } + + public function testIsNotMissingIfSet() + { + $this->resolver->setDefault('foo', 'bar'); + + $this->assertFalse($this->resolver->isMissing('foo')); + $this->resolver->setRequired('foo'); + $this->assertFalse($this->resolver->isMissing('foo')); + } + + public function testIsNotMissingAfterRemove() + { + $this->resolver->setRequired('foo'); + $this->resolver->remove('foo'); + $this->assertFalse($this->resolver->isMissing('foo')); + } + + public function testIsNotMissingAfterClear() + { + $this->resolver->setRequired('foo'); + $this->resolver->clear(); + $this->assertFalse($this->resolver->isRequired('foo')); + } + + public function testGetMissingOptions() + { + $this->resolver->setRequired(array('foo', 'bar')); + $this->resolver->setDefault('bam', 'baz'); + $this->resolver->setDefault('foo', 'boo'); + + $this->assertSame(array('bar'), $this->resolver->getMissingOptions()); + } + + //////////////////////////////////////////////////////////////////////////// + // setDefined()/isDefined()/getDefinedOptions() + //////////////////////////////////////////////////////////////////////////// + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException + */ + public function testFailIfSetDefinedFromLazyOption() + { + $this->resolver->setDefault('foo', function (Options $options) { + $options->setDefined('bar'); + }); + + $this->resolver->resolve(); + } + + public function testDefinedOptionsNotIncludedInResolvedOptions() + { + $this->resolver->setDefined('foo'); + + $this->assertSame(array(), $this->resolver->resolve()); + } + + public function testDefinedOptionsIncludedIfDefaultSetBefore() + { + $this->resolver->setDefault('foo', 'bar'); + $this->resolver->setDefined('foo'); + + $this->assertSame(array('foo' => 'bar'), $this->resolver->resolve()); + } + + public function testDefinedOptionsIncludedIfDefaultSetAfter() + { + $this->resolver->setDefined('foo'); + $this->resolver->setDefault('foo', 'bar'); + + $this->assertSame(array('foo' => 'bar'), $this->resolver->resolve()); + } + + public function testDefinedOptionsIncludedIfPassedToResolve() + { + $this->resolver->setDefined('foo'); + + $this->assertSame(array('foo' => 'bar'), $this->resolver->resolve(array('foo' => 'bar'))); + } + + public function testIsDefined() + { + $this->assertFalse($this->resolver->isDefined('foo')); + $this->resolver->setDefined('foo'); + $this->assertTrue($this->resolver->isDefined('foo')); + } + + public function testLazyOptionsAreDefined() + { + $this->assertFalse($this->resolver->isDefined('foo')); + $this->resolver->setDefault('foo', function (Options $options) {}); + $this->assertTrue($this->resolver->isDefined('foo')); + } + + public function testRequiredOptionsAreDefined() + { + $this->assertFalse($this->resolver->isDefined('foo')); + $this->resolver->setRequired('foo'); + $this->assertTrue($this->resolver->isDefined('foo')); + } + + public function testSetOptionsAreDefined() + { + $this->assertFalse($this->resolver->isDefined('foo')); + $this->resolver->setDefault('foo', 'bar'); + $this->assertTrue($this->resolver->isDefined('foo')); + } + + public function testGetDefinedOptions() + { + $this->resolver->setDefined(array('foo', 'bar')); + $this->resolver->setDefault('baz', 'bam'); + $this->resolver->setRequired('boo'); + + $this->assertSame(array('foo', 'bar', 'baz', 'boo'), $this->resolver->getDefinedOptions()); + } + + public function testRemovedOptionsAreNotDefined() + { + $this->assertFalse($this->resolver->isDefined('foo')); + $this->resolver->setDefined('foo'); + $this->assertTrue($this->resolver->isDefined('foo')); + $this->resolver->remove('foo'); + $this->assertFalse($this->resolver->isDefined('foo')); + } + + public function testClearedOptionsAreNotDefined() + { + $this->assertFalse($this->resolver->isDefined('foo')); + $this->resolver->setDefined('foo'); + $this->assertTrue($this->resolver->isDefined('foo')); + $this->resolver->clear(); + $this->assertFalse($this->resolver->isDefined('foo')); + } + + //////////////////////////////////////////////////////////////////////////// + // setAllowedTypes() + //////////////////////////////////////////////////////////////////////////// + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException + */ + public function testSetAllowedTypesFailsIfUnknownOption() + { + $this->resolver->setAllowedTypes('foo', 'string'); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException + */ + public function testFailIfSetAllowedTypesFromLazyOption() + { + $this->resolver->setDefault('foo', function (Options $options) { + $options->setAllowedTypes('bar', 'string'); + }); + + $this->resolver->setDefault('bar', 'baz'); + + $this->resolver->resolve(); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException + * @expectedExceptionMessage The option "foo" with value array is expected to be of type "int[]", but is of type "DateTime[]". + */ + public function testResolveFailsIfInvalidTypedArray() + { + $this->resolver->setDefined('foo'); + $this->resolver->setAllowedTypes('foo', 'int[]'); + + $this->resolver->resolve(array('foo' => array(new \DateTime()))); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException + * @expectedExceptionMessage The option "foo" with value "bar" is expected to be of type "int[]", but is of type "string". + */ + public function testResolveFailsWithNonArray() + { + $this->resolver->setDefined('foo'); + $this->resolver->setAllowedTypes('foo', 'int[]'); + + $this->resolver->resolve(array('foo' => 'bar')); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException + * @expectedExceptionMessage The option "foo" with value array is expected to be of type "int[]", but is of type "integer|stdClass|array|DateTime[]". + */ + public function testResolveFailsIfTypedArrayContainsInvalidTypes() + { + $this->resolver->setDefined('foo'); + $this->resolver->setAllowedTypes('foo', 'int[]'); + $values = range(1, 5); + $values[] = new \stdClass(); + $values[] = array(); + $values[] = new \DateTime(); + $values[] = 123; + + $this->resolver->resolve(array('foo' => $values)); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException + * @expectedExceptionMessage The option "foo" with value array is expected to be of type "int[][]", but is of type "double[][]". + */ + public function testResolveFailsWithCorrectLevelsButWrongScalar() + { + $this->resolver->setDefined('foo'); + $this->resolver->setAllowedTypes('foo', 'int[][]'); + + $this->resolver->resolve( + array( + 'foo' => array( + array(1.2), + ), + ) + ); + } + + /** + * @dataProvider provideInvalidTypes + */ + public function testResolveFailsIfInvalidType($actualType, $allowedType, $exceptionMessage) + { + $this->resolver->setDefined('option'); + $this->resolver->setAllowedTypes('option', $allowedType); + + if (method_exists($this, 'expectException')) { + $this->expectException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException'); + $this->expectExceptionMessage($exceptionMessage); + } else { + $this->setExpectedException('Symfony\Component\OptionsResolver\Exception\InvalidOptionsException', $exceptionMessage); + } + + $this->resolver->resolve(array('option' => $actualType)); + } + + public function provideInvalidTypes() + { + return array( + array(true, 'string', 'The option "option" with value true is expected to be of type "string", but is of type "boolean".'), + array(false, 'string', 'The option "option" with value false is expected to be of type "string", but is of type "boolean".'), + array(fopen(__FILE__, 'r'), 'string', 'The option "option" with value resource is expected to be of type "string", but is of type "resource".'), + array(array(), 'string', 'The option "option" with value array is expected to be of type "string", but is of type "array".'), + array(new OptionsResolver(), 'string', 'The option "option" with value Symfony\Component\OptionsResolver\OptionsResolver is expected to be of type "string", but is of type "Symfony\Component\OptionsResolver\OptionsResolver".'), + array(42, 'string', 'The option "option" with value 42 is expected to be of type "string", but is of type "integer".'), + array(null, 'string', 'The option "option" with value null is expected to be of type "string", but is of type "NULL".'), + array('bar', '\stdClass', 'The option "option" with value "bar" is expected to be of type "\stdClass", but is of type "string".'), + ); + } + + public function testResolveSucceedsIfValidType() + { + $this->resolver->setDefault('foo', 'bar'); + $this->resolver->setAllowedTypes('foo', 'string'); + + $this->assertNotEmpty($this->resolver->resolve()); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException + * @expectedExceptionMessage The option "foo" with value 42 is expected to be of type "string" or "bool", but is of type "integer". + */ + public function testResolveFailsIfInvalidTypeMultiple() + { + $this->resolver->setDefault('foo', 42); + $this->resolver->setAllowedTypes('foo', array('string', 'bool')); + + $this->resolver->resolve(); + } + + public function testResolveSucceedsIfValidTypeMultiple() + { + $this->resolver->setDefault('foo', true); + $this->resolver->setAllowedTypes('foo', array('string', 'bool')); + + $this->assertNotEmpty($this->resolver->resolve()); + } + + public function testResolveSucceedsIfInstanceOfClass() + { + $this->resolver->setDefault('foo', new \stdClass()); + $this->resolver->setAllowedTypes('foo', '\stdClass'); + + $this->assertNotEmpty($this->resolver->resolve()); + } + + public function testResolveSucceedsIfTypedArray() + { + $this->resolver->setDefault('foo', null); + $this->resolver->setAllowedTypes('foo', array('null', 'DateTime[]')); + + $data = array( + 'foo' => array( + new \DateTime(), + new \DateTime(), + ), + ); + $result = $this->resolver->resolve($data); + $this->assertEquals($data, $result); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException + */ + public function testResolveFailsIfNotInstanceOfClass() + { + $this->resolver->setDefault('foo', 'bar'); + $this->resolver->setAllowedTypes('foo', '\stdClass'); + + $this->resolver->resolve(); + } + + //////////////////////////////////////////////////////////////////////////// + // addAllowedTypes() + //////////////////////////////////////////////////////////////////////////// + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException + */ + public function testAddAllowedTypesFailsIfUnknownOption() + { + $this->resolver->addAllowedTypes('foo', 'string'); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException + */ + public function testFailIfAddAllowedTypesFromLazyOption() + { + $this->resolver->setDefault('foo', function (Options $options) { + $options->addAllowedTypes('bar', 'string'); + }); + + $this->resolver->setDefault('bar', 'baz'); + + $this->resolver->resolve(); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException + */ + public function testResolveFailsIfInvalidAddedType() + { + $this->resolver->setDefault('foo', 42); + $this->resolver->addAllowedTypes('foo', 'string'); + + $this->resolver->resolve(); + } + + public function testResolveSucceedsIfValidAddedType() + { + $this->resolver->setDefault('foo', 'bar'); + $this->resolver->addAllowedTypes('foo', 'string'); + + $this->assertNotEmpty($this->resolver->resolve()); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException + */ + public function testResolveFailsIfInvalidAddedTypeMultiple() + { + $this->resolver->setDefault('foo', 42); + $this->resolver->addAllowedTypes('foo', array('string', 'bool')); + + $this->resolver->resolve(); + } + + public function testResolveSucceedsIfValidAddedTypeMultiple() + { + $this->resolver->setDefault('foo', 'bar'); + $this->resolver->addAllowedTypes('foo', array('string', 'bool')); + + $this->assertNotEmpty($this->resolver->resolve()); + } + + public function testAddAllowedTypesDoesNotOverwrite() + { + $this->resolver->setDefault('foo', 'bar'); + $this->resolver->setAllowedTypes('foo', 'string'); + $this->resolver->addAllowedTypes('foo', 'bool'); + + $this->resolver->setDefault('foo', 'bar'); + + $this->assertNotEmpty($this->resolver->resolve()); + } + + public function testAddAllowedTypesDoesNotOverwrite2() + { + $this->resolver->setDefault('foo', 'bar'); + $this->resolver->setAllowedTypes('foo', 'string'); + $this->resolver->addAllowedTypes('foo', 'bool'); + + $this->resolver->setDefault('foo', false); + + $this->assertNotEmpty($this->resolver->resolve()); + } + + //////////////////////////////////////////////////////////////////////////// + // setAllowedValues() + //////////////////////////////////////////////////////////////////////////// + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException + */ + public function testSetAllowedValuesFailsIfUnknownOption() + { + $this->resolver->setAllowedValues('foo', 'bar'); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException + */ + public function testFailIfSetAllowedValuesFromLazyOption() + { + $this->resolver->setDefault('foo', function (Options $options) { + $options->setAllowedValues('bar', 'baz'); + }); + + $this->resolver->setDefault('bar', 'baz'); + + $this->resolver->resolve(); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException + * @expectedExceptionMessage The option "foo" with value 42 is invalid. Accepted values are: "bar". + */ + public function testResolveFailsIfInvalidValue() + { + $this->resolver->setDefined('foo'); + $this->resolver->setAllowedValues('foo', 'bar'); + + $this->resolver->resolve(array('foo' => 42)); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException + * @expectedExceptionMessage The option "foo" with value null is invalid. Accepted values are: "bar". + */ + public function testResolveFailsIfInvalidValueIsNull() + { + $this->resolver->setDefault('foo', null); + $this->resolver->setAllowedValues('foo', 'bar'); + + $this->resolver->resolve(); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException + */ + public function testResolveFailsIfInvalidValueStrict() + { + $this->resolver->setDefault('foo', 42); + $this->resolver->setAllowedValues('foo', '42'); + + $this->resolver->resolve(); + } + + public function testResolveSucceedsIfValidValue() + { + $this->resolver->setDefault('foo', 'bar'); + $this->resolver->setAllowedValues('foo', 'bar'); + + $this->assertEquals(array('foo' => 'bar'), $this->resolver->resolve()); + } + + public function testResolveSucceedsIfValidValueIsNull() + { + $this->resolver->setDefault('foo', null); + $this->resolver->setAllowedValues('foo', null); + + $this->assertEquals(array('foo' => null), $this->resolver->resolve()); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException + * @expectedExceptionMessage The option "foo" with value 42 is invalid. Accepted values are: "bar", false, null. + */ + public function testResolveFailsIfInvalidValueMultiple() + { + $this->resolver->setDefault('foo', 42); + $this->resolver->setAllowedValues('foo', array('bar', false, null)); + + $this->resolver->resolve(); + } + + public function testResolveSucceedsIfValidValueMultiple() + { + $this->resolver->setDefault('foo', 'baz'); + $this->resolver->setAllowedValues('foo', array('bar', 'baz')); + + $this->assertEquals(array('foo' => 'baz'), $this->resolver->resolve()); + } + + public function testResolveFailsIfClosureReturnsFalse() + { + $this->resolver->setDefault('foo', 42); + $this->resolver->setAllowedValues('foo', function ($value) use (&$passedValue) { + $passedValue = $value; + + return false; + }); + + try { + $this->resolver->resolve(); + $this->fail('Should fail'); + } catch (InvalidOptionsException $e) { + } + + $this->assertSame(42, $passedValue); + } + + public function testResolveSucceedsIfClosureReturnsTrue() + { + $this->resolver->setDefault('foo', 'bar'); + $this->resolver->setAllowedValues('foo', function ($value) use (&$passedValue) { + $passedValue = $value; + + return true; + }); + + $this->assertEquals(array('foo' => 'bar'), $this->resolver->resolve()); + $this->assertSame('bar', $passedValue); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException + */ + public function testResolveFailsIfAllClosuresReturnFalse() + { + $this->resolver->setDefault('foo', 42); + $this->resolver->setAllowedValues('foo', array( + function () { return false; }, + function () { return false; }, + function () { return false; }, + )); + + $this->resolver->resolve(); + } + + public function testResolveSucceedsIfAnyClosureReturnsTrue() + { + $this->resolver->setDefault('foo', 'bar'); + $this->resolver->setAllowedValues('foo', array( + function () { return false; }, + function () { return true; }, + function () { return false; }, + )); + + $this->assertEquals(array('foo' => 'bar'), $this->resolver->resolve()); + } + + //////////////////////////////////////////////////////////////////////////// + // addAllowedValues() + //////////////////////////////////////////////////////////////////////////// + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException + */ + public function testAddAllowedValuesFailsIfUnknownOption() + { + $this->resolver->addAllowedValues('foo', 'bar'); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException + */ + public function testFailIfAddAllowedValuesFromLazyOption() + { + $this->resolver->setDefault('foo', function (Options $options) { + $options->addAllowedValues('bar', 'baz'); + }); + + $this->resolver->setDefault('bar', 'baz'); + + $this->resolver->resolve(); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException + */ + public function testResolveFailsIfInvalidAddedValue() + { + $this->resolver->setDefault('foo', 42); + $this->resolver->addAllowedValues('foo', 'bar'); + + $this->resolver->resolve(); + } + + public function testResolveSucceedsIfValidAddedValue() + { + $this->resolver->setDefault('foo', 'bar'); + $this->resolver->addAllowedValues('foo', 'bar'); + + $this->assertEquals(array('foo' => 'bar'), $this->resolver->resolve()); + } + + public function testResolveSucceedsIfValidAddedValueIsNull() + { + $this->resolver->setDefault('foo', null); + $this->resolver->addAllowedValues('foo', null); + + $this->assertEquals(array('foo' => null), $this->resolver->resolve()); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException + */ + public function testResolveFailsIfInvalidAddedValueMultiple() + { + $this->resolver->setDefault('foo', 42); + $this->resolver->addAllowedValues('foo', array('bar', 'baz')); + + $this->resolver->resolve(); + } + + public function testResolveSucceedsIfValidAddedValueMultiple() + { + $this->resolver->setDefault('foo', 'bar'); + $this->resolver->addAllowedValues('foo', array('bar', 'baz')); + + $this->assertEquals(array('foo' => 'bar'), $this->resolver->resolve()); + } + + public function testAddAllowedValuesDoesNotOverwrite() + { + $this->resolver->setDefault('foo', 'bar'); + $this->resolver->setAllowedValues('foo', 'bar'); + $this->resolver->addAllowedValues('foo', 'baz'); + + $this->assertEquals(array('foo' => 'bar'), $this->resolver->resolve()); + } + + public function testAddAllowedValuesDoesNotOverwrite2() + { + $this->resolver->setDefault('foo', 'baz'); + $this->resolver->setAllowedValues('foo', 'bar'); + $this->resolver->addAllowedValues('foo', 'baz'); + + $this->assertEquals(array('foo' => 'baz'), $this->resolver->resolve()); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException + */ + public function testResolveFailsIfAllAddedClosuresReturnFalse() + { + $this->resolver->setDefault('foo', 42); + $this->resolver->setAllowedValues('foo', function () { return false; }); + $this->resolver->addAllowedValues('foo', function () { return false; }); + + $this->resolver->resolve(); + } + + public function testResolveSucceedsIfAnyAddedClosureReturnsTrue() + { + $this->resolver->setDefault('foo', 'bar'); + $this->resolver->setAllowedValues('foo', function () { return false; }); + $this->resolver->addAllowedValues('foo', function () { return true; }); + + $this->assertEquals(array('foo' => 'bar'), $this->resolver->resolve()); + } + + public function testResolveSucceedsIfAnyAddedClosureReturnsTrue2() + { + $this->resolver->setDefault('foo', 'bar'); + $this->resolver->setAllowedValues('foo', function () { return true; }); + $this->resolver->addAllowedValues('foo', function () { return false; }); + + $this->assertEquals(array('foo' => 'bar'), $this->resolver->resolve()); + } + + //////////////////////////////////////////////////////////////////////////// + // setNormalizer() + //////////////////////////////////////////////////////////////////////////// + + public function testSetNormalizerReturnsThis() + { + $this->resolver->setDefault('foo', 'bar'); + $this->assertSame($this->resolver, $this->resolver->setNormalizer('foo', function () {})); + } + + public function testSetNormalizerClosure() + { + $this->resolver->setDefault('foo', 'bar'); + $this->resolver->setNormalizer('foo', function () { + return 'normalized'; + }); + + $this->assertEquals(array('foo' => 'normalized'), $this->resolver->resolve()); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException + */ + public function testSetNormalizerFailsIfUnknownOption() + { + $this->resolver->setNormalizer('foo', function () {}); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException + */ + public function testFailIfSetNormalizerFromLazyOption() + { + $this->resolver->setDefault('foo', function (Options $options) { + $options->setNormalizer('foo', function () {}); + }); + + $this->resolver->setDefault('bar', 'baz'); + + $this->resolver->resolve(); + } + + public function testNormalizerReceivesSetOption() + { + $this->resolver->setDefault('foo', 'bar'); + + $this->resolver->setNormalizer('foo', function (Options $options, $value) { + return 'normalized['.$value.']'; + }); + + $this->assertEquals(array('foo' => 'normalized[bar]'), $this->resolver->resolve()); + } + + public function testNormalizerReceivesPassedOption() + { + $this->resolver->setDefault('foo', 'bar'); + + $this->resolver->setNormalizer('foo', function (Options $options, $value) { + return 'normalized['.$value.']'; + }); + + $resolved = $this->resolver->resolve(array('foo' => 'baz')); + + $this->assertEquals(array('foo' => 'normalized[baz]'), $resolved); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException + */ + public function testValidateTypeBeforeNormalization() + { + $this->resolver->setDefault('foo', 'bar'); + + $this->resolver->setAllowedTypes('foo', 'int'); + + $this->resolver->setNormalizer('foo', function () { + Assert::fail('Should not be called.'); + }); + + $this->resolver->resolve(); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException + */ + public function testValidateValueBeforeNormalization() + { + $this->resolver->setDefault('foo', 'bar'); + + $this->resolver->setAllowedValues('foo', 'baz'); + + $this->resolver->setNormalizer('foo', function () { + Assert::fail('Should not be called.'); + }); + + $this->resolver->resolve(); + } + + public function testNormalizerCanAccessOtherOptions() + { + $this->resolver->setDefault('default', 'bar'); + $this->resolver->setDefault('norm', 'baz'); + + $this->resolver->setNormalizer('norm', function (Options $options) { + /* @var TestCase $test */ + Assert::assertSame('bar', $options['default']); + + return 'normalized'; + }); + + $this->assertEquals(array( + 'default' => 'bar', + 'norm' => 'normalized', + ), $this->resolver->resolve()); + } + + public function testNormalizerCanAccessLazyOptions() + { + $this->resolver->setDefault('lazy', function (Options $options) { + return 'bar'; + }); + $this->resolver->setDefault('norm', 'baz'); + + $this->resolver->setNormalizer('norm', function (Options $options) { + /* @var TestCase $test */ + Assert::assertEquals('bar', $options['lazy']); + + return 'normalized'; + }); + + $this->assertEquals(array( + 'lazy' => 'bar', + 'norm' => 'normalized', + ), $this->resolver->resolve()); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\OptionDefinitionException + */ + public function testFailIfCyclicDependencyBetweenNormalizers() + { + $this->resolver->setDefault('norm1', 'bar'); + $this->resolver->setDefault('norm2', 'baz'); + + $this->resolver->setNormalizer('norm1', function (Options $options) { + $options['norm2']; + }); + + $this->resolver->setNormalizer('norm2', function (Options $options) { + $options['norm1']; + }); + + $this->resolver->resolve(); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\OptionDefinitionException + */ + public function testFailIfCyclicDependencyBetweenNormalizerAndLazyOption() + { + $this->resolver->setDefault('lazy', function (Options $options) { + $options['norm']; + }); + + $this->resolver->setDefault('norm', 'baz'); + + $this->resolver->setNormalizer('norm', function (Options $options) { + $options['lazy']; + }); + + $this->resolver->resolve(); + } + + public function testCaughtExceptionFromNormalizerDoesNotCrashOptionResolver() + { + $throw = true; + + $this->resolver->setDefaults(array('catcher' => null, 'thrower' => null)); + + $this->resolver->setNormalizer('catcher', function (Options $options) { + try { + return $options['thrower']; + } catch (\Exception $e) { + return false; + } + }); + + $this->resolver->setNormalizer('thrower', function () use (&$throw) { + if ($throw) { + $throw = false; + throw new \UnexpectedValueException('throwing'); + } + + return true; + }); + + $this->assertSame(array('catcher' => false, 'thrower' => true), $this->resolver->resolve()); + } + + public function testCaughtExceptionFromLazyDoesNotCrashOptionResolver() + { + $throw = true; + + $this->resolver->setDefault('catcher', function (Options $options) { + try { + return $options['thrower']; + } catch (\Exception $e) { + return false; + } + }); + + $this->resolver->setDefault('thrower', function (Options $options) use (&$throw) { + if ($throw) { + $throw = false; + throw new \UnexpectedValueException('throwing'); + } + + return true; + }); + + $this->assertSame(array('catcher' => false, 'thrower' => true), $this->resolver->resolve()); + } + + public function testInvokeEachNormalizerOnlyOnce() + { + $calls = 0; + + $this->resolver->setDefault('norm1', 'bar'); + $this->resolver->setDefault('norm2', 'baz'); + + $this->resolver->setNormalizer('norm1', function ($options) use (&$calls) { + Assert::assertSame(1, ++$calls); + + $options['norm2']; + }); + $this->resolver->setNormalizer('norm2', function () use (&$calls) { + Assert::assertSame(2, ++$calls); + }); + + $this->resolver->resolve(); + + $this->assertSame(2, $calls); + } + + public function testNormalizerNotCalledForUnsetOptions() + { + $this->resolver->setDefined('norm'); + + $this->resolver->setNormalizer('norm', function () { + Assert::fail('Should not be called.'); + }); + + $this->assertEmpty($this->resolver->resolve()); + } + + //////////////////////////////////////////////////////////////////////////// + // setDefaults() + //////////////////////////////////////////////////////////////////////////// + + public function testSetDefaultsReturnsThis() + { + $this->assertSame($this->resolver, $this->resolver->setDefaults(array('foo', 'bar'))); + } + + public function testSetDefaults() + { + $this->resolver->setDefault('one', '1'); + $this->resolver->setDefault('two', 'bar'); + + $this->resolver->setDefaults(array( + 'two' => '2', + 'three' => '3', + )); + + $this->assertEquals(array( + 'one' => '1', + 'two' => '2', + 'three' => '3', + ), $this->resolver->resolve()); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException + */ + public function testFailIfSetDefaultsFromLazyOption() + { + $this->resolver->setDefault('foo', function (Options $options) { + $options->setDefaults(array('two' => '2')); + }); + + $this->resolver->resolve(); + } + + //////////////////////////////////////////////////////////////////////////// + // remove() + //////////////////////////////////////////////////////////////////////////// + + public function testRemoveReturnsThis() + { + $this->resolver->setDefault('foo', 'bar'); + + $this->assertSame($this->resolver, $this->resolver->remove('foo')); + } + + public function testRemoveSingleOption() + { + $this->resolver->setDefault('foo', 'bar'); + $this->resolver->setDefault('baz', 'boo'); + $this->resolver->remove('foo'); + + $this->assertSame(array('baz' => 'boo'), $this->resolver->resolve()); + } + + public function testRemoveMultipleOptions() + { + $this->resolver->setDefault('foo', 'bar'); + $this->resolver->setDefault('baz', 'boo'); + $this->resolver->setDefault('doo', 'dam'); + + $this->resolver->remove(array('foo', 'doo')); + + $this->assertSame(array('baz' => 'boo'), $this->resolver->resolve()); + } + + public function testRemoveLazyOption() + { + $this->resolver->setDefault('foo', function (Options $options) { + return 'lazy'; + }); + $this->resolver->remove('foo'); + + $this->assertSame(array(), $this->resolver->resolve()); + } + + public function testRemoveNormalizer() + { + $this->resolver->setDefault('foo', 'bar'); + $this->resolver->setNormalizer('foo', function (Options $options, $value) { + return 'normalized'; + }); + $this->resolver->remove('foo'); + $this->resolver->setDefault('foo', 'bar'); + + $this->assertSame(array('foo' => 'bar'), $this->resolver->resolve()); + } + + public function testRemoveAllowedTypes() + { + $this->resolver->setDefault('foo', 'bar'); + $this->resolver->setAllowedTypes('foo', 'int'); + $this->resolver->remove('foo'); + $this->resolver->setDefault('foo', 'bar'); + + $this->assertSame(array('foo' => 'bar'), $this->resolver->resolve()); + } + + public function testRemoveAllowedValues() + { + $this->resolver->setDefault('foo', 'bar'); + $this->resolver->setAllowedValues('foo', array('baz', 'boo')); + $this->resolver->remove('foo'); + $this->resolver->setDefault('foo', 'bar'); + + $this->assertSame(array('foo' => 'bar'), $this->resolver->resolve()); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException + */ + public function testFailIfRemoveFromLazyOption() + { + $this->resolver->setDefault('foo', function (Options $options) { + $options->remove('bar'); + }); + + $this->resolver->setDefault('bar', 'baz'); + + $this->resolver->resolve(); + } + + public function testRemoveUnknownOptionIgnored() + { + $this->assertNotNull($this->resolver->remove('foo')); + } + + //////////////////////////////////////////////////////////////////////////// + // clear() + //////////////////////////////////////////////////////////////////////////// + + public function testClearReturnsThis() + { + $this->assertSame($this->resolver, $this->resolver->clear()); + } + + public function testClearRemovesAllOptions() + { + $this->resolver->setDefault('one', 1); + $this->resolver->setDefault('two', 2); + + $this->resolver->clear(); + + $this->assertEmpty($this->resolver->resolve()); + } + + public function testClearLazyOption() + { + $this->resolver->setDefault('foo', function (Options $options) { + return 'lazy'; + }); + $this->resolver->clear(); + + $this->assertSame(array(), $this->resolver->resolve()); + } + + public function testClearNormalizer() + { + $this->resolver->setDefault('foo', 'bar'); + $this->resolver->setNormalizer('foo', function (Options $options, $value) { + return 'normalized'; + }); + $this->resolver->clear(); + $this->resolver->setDefault('foo', 'bar'); + + $this->assertSame(array('foo' => 'bar'), $this->resolver->resolve()); + } + + public function testClearAllowedTypes() + { + $this->resolver->setDefault('foo', 'bar'); + $this->resolver->setAllowedTypes('foo', 'int'); + $this->resolver->clear(); + $this->resolver->setDefault('foo', 'bar'); + + $this->assertSame(array('foo' => 'bar'), $this->resolver->resolve()); + } + + public function testClearAllowedValues() + { + $this->resolver->setDefault('foo', 'bar'); + $this->resolver->setAllowedValues('foo', 'baz'); + $this->resolver->clear(); + $this->resolver->setDefault('foo', 'bar'); + + $this->assertSame(array('foo' => 'bar'), $this->resolver->resolve()); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException + */ + public function testFailIfClearFromLazyption() + { + $this->resolver->setDefault('foo', function (Options $options) { + $options->clear(); + }); + + $this->resolver->setDefault('bar', 'baz'); + + $this->resolver->resolve(); + } + + public function testClearOptionAndNormalizer() + { + $this->resolver->setDefault('foo1', 'bar'); + $this->resolver->setNormalizer('foo1', function (Options $options) { + return ''; + }); + $this->resolver->setDefault('foo2', 'bar'); + $this->resolver->setNormalizer('foo2', function (Options $options) { + return ''; + }); + + $this->resolver->clear(); + $this->assertEmpty($this->resolver->resolve()); + } + + //////////////////////////////////////////////////////////////////////////// + // ArrayAccess + //////////////////////////////////////////////////////////////////////////// + + public function testArrayAccess() + { + $this->resolver->setDefault('default1', 0); + $this->resolver->setDefault('default2', 1); + $this->resolver->setRequired('required'); + $this->resolver->setDefined('defined'); + $this->resolver->setDefault('lazy1', function (Options $options) { + return 'lazy'; + }); + + $this->resolver->setDefault('lazy2', function (Options $options) { + Assert::assertTrue(isset($options['default1'])); + Assert::assertTrue(isset($options['default2'])); + Assert::assertTrue(isset($options['required'])); + Assert::assertTrue(isset($options['lazy1'])); + Assert::assertTrue(isset($options['lazy2'])); + Assert::assertFalse(isset($options['defined'])); + + Assert::assertSame(0, $options['default1']); + Assert::assertSame(42, $options['default2']); + Assert::assertSame('value', $options['required']); + Assert::assertSame('lazy', $options['lazy1']); + + // Obviously $options['lazy'] and $options['defined'] cannot be + // accessed + }); + + $this->resolver->resolve(array('default2' => 42, 'required' => 'value')); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException + */ + public function testArrayAccessGetFailsOutsideResolve() + { + $this->resolver->setDefault('default', 0); + + $this->resolver['default']; + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException + */ + public function testArrayAccessExistsFailsOutsideResolve() + { + $this->resolver->setDefault('default', 0); + + isset($this->resolver['default']); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException + */ + public function testArrayAccessSetNotSupported() + { + $this->resolver['default'] = 0; + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException + */ + public function testArrayAccessUnsetNotSupported() + { + $this->resolver->setDefault('default', 0); + + unset($this->resolver['default']); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\NoSuchOptionException + * @expectedExceptionMessage The option "undefined" does not exist. Defined options are: "foo", "lazy". + */ + public function testFailIfGetNonExisting() + { + $this->resolver->setDefault('foo', 'bar'); + + $this->resolver->setDefault('lazy', function (Options $options) { + $options['undefined']; + }); + + $this->resolver->resolve(); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\NoSuchOptionException + * @expectedExceptionMessage The optional option "defined" has no value set. You should make sure it is set with "isset" before reading it. + */ + public function testFailIfGetDefinedButUnset() + { + $this->resolver->setDefined('defined'); + + $this->resolver->setDefault('lazy', function (Options $options) { + $options['defined']; + }); + + $this->resolver->resolve(); + } + + /** + * @expectedException \Symfony\Component\OptionsResolver\Exception\OptionDefinitionException + */ + public function testFailIfCyclicDependency() + { + $this->resolver->setDefault('lazy1', function (Options $options) { + $options['lazy2']; + }); + + $this->resolver->setDefault('lazy2', function (Options $options) { + $options['lazy1']; + }); + + $this->resolver->resolve(); + } + + //////////////////////////////////////////////////////////////////////////// + // Countable + //////////////////////////////////////////////////////////////////////////// + + public function testCount() + { + $this->resolver->setDefault('default', 0); + $this->resolver->setRequired('required'); + $this->resolver->setDefined('defined'); + $this->resolver->setDefault('lazy1', function () {}); + + $this->resolver->setDefault('lazy2', function (Options $options) { + Assert::assertCount(4, $options); + }); + + $this->assertCount(4, $this->resolver->resolve(array('required' => 'value'))); + } + + /** + * In resolve() we count the options that are actually set (which may be + * only a subset of the defined options). Outside of resolve(), it's not + * clear what is counted. + * + * @expectedException \Symfony\Component\OptionsResolver\Exception\AccessException + */ + public function testCountFailsOutsideResolve() + { + $this->resolver->setDefault('foo', 0); + $this->resolver->setRequired('bar'); + $this->resolver->setDefined('bar'); + $this->resolver->setDefault('lazy1', function () {}); + + count($this->resolver); + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/composer.json b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/composer.json new file mode 100644 index 0000000..895847e --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/composer.json @@ -0,0 +1,33 @@ +{ + "name": "symfony/options-resolver", + "type": "library", + "description": "Symfony OptionsResolver Component", + "keywords": ["options", "config", "configuration"], + "homepage": "https://symfony.com", + "license": "MIT", + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "require": { + "php": "^5.5.9|>=7.0.8" + }, + "autoload": { + "psr-4": { "Symfony\\Component\\OptionsResolver\\": "" }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "minimum-stability": "dev", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/phpunit.xml.dist b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/phpunit.xml.dist new file mode 100644 index 0000000..7e04e60 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/symfony/options-resolver/phpunit.xml.dist @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd" + backupGlobals="false" + colors="true" + bootstrap="vendor/autoload.php" + failOnRisky="true" + failOnWarning="true" +> + <php> + <ini name="error_reporting" value="-1" /> + </php> + + <testsuites> + <testsuite name="Symfony OptionsResolver Component Test Suite"> + <directory>./Tests/</directory> + </testsuite> + </testsuites> + + <filter> + <whitelist> + <directory>./</directory> + <exclude> + <directory>./Resources</directory> + <directory>./Tests</directory> + <directory>./vendor</directory> + </exclude> + </whitelist> + </filter> +</phpunit> diff --git a/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/.composer-auth.json b/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/.composer-auth.json new file mode 100644 index 0000000..eea8001 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/.composer-auth.json @@ -0,0 +1,7 @@ +{ + "github-oauth": { + "github.com": "PLEASE DO NOT USE THIS TOKEN IN YOUR OWN PROJECTS/FORKS", + "github.com": "This token is reserved for testing the webmozart/* repositories", + "github.com": "a9debbffdd953ee9b3b82dbc3b807cde2086bb86" + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/.gitignore b/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/.gitignore new file mode 100644 index 0000000..3a9875b --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/.gitignore @@ -0,0 +1,2 @@ +/vendor/ +composer.lock diff --git a/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/.styleci.yml b/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/.styleci.yml new file mode 100644 index 0000000..92da20f --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/.styleci.yml @@ -0,0 +1,8 @@ +preset: symfony + +enabled: + - ordered_use + +disabled: + - empty_return + - phpdoc_annotation_without_dot # This is still buggy: https://github.com/symfony/symfony/pull/19198 diff --git a/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/.travis.yml b/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/.travis.yml new file mode 100644 index 0000000..1265196 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/.travis.yml @@ -0,0 +1,39 @@ +language: php + +sudo: false + +branches: + only: + - master + +cache: + directories: + - $HOME/.composer/cache/files + +matrix: + include: + - php: 5.3 + - php: 5.4 + - php: 5.5 + - php: 5.6 + - php: hhvm + - php: nightly + - php: 7.0 + env: COVERAGE=yes + - php: 7.0 + env: COMPOSER_FLAGS='--prefer-lowest --prefer-stable' + allow_failures: + - php: hhvm + - php: nightly + fast_finish: true + +before_install: + - if [[ $TRAVIS_PHP_VERSION != hhvm && $COVERAGE != yes ]]; then phpenv config-rm xdebug.ini; fi; + - if [[ $TRAVIS_REPO_SLUG = webmozart/assert ]]; then cp .composer-auth.json ~/.composer/auth.json; fi; + - composer self-update + +install: composer update $COMPOSER_FLAGS --prefer-dist --no-interaction + +script: if [[ $COVERAGE = yes ]]; then vendor/bin/phpunit --verbose --coverage-clover=coverage.clover; else vendor/bin/phpunit --verbose; fi + +after_script: if [[ $COVERAGE = yes ]]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi diff --git a/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/CHANGELOG.md b/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/CHANGELOG.md new file mode 100644 index 0000000..3298361 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/CHANGELOG.md @@ -0,0 +1,34 @@ +Changelog +========= + +* 1.2.0 (2016-11-23) + + * added `Assert::throws()` + * added `Assert::count()` + * added extension point `Assert::reportInvalidArgument()` for custom subclasses + +* 1.1.0 (2016-08-09) + + * added `Assert::object()` + * added `Assert::propertyExists()` + * added `Assert::propertyNotExists()` + * added `Assert::methodExists()` + * added `Assert::methodNotExists()` + * added `Assert::uuid()` + +* 1.0.2 (2015-08-24) + + * integrated Style CI + * add tests for minimum package dependencies on Travis CI + +* 1.0.1 (2015-05-12) + + * added support for PHP 5.3.3 + +* 1.0.0 (2015-05-12) + + * first stable release + +* 1.0.0-beta (2015-03-19) + + * first beta release diff --git a/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/LICENSE b/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/LICENSE new file mode 100644 index 0000000..9e2e307 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2014 Bernhard Schussek + +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/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/README.md b/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/README.md new file mode 100644 index 0000000..d176860 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/README.md @@ -0,0 +1,242 @@ +Webmozart Assert +================ + +[![Build Status](https://travis-ci.org/webmozart/assert.svg?branch=1.2.0)](https://travis-ci.org/webmozart/assert) +[![Build status](https://ci.appveyor.com/api/projects/status/lyg83bcsisrr94se/branch/master?svg=true)](https://ci.appveyor.com/project/webmozart/assert/branch/master) +[![Latest Stable Version](https://poser.pugx.org/webmozart/assert/v/stable.svg)](https://packagist.org/packages/webmozart/assert) +[![Total Downloads](https://poser.pugx.org/webmozart/assert/downloads.svg)](https://packagist.org/packages/webmozart/assert) +[![Dependency Status](https://www.versioneye.com/php/webmozart:assert/1.2.0/badge.svg)](https://www.versioneye.com/php/webmozart:assert/1.2.0) + +Latest release: [1.2.0](https://packagist.org/packages/webmozart/assert#1.2.0) + +PHP >= 5.3.9 + +This library contains efficient assertions to test the input and output of +your methods. With these assertions, you can greatly reduce the amount of coding +needed to write a safe implementation. + +All assertions in the [`Assert`] class throw an `\InvalidArgumentException` if +they fail. + +FAQ +--- + +**What's the difference to [beberlei/assert]?** + +This library is heavily inspired by Benjamin Eberlei's wonderful [assert package], +but fixes a usability issue with error messages that can't be fixed there without +breaking backwards compatibility. + +This package features usable error messages by default. However, you can also +easily write custom error messages: + +``` +Assert::string($path, 'The path is expected to be a string. Got: %s'); +``` + +In [beberlei/assert], the ordering of the `%s` placeholders is different for +every assertion. This package, on the contrary, provides consistent placeholder +ordering for all assertions: + +* `%s`: The tested value as string, e.g. `"/foo/bar"`. +* `%2$s`, `%3$s`, ...: Additional assertion-specific values, e.g. the + minimum/maximum length, allowed values, etc. + +Check the source code of the assertions to find out details about the additional +available placeholders. + +Installation +------------ + +Use [Composer] to install the package: + +``` +$ composer require webmozart/assert +``` + +Example +------- + +```php +use Webmozart\Assert\Assert; + +class Employee +{ + public function __construct($id) + { + Assert::integer($id, 'The employee ID must be an integer. Got: %s'); + Assert::greaterThan($id, 0, 'The employee ID must be a positive integer. Got: %s'); + } +} +``` + +If you create an employee with an invalid ID, an exception is thrown: + +```php +new Employee('foobar'); +// => InvalidArgumentException: +// The employee ID must be an integer. Got: string + +new Employee(-10); +// => InvalidArgumentException: +// The employee ID must be a positive integer. Got: -10 +``` + +Assertions +---------- + +The [`Assert`] class provides the following assertions: + +### Type Assertions + +Method | Description +----------------------------------------------- | -------------------------------------------------- +`string($value, $message = '')` | Check that a value is a string +`stringNotEmpty($value, $message = '')` | Check that a value is a non-empty string +`integer($value, $message = '')` | Check that a value is an integer +`integerish($value, $message = '')` | Check that a value casts to an integer +`float($value, $message = '')` | Check that a value is a float +`numeric($value, $message = '')` | Check that a value is numeric +`boolean($value, $message = '')` | Check that a value is a boolean +`scalar($value, $message = '')` | Check that a value is a scalar +`object($value, $message = '')` | Check that a value is an object +`resource($value, $type = null, $message = '')` | Check that a value is a resource +`isCallable($value, $message = '')` | Check that a value is a callable +`isArray($value, $message = '')` | Check that a value is an array +`isTraversable($value, $message = '')` | Check that a value is an array or a `\Traversable` +`isInstanceOf($value, $class, $message = '')` | Check that a value is an `instanceof` a class +`notInstanceOf($value, $class, $message = '')` | Check that a value is not an `instanceof` a class + +### Comparison Assertions + +Method | Description +----------------------------------------------- | -------------------------------------------------- +`true($value, $message = '')` | Check that a value is `true` +`false($value, $message = '')` | Check that a value is `false` +`null($value, $message = '')` | Check that a value is `null` +`notNull($value, $message = '')` | Check that a value is not `null` +`isEmpty($value, $message = '')` | Check that a value is `empty()` +`notEmpty($value, $message = '')` | Check that a value is not `empty()` +`eq($value, $value2, $message = '')` | Check that a value equals another (`==`) +`notEq($value, $value2, $message = '')` | Check that a value does not equal another (`!=`) +`same($value, $value2, $message = '')` | Check that a value is identical to another (`===`) +`notSame($value, $value2, $message = '')` | Check that a value is not identical to another (`!==`) +`greaterThan($value, $value2, $message = '')` | Check that a value is greater than another +`greaterThanEq($value, $value2, $message = '')` | Check that a value is greater than or equal to another +`lessThan($value, $value2, $message = '')` | Check that a value is less than another +`lessThanEq($value, $value2, $message = '')` | Check that a value is less than or equal to another +`range($value, $min, $max, $message = '')` | Check that a value is within a range +`oneOf($value, array $values, $message = '')` | Check that a value is one of a list of values + +### String Assertions + +You should check that a value is a string with `Assert::string()` before making +any of the following assertions. + +Method | Description +--------------------------------------------------- | -------------------------------------------------- +`contains($value, $subString, $message = '')` | Check that a string contains a substring +`startsWith($value, $prefix, $message = '')` | Check that a string has a prefix +`startsWithLetter($value, $message = '')` | Check that a string starts with a letter +`endsWith($value, $suffix, $message = '')` | Check that a string has a suffix +`regex($value, $pattern, $message = '')` | Check that a string matches a regular expression +`alpha($value, $message = '')` | Check that a string contains letters only +`digits($value, $message = '')` | Check that a string contains digits only +`alnum($value, $message = '')` | Check that a string contains letters and digits only +`lower($value, $message = '')` | Check that a string contains lowercase characters only +`upper($value, $message = '')` | Check that a string contains uppercase characters only +`length($value, $length, $message = '')` | Check that a string has a certain number of characters +`minLength($value, $min, $message = '')` | Check that a string has at least a certain number of characters +`maxLength($value, $max, $message = '')` | Check that a string has at most a certain number of characters +`lengthBetween($value, $min, $max, $message = '')` | Check that a string has a length in the given range +`uuid($value, $message = '')` | Check that a string is a valid UUID + +### File Assertions + +Method | Description +----------------------------------- | -------------------------------------------------- +`fileExists($value, $message = '')` | Check that a value is an existing path +`file($value, $message = '')` | Check that a value is an existing file +`directory($value, $message = '')` | Check that a value is an existing directory +`readable($value, $message = '')` | Check that a value is a readable path +`writable($value, $message = '')` | Check that a value is a writable path + +### Object Assertions + +Method | Description +----------------------------------------------------- | -------------------------------------------------- +`classExists($value, $message = '')` | Check that a value is an existing class name +`subclassOf($value, $class, $message = '')` | Check that a class is a subclass of another +`implementsInterface($value, $class, $message = '')` | Check that a class implements an interface +`propertyExists($value, $property, $message = '')` | Check that a property exists in a class/object +`propertyNotExists($value, $property, $message = '')` | Check that a property does not exist in a class/object +`methodExists($value, $method, $message = '')` | Check that a method exists in a class/object +`methodNotExists($value, $method, $message = '')` | Check that a method does not exist in a class/object + +### Array Assertions + +Method | Description +------------------------------------------- | -------------------------------------------------- +`keyExists($array, $key, $message = '')` | Check that a key exists in an array +`keyNotExists($array, $key, $message = '')` | Check that a key does not exist in an array +`count($array, $number, $message = '')` | Check that an array contains a specific number of elements + +### Function Assertions + +Method | Description +------------------------------------------- | ----------------------------------------------------------------------------------------------------- +`throws($closure, $class, $message = '')` | Check that a function throws a certain exception. Subclasses of the exception class will be accepted. + +### Collection Assertions + +All of the above assertions can be prefixed with `all*()` to test the contents +of an array or a `\Traversable`: + +```php +Assert::allIsInstanceOf($employees, 'Acme\Employee'); +``` + +### Nullable Assertions + +All of the above assertions can be prefixed with `nullOr*()` to run the +assertion only if it the value is not `null`: + +```php +Assert::nullOrString($middleName, 'The middle name must be a string or null. Got: %s'); +``` + +Authors +------- + +* [Bernhard Schussek] a.k.a. [@webmozart] +* [The Community Contributors] + +Contribute +---------- + +Contributions to the package are always welcome! + +* Report any bugs or issues you find on the [issue tracker]. +* You can grab the source code at the package's [Git repository]. + +Support +------- + +If you are having problems, send a mail to bschussek@gmail.com or shout out to +[@webmozart] on Twitter. + +License +------- + +All contents of this package are licensed under the [MIT license]. + +[beberlei/assert]: https://github.com/beberlei/assert +[assert package]: https://github.com/beberlei/assert +[Composer]: https://getcomposer.org +[Bernhard Schussek]: http://webmozarts.com +[The Community Contributors]: https://github.com/webmozart/assert/graphs/contributors +[issue tracker]: https://github.com/webmozart/assert +[Git repository]: https://github.com/webmozart/assert +[@webmozart]: https://twitter.com/webmozart +[MIT license]: LICENSE +[`Assert`]: src/Assert.php diff --git a/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/appveyor.yml b/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/appveyor.yml new file mode 100644 index 0000000..3a413bc --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/appveyor.yml @@ -0,0 +1,40 @@ +build: false +platform: x86 +clone_folder: c:\projects\webmozart\assert + +branches: + only: + - master + +cache: + - c:\php -> appveyor.yml + +init: + - SET PATH=c:\php;%PATH% + - SET COMPOSER_NO_INTERACTION=1 + - SET PHP=1 + +install: + - IF EXIST c:\php (SET PHP=0) ELSE (mkdir c:\php) + - cd c:\php + - IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/releases/archives/php-7.0.0-nts-Win32-VC14-x86.zip + - IF %PHP%==1 7z x php-7.0.0-nts-Win32-VC14-x86.zip -y >nul + - IF %PHP%==1 del /Q *.zip + - IF %PHP%==1 echo @php %%~dp0composer.phar %%* > composer.bat + - IF %PHP%==1 copy /Y php.ini-development php.ini + - IF %PHP%==1 echo max_execution_time=1200 >> php.ini + - IF %PHP%==1 echo date.timezone="UTC" >> php.ini + - IF %PHP%==1 echo extension_dir=ext >> php.ini + - IF %PHP%==1 echo extension=php_curl.dll >> php.ini + - IF %PHP%==1 echo extension=php_openssl.dll >> php.ini + - IF %PHP%==1 echo extension=php_mbstring.dll >> php.ini + - IF %PHP%==1 echo extension=php_fileinfo.dll >> php.ini + - appveyor DownloadFile https://getcomposer.org/composer.phar + - cd c:\projects\webmozart\assert + - mkdir %APPDATA%\Composer + - IF %APPVEYOR_REPO_NAME%==webmozart/assert copy /Y .composer-auth.json %APPDATA%\Composer\auth.json + - composer update --prefer-dist --no-progress --ansi + +test_script: + - cd c:\projects\webmozart\assert + - vendor\bin\phpunit.bat --verbose diff --git a/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/composer.json b/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/composer.json new file mode 100644 index 0000000..c49e623 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/composer.json @@ -0,0 +1,34 @@ +{ + "name": "webmozart/assert", + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": ["assert", "check", "validate"], + "license": "MIT", + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.6", + "sebastian/version": "^1.0.1" + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Webmozart\\Assert\\Tests\\": "tests/" + } + }, + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/phpunit.xml.dist b/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/phpunit.xml.dist new file mode 100644 index 0000000..db20e9b --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/phpunit.xml.dist @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<phpunit bootstrap="vendor/autoload.php" colors="true"> + <testsuites> + <testsuite name="Webmozart Assert Test Suite"> + <directory suffix="Test.php">./tests/</directory> + </testsuite> + </testsuites> + + <!-- Whitelist for code coverage --> + <filter> + <whitelist> + <directory suffix=".php">./src/</directory> + </whitelist> + </filter> +</phpunit> diff --git a/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/src/Assert.php b/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/src/Assert.php new file mode 100644 index 0000000..083ad20 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/src/Assert.php @@ -0,0 +1,948 @@ +<?php + +/* + * This file is part of the webmozart/assert package. + * + * (c) Bernhard Schussek <bschussek@gmail.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Webmozart\Assert; + +use BadMethodCallException; +use InvalidArgumentException; +use Traversable; +use Exception; +use Throwable; +use Closure; + +/** + * Efficient assertions to validate the input/output of your methods. + * + * @method static void nullOrString($value, $message = '') + * @method static void nullOrStringNotEmpty($value, $message = '') + * @method static void nullOrInteger($value, $message = '') + * @method static void nullOrIntegerish($value, $message = '') + * @method static void nullOrFloat($value, $message = '') + * @method static void nullOrNumeric($value, $message = '') + * @method static void nullOrBoolean($value, $message = '') + * @method static void nullOrScalar($value, $message = '') + * @method static void nullOrObject($value, $message = '') + * @method static void nullOrResource($value, $type = null, $message = '') + * @method static void nullOrIsCallable($value, $message = '') + * @method static void nullOrIsArray($value, $message = '') + * @method static void nullOrIsTraversable($value, $message = '') + * @method static void nullOrIsInstanceOf($value, $class, $message = '') + * @method static void nullOrNotInstanceOf($value, $class, $message = '') + * @method static void nullOrIsEmpty($value, $message = '') + * @method static void nullOrNotEmpty($value, $message = '') + * @method static void nullOrTrue($value, $message = '') + * @method static void nullOrFalse($value, $message = '') + * @method static void nullOrEq($value, $value2, $message = '') + * @method static void nullOrNotEq($value,$value2, $message = '') + * @method static void nullOrSame($value, $value2, $message = '') + * @method static void nullOrNotSame($value, $value2, $message = '') + * @method static void nullOrGreaterThan($value, $value2, $message = '') + * @method static void nullOrGreaterThanEq($value, $value2, $message = '') + * @method static void nullOrLessThan($value, $value2, $message = '') + * @method static void nullOrLessThanEq($value, $value2, $message = '') + * @method static void nullOrRange($value, $min, $max, $message = '') + * @method static void nullOrOneOf($value, $values, $message = '') + * @method static void nullOrContains($value, $subString, $message = '') + * @method static void nullOrStartsWith($value, $prefix, $message = '') + * @method static void nullOrStartsWithLetter($value, $message = '') + * @method static void nullOrEndsWith($value, $suffix, $message = '') + * @method static void nullOrRegex($value, $pattern, $message = '') + * @method static void nullOrAlpha($value, $message = '') + * @method static void nullOrDigits($value, $message = '') + * @method static void nullOrAlnum($value, $message = '') + * @method static void nullOrLower($value, $message = '') + * @method static void nullOrUpper($value, $message = '') + * @method static void nullOrLength($value, $length, $message = '') + * @method static void nullOrMinLength($value, $min, $message = '') + * @method static void nullOrMaxLength($value, $max, $message = '') + * @method static void nullOrLengthBetween($value, $min, $max, $message = '') + * @method static void nullOrFileExists($value, $message = '') + * @method static void nullOrFile($value, $message = '') + * @method static void nullOrDirectory($value, $message = '') + * @method static void nullOrReadable($value, $message = '') + * @method static void nullOrWritable($value, $message = '') + * @method static void nullOrClassExists($value, $message = '') + * @method static void nullOrSubclassOf($value, $class, $message = '') + * @method static void nullOrImplementsInterface($value, $interface, $message = '') + * @method static void nullOrPropertyExists($value, $property, $message = '') + * @method static void nullOrPropertyNotExists($value, $property, $message = '') + * @method static void nullOrMethodExists($value, $method, $message = '') + * @method static void nullOrMethodNotExists($value, $method, $message = '') + * @method static void nullOrKeyExists($value, $key, $message = '') + * @method static void nullOrKeyNotExists($value, $key, $message = '') + * @method static void nullOrCount($value, $key, $message = '') + * @method static void nullOrUuid($values, $message = '') + * @method static void allString($values, $message = '') + * @method static void allStringNotEmpty($values, $message = '') + * @method static void allInteger($values, $message = '') + * @method static void allIntegerish($values, $message = '') + * @method static void allFloat($values, $message = '') + * @method static void allNumeric($values, $message = '') + * @method static void allBoolean($values, $message = '') + * @method static void allScalar($values, $message = '') + * @method static void allObject($values, $message = '') + * @method static void allResource($values, $type = null, $message = '') + * @method static void allIsCallable($values, $message = '') + * @method static void allIsArray($values, $message = '') + * @method static void allIsTraversable($values, $message = '') + * @method static void allIsInstanceOf($values, $class, $message = '') + * @method static void allNotInstanceOf($values, $class, $message = '') + * @method static void allNull($values, $message = '') + * @method static void allNotNull($values, $message = '') + * @method static void allIsEmpty($values, $message = '') + * @method static void allNotEmpty($values, $message = '') + * @method static void allTrue($values, $message = '') + * @method static void allFalse($values, $message = '') + * @method static void allEq($values, $value2, $message = '') + * @method static void allNotEq($values,$value2, $message = '') + * @method static void allSame($values, $value2, $message = '') + * @method static void allNotSame($values, $value2, $message = '') + * @method static void allGreaterThan($values, $value2, $message = '') + * @method static void allGreaterThanEq($values, $value2, $message = '') + * @method static void allLessThan($values, $value2, $message = '') + * @method static void allLessThanEq($values, $value2, $message = '') + * @method static void allRange($values, $min, $max, $message = '') + * @method static void allOneOf($values, $values, $message = '') + * @method static void allContains($values, $subString, $message = '') + * @method static void allStartsWith($values, $prefix, $message = '') + * @method static void allStartsWithLetter($values, $message = '') + * @method static void allEndsWith($values, $suffix, $message = '') + * @method static void allRegex($values, $pattern, $message = '') + * @method static void allAlpha($values, $message = '') + * @method static void allDigits($values, $message = '') + * @method static void allAlnum($values, $message = '') + * @method static void allLower($values, $message = '') + * @method static void allUpper($values, $message = '') + * @method static void allLength($values, $length, $message = '') + * @method static void allMinLength($values, $min, $message = '') + * @method static void allMaxLength($values, $max, $message = '') + * @method static void allLengthBetween($values, $min, $max, $message = '') + * @method static void allFileExists($values, $message = '') + * @method static void allFile($values, $message = '') + * @method static void allDirectory($values, $message = '') + * @method static void allReadable($values, $message = '') + * @method static void allWritable($values, $message = '') + * @method static void allClassExists($values, $message = '') + * @method static void allSubclassOf($values, $class, $message = '') + * @method static void allImplementsInterface($values, $interface, $message = '') + * @method static void allPropertyExists($values, $property, $message = '') + * @method static void allPropertyNotExists($values, $property, $message = '') + * @method static void allMethodExists($values, $method, $message = '') + * @method static void allMethodNotExists($values, $method, $message = '') + * @method static void allKeyExists($values, $key, $message = '') + * @method static void allKeyNotExists($values, $key, $message = '') + * @method static void allCount($values, $key, $message = '') + * @method static void allUuid($values, $message = '') + * + * @since 1.0 + * + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class Assert +{ + public static function string($value, $message = '') + { + if (!is_string($value)) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a string. Got: %s', + static::typeToString($value) + )); + } + } + + public static function stringNotEmpty($value, $message = '') + { + static::string($value, $message); + static::notEmpty($value, $message); + } + + public static function integer($value, $message = '') + { + if (!is_int($value)) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected an integer. Got: %s', + static::typeToString($value) + )); + } + } + + public static function integerish($value, $message = '') + { + if (!is_numeric($value) || $value != (int) $value) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected an integerish value. Got: %s', + static::typeToString($value) + )); + } + } + + public static function float($value, $message = '') + { + if (!is_float($value)) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a float. Got: %s', + static::typeToString($value) + )); + } + } + + public static function numeric($value, $message = '') + { + if (!is_numeric($value)) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a numeric. Got: %s', + static::typeToString($value) + )); + } + } + + public static function boolean($value, $message = '') + { + if (!is_bool($value)) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a boolean. Got: %s', + static::typeToString($value) + )); + } + } + + public static function scalar($value, $message = '') + { + if (!is_scalar($value)) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a scalar. Got: %s', + static::typeToString($value) + )); + } + } + + public static function object($value, $message = '') + { + if (!is_object($value)) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected an object. Got: %s', + static::typeToString($value) + )); + } + } + + public static function resource($value, $type = null, $message = '') + { + if (!is_resource($value)) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a resource. Got: %s', + static::typeToString($value) + )); + } + + if ($type && $type !== get_resource_type($value)) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a resource of type %2$s. Got: %s', + static::typeToString($value), + $type + )); + } + } + + public static function isCallable($value, $message = '') + { + if (!is_callable($value)) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a callable. Got: %s', + static::typeToString($value) + )); + } + } + + public static function isArray($value, $message = '') + { + if (!is_array($value)) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected an array. Got: %s', + static::typeToString($value) + )); + } + } + + public static function isTraversable($value, $message = '') + { + if (!is_array($value) && !($value instanceof Traversable)) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a traversable. Got: %s', + static::typeToString($value) + )); + } + } + + public static function isInstanceOf($value, $class, $message = '') + { + if (!($value instanceof $class)) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected an instance of %2$s. Got: %s', + static::typeToString($value), + $class + )); + } + } + + public static function notInstanceOf($value, $class, $message = '') + { + if ($value instanceof $class) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected an instance other than %2$s. Got: %s', + static::typeToString($value), + $class + )); + } + } + + public static function isEmpty($value, $message = '') + { + if (!empty($value)) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected an empty value. Got: %s', + static::valueToString($value) + )); + } + } + + public static function notEmpty($value, $message = '') + { + if (empty($value)) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a non-empty value. Got: %s', + static::valueToString($value) + )); + } + } + + public static function null($value, $message = '') + { + if (null !== $value) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected null. Got: %s', + static::valueToString($value) + )); + } + } + + public static function notNull($value, $message = '') + { + if (null === $value) { + static::reportInvalidArgument( + $message ?: 'Expected a value other than null.' + ); + } + } + + public static function true($value, $message = '') + { + if (true !== $value) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a value to be true. Got: %s', + static::valueToString($value) + )); + } + } + + public static function false($value, $message = '') + { + if (false !== $value) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a value to be false. Got: %s', + static::valueToString($value) + )); + } + } + + public static function eq($value, $value2, $message = '') + { + if ($value2 != $value) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a value equal to %2$s. Got: %s', + static::valueToString($value), + static::valueToString($value2) + )); + } + } + + public static function notEq($value, $value2, $message = '') + { + if ($value2 == $value) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a different value than %s.', + static::valueToString($value2) + )); + } + } + + public static function same($value, $value2, $message = '') + { + if ($value2 !== $value) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a value identical to %2$s. Got: %s', + static::valueToString($value), + static::valueToString($value2) + )); + } + } + + public static function notSame($value, $value2, $message = '') + { + if ($value2 === $value) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a value not identical to %s.', + static::valueToString($value2) + )); + } + } + + public static function greaterThan($value, $limit, $message = '') + { + if ($value <= $limit) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a value greater than %2$s. Got: %s', + static::valueToString($value), + static::valueToString($limit) + )); + } + } + + public static function greaterThanEq($value, $limit, $message = '') + { + if ($value < $limit) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a value greater than or equal to %2$s. Got: %s', + static::valueToString($value), + static::valueToString($limit) + )); + } + } + + public static function lessThan($value, $limit, $message = '') + { + if ($value >= $limit) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a value less than %2$s. Got: %s', + static::valueToString($value), + static::valueToString($limit) + )); + } + } + + public static function lessThanEq($value, $limit, $message = '') + { + if ($value > $limit) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a value less than or equal to %2$s. Got: %s', + static::valueToString($value), + static::valueToString($limit) + )); + } + } + + public static function range($value, $min, $max, $message = '') + { + if ($value < $min || $value > $max) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a value between %2$s and %3$s. Got: %s', + static::valueToString($value), + static::valueToString($min), + static::valueToString($max) + )); + } + } + + public static function oneOf($value, array $values, $message = '') + { + if (!in_array($value, $values, true)) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected one of: %2$s. Got: %s', + static::valueToString($value), + implode(', ', array_map(array('static', 'valueToString'), $values)) + )); + } + } + + public static function contains($value, $subString, $message = '') + { + if (false === strpos($value, $subString)) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a value to contain %2$s. Got: %s', + static::valueToString($value), + static::valueToString($subString) + )); + } + } + + public static function startsWith($value, $prefix, $message = '') + { + if (0 !== strpos($value, $prefix)) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a value to start with %2$s. Got: %s', + static::valueToString($value), + static::valueToString($prefix) + )); + } + } + + public static function startsWithLetter($value, $message = '') + { + $valid = isset($value[0]); + + if ($valid) { + $locale = setlocale(LC_CTYPE, 0); + setlocale(LC_CTYPE, 'C'); + $valid = ctype_alpha($value[0]); + setlocale(LC_CTYPE, $locale); + } + + if (!$valid) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a value to start with a letter. Got: %s', + static::valueToString($value) + )); + } + } + + public static function endsWith($value, $suffix, $message = '') + { + if ($suffix !== substr($value, -static::strlen($suffix))) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a value to end with %2$s. Got: %s', + static::valueToString($value), + static::valueToString($suffix) + )); + } + } + + public static function regex($value, $pattern, $message = '') + { + if (!preg_match($pattern, $value)) { + static::reportInvalidArgument(sprintf( + $message ?: 'The value %s does not match the expected pattern.', + static::valueToString($value) + )); + } + } + + public static function alpha($value, $message = '') + { + $locale = setlocale(LC_CTYPE, 0); + setlocale(LC_CTYPE, 'C'); + $valid = !ctype_alpha($value); + setlocale(LC_CTYPE, $locale); + + if ($valid) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a value to contain only letters. Got: %s', + static::valueToString($value) + )); + } + } + + public static function digits($value, $message = '') + { + $locale = setlocale(LC_CTYPE, 0); + setlocale(LC_CTYPE, 'C'); + $valid = !ctype_digit($value); + setlocale(LC_CTYPE, $locale); + + if ($valid) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a value to contain digits only. Got: %s', + static::valueToString($value) + )); + } + } + + public static function alnum($value, $message = '') + { + $locale = setlocale(LC_CTYPE, 0); + setlocale(LC_CTYPE, 'C'); + $valid = !ctype_alnum($value); + setlocale(LC_CTYPE, $locale); + + if ($valid) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a value to contain letters and digits only. Got: %s', + static::valueToString($value) + )); + } + } + + public static function lower($value, $message = '') + { + $locale = setlocale(LC_CTYPE, 0); + setlocale(LC_CTYPE, 'C'); + $valid = !ctype_lower($value); + setlocale(LC_CTYPE, $locale); + + if ($valid) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a value to contain lowercase characters only. Got: %s', + static::valueToString($value) + )); + } + } + + public static function upper($value, $message = '') + { + $locale = setlocale(LC_CTYPE, 0); + setlocale(LC_CTYPE, 'C'); + $valid = !ctype_upper($value); + setlocale(LC_CTYPE, $locale); + + if ($valid) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a value to contain uppercase characters only. Got: %s', + static::valueToString($value) + )); + } + } + + public static function length($value, $length, $message = '') + { + if ($length !== static::strlen($value)) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a value to contain %2$s characters. Got: %s', + static::valueToString($value), + $length + )); + } + } + + public static function minLength($value, $min, $message = '') + { + if (static::strlen($value) < $min) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a value to contain at least %2$s characters. Got: %s', + static::valueToString($value), + $min + )); + } + } + + public static function maxLength($value, $max, $message = '') + { + if (static::strlen($value) > $max) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a value to contain at most %2$s characters. Got: %s', + static::valueToString($value), + $max + )); + } + } + + public static function lengthBetween($value, $min, $max, $message = '') + { + $length = static::strlen($value); + + if ($length < $min || $length > $max) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', + static::valueToString($value), + $min, + $max + )); + } + } + + public static function fileExists($value, $message = '') + { + static::string($value); + + if (!file_exists($value)) { + static::reportInvalidArgument(sprintf( + $message ?: 'The file %s does not exist.', + static::valueToString($value) + )); + } + } + + public static function file($value, $message = '') + { + static::fileExists($value, $message); + + if (!is_file($value)) { + static::reportInvalidArgument(sprintf( + $message ?: 'The path %s is not a file.', + static::valueToString($value) + )); + } + } + + public static function directory($value, $message = '') + { + static::fileExists($value, $message); + + if (!is_dir($value)) { + static::reportInvalidArgument(sprintf( + $message ?: 'The path %s is no directory.', + static::valueToString($value) + )); + } + } + + public static function readable($value, $message = '') + { + if (!is_readable($value)) { + static::reportInvalidArgument(sprintf( + $message ?: 'The path %s is not readable.', + static::valueToString($value) + )); + } + } + + public static function writable($value, $message = '') + { + if (!is_writable($value)) { + static::reportInvalidArgument(sprintf( + $message ?: 'The path %s is not writable.', + static::valueToString($value) + )); + } + } + + public static function classExists($value, $message = '') + { + if (!class_exists($value)) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected an existing class name. Got: %s', + static::valueToString($value) + )); + } + } + + public static function subclassOf($value, $class, $message = '') + { + if (!is_subclass_of($value, $class)) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected a sub-class of %2$s. Got: %s', + static::valueToString($value), + static::valueToString($class) + )); + } + } + + public static function implementsInterface($value, $interface, $message = '') + { + if (!in_array($interface, class_implements($value))) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected an implementation of %2$s. Got: %s', + static::valueToString($value), + static::valueToString($interface) + )); + } + } + + public static function propertyExists($classOrObject, $property, $message = '') + { + if (!property_exists($classOrObject, $property)) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected the property %s to exist.', + static::valueToString($property) + )); + } + } + + public static function propertyNotExists($classOrObject, $property, $message = '') + { + if (property_exists($classOrObject, $property)) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected the property %s to not exist.', + static::valueToString($property) + )); + } + } + + public static function methodExists($classOrObject, $method, $message = '') + { + if (!method_exists($classOrObject, $method)) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected the method %s to exist.', + static::valueToString($method) + )); + } + } + + public static function methodNotExists($classOrObject, $method, $message = '') + { + if (method_exists($classOrObject, $method)) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected the method %s to not exist.', + static::valueToString($method) + )); + } + } + + public static function keyExists($array, $key, $message = '') + { + if (!array_key_exists($key, $array)) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected the key %s to exist.', + static::valueToString($key) + )); + } + } + + public static function keyNotExists($array, $key, $message = '') + { + if (array_key_exists($key, $array)) { + static::reportInvalidArgument(sprintf( + $message ?: 'Expected the key %s to not exist.', + static::valueToString($key) + )); + } + } + + public static function count($array, $number, $message = '') + { + static::eq( + count($array), + $number, + $message ?: sprintf('Expected an array to contain %d elements. Got: %d.', $number, count($array)) + ); + } + + public static function uuid($value, $message = '') + { + $value = str_replace(array('urn:', 'uuid:', '{', '}'), '', $value); + + // The nil UUID is special form of UUID that is specified to have all + // 128 bits set to zero. + if ('00000000-0000-0000-0000-000000000000' === $value) { + return; + } + + if (!preg_match('/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/', $value)) { + static::reportInvalidArgument(sprintf( + $message ?: 'Value %s is not a valid UUID.', + static::valueToString($value) + )); + } + } + + public static function throws(Closure $expression, $class = 'Exception', $message = '') + { + static::string($class); + + $actual = 'none'; + try { + $expression(); + } catch (Exception $e) { + $actual = get_class($e); + if ($e instanceof $class) { + return; + } + } catch (Throwable $e) { + $actual = get_class($e); + if ($e instanceof $class) { + return; + } + } + + static::reportInvalidArgument($message ?: sprintf( + 'Expected to throw "%s", got "%s"', + $class, + $actual + )); + } + + public static function __callStatic($name, $arguments) + { + if ('nullOr' === substr($name, 0, 6)) { + if (null !== $arguments[0]) { + $method = lcfirst(substr($name, 6)); + call_user_func_array(array('static', $method), $arguments); + } + + return; + } + + if ('all' === substr($name, 0, 3)) { + static::isTraversable($arguments[0]); + + $method = lcfirst(substr($name, 3)); + $args = $arguments; + + foreach ($arguments[0] as $entry) { + $args[0] = $entry; + + call_user_func_array(array('static', $method), $args); + } + + return; + } + + throw new BadMethodCallException('No such method: '.$name); + } + + protected static function valueToString($value) + { + if (null === $value) { + return 'null'; + } + + if (true === $value) { + return 'true'; + } + + if (false === $value) { + return 'false'; + } + + if (is_array($value)) { + return 'array'; + } + + if (is_object($value)) { + return get_class($value); + } + + if (is_resource($value)) { + return 'resource'; + } + + if (is_string($value)) { + return '"'.$value.'"'; + } + + return (string) $value; + } + + protected static function typeToString($value) + { + return is_object($value) ? get_class($value) : gettype($value); + } + + protected static function strlen($value) + { + if (!function_exists('mb_detect_encoding')) { + return strlen($value); + } + + if (false === $encoding = mb_detect_encoding($value)) { + return strlen($value); + } + + return mb_strwidth($value, $encoding); + } + + protected static function reportInvalidArgument($message) + { + throw new InvalidArgumentException($message); + } + + private function __construct() + { + } +} diff --git a/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/tests/AssertTest.php b/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/tests/AssertTest.php new file mode 100644 index 0000000..e9ed505 --- /dev/null +++ b/Postman/Postman-Mail/mailgun/vendor/webmozart/assert/tests/AssertTest.php @@ -0,0 +1,451 @@ +<?php + +/* + * This file is part of the webmozart/assert package. + * + * (c) Bernhard Schussek <bschussek@gmail.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Webmozart\Assert\Tests; + +use ArrayIterator; +use Exception; +use Error; +use LogicException; +use PHPUnit_Framework_TestCase; +use RuntimeException; +use stdClass; +use Webmozart\Assert\Assert; + +/** + * @since 1.0 + * + * @author Bernhard Schussek <bschussek@gmail.com> + */ +class AssertTest extends PHPUnit_Framework_TestCase +{ + private static $resource; + + public static function getResource() + { + if (!static::$resource) { + static::$resource = fopen(__FILE__, 'r'); + } + + return static::$resource; + } + + public static function tearDownAfterClass() + { + @fclose(self::$resource); + } + + public function getTests() + { + $resource = self::getResource(); + + return array( + array('string', array('value'), true), + array('string', array(''), true), + array('string', array(1234), false), + array('stringNotEmpty', array('value'), true), + array('stringNotEmpty', array(''), false), + array('stringNotEmpty', array(1234), false), + array('integer', array(123), true), + array('integer', array('123'), false), + array('integer', array(1.0), false), + array('integer', array(1.23), false), + array('integerish', array(1.0), true), + array('integerish', array(1.23), false), + array('integerish', array(123), true), + array('integerish', array('123'), true), + array('float', array(1.0), true), + array('float', array(1.23), true), + array('float', array(123), false), + array('float', array('123'), false), + array('numeric', array(1.0), true), + array('numeric', array(1.23), true), + array('numeric', array(123), true), + array('numeric', array('123'), true), + array('numeric', array('foo'), false), + array('boolean', array(true), true), + array('boolean', array(false), true), + array('boolean', array(1), false), + array('boolean', array('1'), false), + array('scalar', array('1'), true), + array('scalar', array(123), true), + array('scalar', array(true), true), + array('scalar', array(null), false), + array('scalar', array(array()), false), + array('scalar', array(new stdClass()), false), + array('object', array(new stdClass()), true), + array('object', array(new RuntimeException()), true), + array('object', array(null), false), + array('object', array(true), false), + array('object', array(1), false), + array('object', array(array()), false), + array('resource', array($resource), true), + array('resource', array($resource, 'stream'), true), + array('resource', array($resource, 'other'), false), + array('resource', array(1), false), + array('isCallable', array('strlen'), true), + array('isCallable', array(array($this, 'getTests')), true), + array('isCallable', array(function () {}), true), + array('isCallable', array(1234), false), + array('isCallable', array('foobar'), false), + array('isArray', array(array()), true), + array('isArray', array(array(1, 2, 3)), true), + array('isArray', array(new ArrayIterator(array())), false), + array('isArray', array(123), false), + array('isArray', array(new stdClass()), false), + array('isTraversable', array(array()), true), + array('isTraversable', array(array(1, 2, 3)), true), + array('isTraversable', array(new ArrayIterator(array())), true), + array('isTraversable', array(123), false), + array('isTraversable', array(new stdClass()), false), + array('isInstanceOf', array(new stdClass(), 'stdClass'), true), + array('isInstanceOf', array(new Exception(), 'stdClass'), false), + array('isInstanceOf', array(123, 'stdClass'), false), + array('isInstanceOf', array(array(), 'stdClass'), false), + array('notInstanceOf', array(new stdClass(), 'stdClass'), false), + array('notInstanceOf', array(new Exception(), 'stdClass'), true), + array('notInstanceOf', array(123, 'stdClass'), true), + array('notInstanceOf', array(array(), 'stdClass'), true), + array('true', array(true), true), + array('true', array(false), false), + array('true', array(1), false), + array('true', array(null), false), + array('false', array(false), true), + array('false', array(true), false), + array('false', array(1), false), + array('false', array(0), false), + array('false', array(null), false), + array('null', array(null), true), + array('null', array(false), false), + array('null', array(0), false), + array('notNull', array(false), true), + array('notNull', array(0), true), + array('notNull', array(null), false), + array('isEmpty', array(null), true), + array('isEmpty', array(false), true), + array('isEmpty', array(0), true), + array('isEmpty', array(''), true), + array('isEmpty', array(1), false), + array('isEmpty', array('a'), false), + array('notEmpty', array(1), true), + array('notEmpty', array('a'), true), + array('notEmpty', array(null), false), + array('notEmpty', array(false), false), + array('notEmpty', array(0), false), + array('notEmpty', array(''), false), + array('eq', array(1, 1), true), + array('eq', array(1, '1'), true), + array('eq', array(1, true), true), + array('eq', array(1, 0), false), + array('notEq', array(1, 0), true), + array('notEq', array(1, 1), false), + array('notEq', array(1, '1'), false), + array('notEq', array(1, true), false), + array('same', array(1, 1), true), + array('same', array(1, '1'), false), + array('same', array(1, true), false), + array('same', array(1, 0), false), + array('notSame', array(1, 0), true), + array('notSame', array(1, 1), false), + array('notSame', array(1, '1'), true), + array('notSame', array(1, true), true), + array('greaterThan', array(1, 0), true), + array('greaterThan', array(0, 0), false), + array('greaterThanEq', array(2, 1), true), + array('greaterThanEq', array(1, 1), true), + array('greaterThanEq', array(0, 1), false), + array('lessThan', array(0, 1), true), + array('lessThan', array(1, 1), false), + array('lessThanEq', array(0, 1), true), + array('lessThanEq', array(1, 1), true), + array('lessThanEq', array(2, 1), false), + array('range', array(1, 1, 2), true), + array('range', array(2, 1, 2), true), + array('range', array(0, 1, 2), false), + array('range', array(3, 1, 2), false), + array('oneOf', array(1, array(1, 2, 3)), true), + array('oneOf', array(1, array('1', '2', '3')), false), + array('contains', array('abcd', 'ab'), true), + array('contains', array('abcd', 'bc'), true), + array('contains', array('abcd', 'cd'), true), + array('contains', array('abcd', 'de'), false), + array('contains', array('', 'de'), false), + array('startsWith', array('abcd', 'ab'), true), + array('startsWith', array('abcd', 'bc'), false), + array('startsWith', array('', 'bc'), false), + array('startsWithLetter', array('abcd'), true), + array('startsWithLetter', array('1abcd'), false), + array('startsWithLetter', array(''), false), + array('endsWith', array('abcd', 'cd'), true), + array('endsWith', array('abcd', 'bc'), false), + array('endsWith', array('', 'bc'), false), + array('regex', array('abcd', '~^ab~'), true), + array('regex', array('abcd', '~^bc~'), false), + array('regex', array('', '~^bc~'), false), + array('alpha', array('abcd'), true), + array('alpha', array('ab1cd'), false), + array('alpha', array(''), false), + array('digits', array('1234'), true), + array('digits', array('12a34'), false), + array('digits', array(''), false), + array('alnum', array('ab12'), true), + array('alnum', array('ab12$'), false), + array('alnum', array(''), false), + array('lower', array('abcd'), true), + array('lower', array('abCd'), false), + array('lower', array('ab_d'), false), + array('lower', array(''), false), + array('upper', array('ABCD'), true), + array('upper', array('ABcD'), false), + array('upper', array('AB_D'), false), + array('upper', array(''), false), + array('length', array('abcd', 4), true), + array('length', array('abc', 4), false), + array('length', array('abcde', 4), false), + array('length', array('äbcd', 4), true, true), + array('length', array('äbc', 4), false, true), + array('length', array('äbcde', 4), false, true), + array('minLength', array('abcd', 4), true), + array('minLength', array('abcde', 4), true), + array('minLength', array('abc', 4), false), + array('minLength', array('äbcd', 4), true, true), + array('minLength', array('äbcde', 4), true, true), + array('minLength', array('äbc', 4), false, true), + array('maxLength', array('abcd', 4), true), + array('maxLength', array('abc', 4), true), + array('maxLength', array('abcde', 4), false), + array('maxLength', array('äbcd', 4), true, true), + array('maxLength', array('äbc', 4), true, true), + array('maxLength', array('äbcde', 4), false, true), + array('lengthBetween', array('abcd', 3, 5), true), + array('lengthBetween', array('abc', 3, 5), true), + array('lengthBetween', array('abcde', 3, 5), true), + array('lengthBetween', array('ab', 3, 5), false), + array('lengthBetween', array('abcdef', 3, 5), false), + array('lengthBetween', array('äbcd', 3, 5), true, true), + array('lengthBetween', array('äbc', 3, 5), true, true), + array('lengthBetween', array('äbcde', 3, 5), true, true), + array('lengthBetween', array('äb', 3, 5), false, true), + array('lengthBetween', array('äbcdef', 3, 5), false, true), + array('fileExists', array(__FILE__), true), + array('fileExists', array(__DIR__), true), + array('fileExists', array(__DIR__.'/foobar'), false), + array('file', array(__FILE__), true), + array('file', array(__DIR__), false), + array('file', array(__DIR__.'/foobar'), false), + array('directory', array(__DIR__), true), + array('directory', array(__FILE__), false), + array('directory', array(__DIR__.'/foobar'), false), + // no tests for readable()/writable() for now + array('classExists', array(__CLASS__), true), + array('classExists', array(__NAMESPACE__.'\Foobar'), false), + array('subclassOf', array(__CLASS__, 'PHPUnit_Framework_TestCase'), true), + array('subclassOf', array(__CLASS__, 'stdClass'), false), + array('implementsInterface', array('ArrayIterator', 'Traversable'), true), + array('implementsInterface', array(__CLASS__, 'Traversable'), false), + array('propertyExists', array((object) array('property' => 0), 'property'), true), + array('propertyExists', array((object) array('property' => null), 'property'), true), + array('propertyExists', array((object) array('property' => null), 'foo'), false), + array('propertyNotExists', array((object) array('property' => 0), 'property'), false), + array('propertyNotExists', array((object) array('property' => null), 'property'), false), + array('propertyNotExists', array((object) array('property' => null), 'foo'), true), + array('methodExists', array('RuntimeException', 'getMessage'), true), + array('methodExists', array(new RuntimeException(), 'getMessage'), true), + array('methodExists', array('stdClass', 'getMessage'), false), + array('methodExists', array(new stdClass(), 'getMessage'), false), + array('methodExists', array(null, 'getMessage'), false), + array('methodExists', array(true, 'getMessage'), false), + array('methodExists', array(1, 'getMessage'), false), + array('methodNotExists', array('RuntimeException', 'getMessage'), false), + array('methodNotExists', array(new RuntimeException(), 'getMessage'), false), + array('methodNotExists', array('stdClass', 'getMessage'), true), + array('methodNotExists', array(new stdClass(), 'getMessage'), true), + array('methodNotExists', array(null, 'getMessage'), true), + array('methodNotExists', array(true, 'getMessage'), true), + array('methodNotExists', array(1, 'getMessage'), true), + array('keyExists', array(array('key' => 0), 'key'), true), + array('keyExists', array(array('key' => null), 'key'), true), + array('keyExists', array(array('key' => null), 'foo'), false), + array('keyNotExists', array(array('key' => 0), 'key'), false), + array('keyNotExists', array(array('key' => null), 'key'), false), + array('keyNotExists', array(array('key' => null), 'foo'), true), + array('count', array(array(0, 1, 2), 3), true), + array('count', array(array(0, 1, 2), 2), false), + array('uuid', array('00000000-0000-0000-0000-000000000000'), true), + array('uuid', array('ff6f8cb0-c57d-21e1-9b21-0800200c9a66'), true), + array('uuid', array('ff6f8cb0-c57d-11e1-9b21-0800200c9a66'), true), + array('uuid', array('ff6f8cb0-c57d-31e1-9b21-0800200c9a66'), true), + array('uuid', array('ff6f8cb0-c57d-41e1-9b21-0800200c9a66'), true), + array('uuid', array('ff6f8cb0-c57d-51e1-9b21-0800200c9a66'), true), + array('uuid', array('FF6F8CB0-C57D-11E1-9B21-0800200C9A66'), true), + array('uuid', array('zf6f8cb0-c57d-11e1-9b21-0800200c9a66'), false), + array('uuid', array('af6f8cb0c57d11e19b210800200c9a66'), false), + array('uuid', array('ff6f8cb0-c57da-51e1-9b21-0800200c9a66'), false), + array('uuid', array('af6f8cb-c57d-11e1-9b21-0800200c9a66'), false), + array('uuid', array('3f6f8cb0-c57d-11e1-9b21-0800200c9a6'), false), + array('throws', array(function() { throw new LogicException('test'); }, 'LogicException'), true), + array('throws', array(function() { throw new LogicException('test'); }, 'IllogicException'), false), + array('throws', array(function() { throw new Exception('test'); }), true), + array('throws', array(function() { trigger_error('test'); }, 'Throwable'), true, false, 70000), + array('throws', array(function() { trigger_error('test'); }, 'Unthrowable'), false, false, 70000), + array('throws', array(function() { throw new Error(); }, 'Throwable'), true, true, 70000), + ); + } + + public function getMethods() + { + $methods = array(); + + foreach ($this->getTests() as $params) { + $methods[$params[0]] = array($params[0]); + } + + return array_values($methods); + } + + /** + * @dataProvider getTests + */ + public function testAssert($method, $args, $success, $multibyte = false, $minVersion = null) + { + if ($minVersion && PHP_VERSION_ID < $minVersion) { + $this->markTestSkipped(sprintf('This test requires php %s or upper.', $minVersion)); + + return; + } + if ($multibyte && !function_exists('mb_strlen')) { + $this->markTestSkipped('The function mb_strlen() is not available'); + + return; + } + + if (!$success) { + $this->setExpectedException('\InvalidArgumentException'); + } + + call_user_func_array(array('Webmozart\Assert\Assert', $method), $args); + } + + /** + * @dataProvider getTests + */ + public function testNullOr($method, $args, $success, $multibyte = false, $minVersion = null) + { + if ($minVersion && PHP_VERSION_ID < $minVersion) { + $this->markTestSkipped(sprintf('This test requires php %s or upper.', $minVersion)); + + return; + } + if ($multibyte && !function_exists('mb_strlen')) { + $this->markTestSkipped('The function mb_strlen() is not available'); + + return; + } + + if (!$success && null !== reset($args)) { + $this->setExpectedException('\InvalidArgumentException'); + } + + call_user_func_array(array('Webmozart\Assert\Assert', 'nullOr'.ucfirst($method)), $args); + } + + /** + * @dataProvider getMethods + */ + public function testNullOrAcceptsNull($method) + { + call_user_func(array('Webmozart\Assert\Assert', 'nullOr'.ucfirst($method)), null); + } + + /** + * @dataProvider getTests + */ + public function testAllArray($method, $args, $success, $multibyte = false, $minVersion = null) + { + if ($minVersion && PHP_VERSION_ID < $minVersion) { + $this->markTestSkipped(sprintf('This test requires php %s or upper.', $minVersion)); + + return; + } + if ($multibyte && !function_exists('mb_strlen')) { + $this->markTestSkipped('The function mb_strlen() is not available'); + + return; + } + + if (!$success) { + $this->setExpectedException('\InvalidArgumentException'); + } + + $arg = array_shift($args); + array_unshift($args, array($arg)); + + call_user_func_array(array('Webmozart\Assert\Assert', 'all'.ucfirst($method)), $args); + } + + /** + * @dataProvider getTests + */ + public function testAllTraversable($method, $args, $success, $multibyte = false, $minVersion = null) + { + if ($minVersion && PHP_VERSION_ID < $minVersion) { + $this->markTestSkipped(sprintf('This test requires php %s or upper.', $minVersion)); + + return; + } + if ($multibyte && !function_exists('mb_strlen')) { + $this->markTestSkipped('The function mb_strlen() is not available'); + + return; + } + + if (!$success) { + $this->setExpectedException('\InvalidArgumentException'); + } + + $arg = array_shift($args); + array_unshift($args, new ArrayIterator(array($arg))); + + call_user_func_array(array('Webmozart\Assert\Assert', 'all'.ucfirst($method)), $args); + } + + public function getStringConversions() + { + return array( + array('integer', array('foobar'), 'Expected an integer. Got: string'), + array('string', array(1), 'Expected a string. Got: integer'), + array('string', array(true), 'Expected a string. Got: boolean'), + array('string', array(null), 'Expected a string. Got: NULL'), + array('string', array(array()), 'Expected a string. Got: array'), + array('string', array(new stdClass()), 'Expected a string. Got: stdClass'), + array('string', array(self::getResource()), 'Expected a string. Got: resource'), + + array('eq', array('1', '2'), 'Expected a value equal to "2". Got: "1"'), + array('eq', array(1, 2), 'Expected a value equal to 2. Got: 1'), + array('eq', array(true, false), 'Expected a value equal to false. Got: true'), + array('eq', array(true, null), 'Expected a value equal to null. Got: true'), + array('eq', array(null, true), 'Expected a value equal to true. Got: null'), + array('eq', array(array(1), array(2)), 'Expected a value equal to array. Got: array'), + array('eq', array(new ArrayIterator(array()), new stdClass()), 'Expected a value equal to stdClass. Got: ArrayIterator'), + array('eq', array(1, self::getResource()), 'Expected a value equal to resource. Got: 1'), + ); + } + + /** + * @dataProvider getStringConversions + */ + public function testConvertValuesToStrings($method, $args, $exceptionMessage) + { + $this->setExpectedException('\InvalidArgumentException', $exceptionMessage); + + call_user_func_array(array('Webmozart\Assert\Assert', $method), $args); + } +} |