diff --git a/ phpunit.xml.dist b/ phpunit.xml.dist new file mode 100644 index 0000000..16de795 --- /dev/null +++ b/ phpunit.xml.dist @@ -0,0 +1,23 @@ + + + + + + + + + + tests/ + + + + + + ./src/ + + + \ No newline at end of file diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 9d49909..0000000 --- a/.editorconfig +++ /dev/null @@ -1,15 +0,0 @@ -; This file is for unifying the coding style for different editors and IDEs. -; More information at http://editorconfig.org - -root = true - -[*] -charset = utf-8 -indent_size = 4 -indent_style = space -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true - -[*.md] -trim_trailing_whitespace = false \ No newline at end of file diff --git a/.gitignore b/.gitignore index 462abd2..4e52068 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ /vendor -.phpintel/ coverage.clover -build/ -index.php \ No newline at end of file +.env +.php_cs.cache +build \ No newline at end of file diff --git a/.php_cs.dist b/.php_cs.dist new file mode 100644 index 0000000..7fc2a42 --- /dev/null +++ b/.php_cs.dist @@ -0,0 +1,39 @@ + +COMMENT; +$finder = PhpCsFixer\Finder::create() + ->in(__DIR__) + ->exclude('var') +; +return PhpCsFixer\Config::create() + ->setIndent(" ") + ->setLineEnding("\n") + ->setRiskyAllowed(true) + ->setRules([ + '@PSR2' => true, + '@Symfony' => true, + '@Symfony:risky' => true, + 'array_syntax' => ['syntax' => 'short'], + 'header_comment' => ['header' => $fileHeaderComment, 'separate' => 'both'], + 'linebreak_after_opening_tag' => true, + 'mb_str_functions' => true, + 'no_php4_constructor' => true, + 'no_unreachable_default_argument_value' => true, + 'no_useless_else' => true, + 'no_useless_return' => true, + 'ordered_imports' => true, + 'php_unit_strict' => true, + 'phpdoc_order' => true, + 'semicolon_after_instruction' => true, + 'strict_comparison' => true, + 'strict_param' => true, + 'phpdoc_add_missing_param_annotation' => true, + 'ordered_class_elements'=> true, + 'phpdoc_types_order' => true, + 'logical_operators' => true, + ]) + ->setFinder($finder) + ->setCacheFile(__DIR__.'/.php_cs.cache') +; \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 6777756..54781ca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,4 @@ language: php -dist: precise php: - 5.6 @@ -16,4 +15,4 @@ before_script: - travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-dist script: - - vendor/bin/phpunit --bootstrap vendor/autoload.php --coverage-text --coverage-clover=coverage.clover \ No newline at end of file + - make ci \ No newline at end of file diff --git a/LICENSE b/LICENSE index 59b5b31..661dac6 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017 A. F +Copyright (c) 2017 Cliven Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7977003 --- /dev/null +++ b/Makefile @@ -0,0 +1,57 @@ +COMPOSER ?= composer +PHPUNIT_OPTS = + + +composer: + $(COMPOSER) install + + +fix: + ./vendor/bin/php-cs-fixer fix + + +fix-diff: + ./vendor/bin/php-cs-fixer fix --diff --dry-run -v + + +test: composer + vendor/bin/phpunit -c . + + +lint: lint-php phpcs php-cs lint-composer lint-eol + @echo All good. + + +lint-eol: + @echo "\n==> Validating unix style line endings of files:files" + @! grep -lIUr --color '^M' src/ composer.json composer.lock || ( echo '[ERROR] Above files have CRLF line endings' && exit 1 ) + @echo All files have valid line endings + + +lint-composer: + @echo "\n==> Validating composer.json and composer.lock:" + $(COMPOSER) validate --strict + + +lint-php: + @echo "\n==> Validating all php files:" + @find src tests -type f -name \*.php | while read file; do php -l "$$file" || exit 1; done + + +phpcs: + vendor/bin/phpcs + + +php-cs: + vendor/bin/php-cs-fixer fix --diff --dry-run -v + + +coverage: composer + vendor/bin/phpunit -c . + + +ci: composer lint test + @echo "All quality checks passed" + + +.PHONY: test composer coverage phpcs php-cs lint lint-php ci \ No newline at end of file diff --git a/README.md b/README.md index edb2ed5..01df84b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Imap ==== :mailbox_with_mail: Access Mailbox Using PHP IMAP. -*Current Version: 1.0.4* +*Current Version: 1.0.5* [![Build Status](https://travis-ci.org/Clivern/Imap.svg?branch=master)](https://travis-ci.org/Clivern/Imap) @@ -265,6 +265,12 @@ Misc Changelog --------- +Version 1.0.5: +``` +Enhance code style. +Automate code fixes and linting. +``` + Version 1.0.4: ``` Fix for plain text messages. diff --git a/composer.json b/composer.json index da4038f..660a422 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,6 @@ "description": "Access Mailbox Using PHP IMAP", "keywords": ["clivern", "imap"], "license": "MIT", - "type": "project", "homepage": "https://github.com/clivern/imap", "authors": [ { @@ -17,7 +16,9 @@ "php": ">=5.6.4" }, "require-dev": { - "phpunit/phpunit": "~5.7" + "phpunit/phpunit": "~5.7", + "friendsofphp/php-cs-fixer": "^2.14", + "squizlabs/php_codesniffer": "^3.4" }, "autoload": { "psr-4": { @@ -32,4 +33,4 @@ "scripts": { "test": "phpunit" } -} \ No newline at end of file +} diff --git a/composer.lock b/composer.lock index 33e1cbb..770408b 100644 --- a/composer.lock +++ b/composer.lock @@ -1,40 +1,214 @@ { "_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", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "09858dbd5ada4a10aae0f98d06c6340b", + "content-hash": "72e32d9720f8b30de799786db5951d66", "packages": [], "packages-dev": [ { - "name": "doctrine/instantiator", - "version": "1.0.5", + "name": "composer/semver", + "version": "1.4.2", "source": { "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" + "url": "https://github.com/composer/semver.git", + "reference": "c7cb9a2095a074d131b65a8a0cd294479d785573" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", + "url": "https://api.github.com/repos/composer/semver/zipball/c7cb9a2095a074d131b65a8a0cd294479d785573", + "reference": "c7cb9a2095a074d131b65a8a0cd294479d785573", "shasum": "" }, "require": { - "php": ">=5.3,<8.0-DEV" + "php": "^5.3.2 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.5 || ^5.0.5", + "phpunit/phpunit-mock-objects": "2.3.0 || ^3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Semver\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "http://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + }, + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com", + "homepage": "http://robbast.nl" + } + ], + "description": "Semver library that offers utilities, version constraint parsing and validation.", + "keywords": [ + "semantic", + "semver", + "validation", + "versioning" + ], + "time": "2016-08-30T16:08:34+00:00" + }, + { + "name": "composer/xdebug-handler", + "version": "1.3.2", + "source": { + "type": "git", + "url": "https://github.com/composer/xdebug-handler.git", + "reference": "d17708133b6c276d6e42ef887a877866b909d892" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/d17708133b6c276d6e42ef887a877866b909d892", + "reference": "d17708133b6c276d6e42ef887a877866b909d892", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0", + "psr/log": "^1.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Composer\\XdebugHandler\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" + } + ], + "description": "Restarts a process without xdebug.", + "keywords": [ + "Xdebug", + "performance" + ], + "time": "2019-01-28T20:25:53+00:00" + }, + { + "name": "doctrine/annotations", + "version": "v1.6.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/annotations.git", + "reference": "c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5", + "reference": "c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5", + "shasum": "" + }, + "require": { + "doctrine/lexer": "1.*", + "php": "^7.1" + }, + "require-dev": { + "doctrine/cache": "1.*", + "phpunit/phpunit": "^6.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.6.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Docblock Annotations Parser", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "docblock", + "parser" + ], + "time": "2017-12-06T07:11:42+00:00" + }, + { + "name": "doctrine/instantiator", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", + "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", + "shasum": "" + }, + "require": { + "php": "^7.1" }, "require-dev": { "athletic/athletic": "~0.1.8", "ext-pdo": "*", "ext-phar": "*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~2.0" + "phpunit/phpunit": "^6.2.3", + "squizlabs/php_codesniffer": "^3.0.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.2.x-dev" } }, "autoload": { @@ -59,41 +233,189 @@ "constructor", "instantiate" ], - "time": "2015-06-14T21:17:01+00:00" + "time": "2017-07-22T11:58:36+00:00" }, { - "name": "myclabs/deep-copy", - "version": "1.6.1", + "name": "doctrine/lexer", + "version": "v1.0.1", "source": { "type": "git", - "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "8e6e04167378abf1ddb4d3522d8755c5fd90d102" + "url": "https://github.com/doctrine/lexer.git", + "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/8e6e04167378abf1ddb4d3522d8755c5fd90d102", - "reference": "8e6e04167378abf1ddb4d3522d8755c5fd90d102", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/83893c552fd2045dd78aef794c31e694c37c0b8c", + "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c", "shasum": "" }, "require": { - "php": ">=5.4.0" - }, - "require-dev": { - "doctrine/collections": "1.*", - "phpunit/phpunit": "~4.1" + "php": ">=5.3.2" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, "autoload": { - "psr-4": { - "DeepCopy\\": "src/DeepCopy/" + "psr-0": { + "Doctrine\\Common\\Lexer\\": "lib/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "lexer", + "parser" + ], + "time": "2014-09-09T13:34:57+00:00" + }, + { + "name": "friendsofphp/php-cs-fixer", + "version": "v2.14.2", + "source": { + "type": "git", + "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", + "reference": "ff401e58261ffc5934a58f795b3f95b355e276cb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/ff401e58261ffc5934a58f795b3f95b355e276cb", + "reference": "ff401e58261ffc5934a58f795b3f95b355e276cb", + "shasum": "" + }, + "require": { + "composer/semver": "^1.4", + "composer/xdebug-handler": "^1.2", + "doctrine/annotations": "^1.2", + "ext-json": "*", + "ext-tokenizer": "*", + "php": "^5.6 || ^7.0", + "php-cs-fixer/diff": "^1.3", + "symfony/console": "^3.4.17 || ^4.1.6", + "symfony/event-dispatcher": "^3.0 || ^4.0", + "symfony/filesystem": "^3.0 || ^4.0", + "symfony/finder": "^3.0 || ^4.0", + "symfony/options-resolver": "^3.0 || ^4.0", + "symfony/polyfill-php70": "^1.0", + "symfony/polyfill-php72": "^1.4", + "symfony/process": "^3.0 || ^4.0", + "symfony/stopwatch": "^3.0 || ^4.0" + }, + "require-dev": { + "johnkary/phpunit-speedtrap": "^1.1 || ^2.0 || ^3.0", + "justinrainbow/json-schema": "^5.0", + "keradus/cli-executor": "^1.2", + "mikey179/vfsstream": "^1.6", + "php-coveralls/php-coveralls": "^2.1", + "php-cs-fixer/accessible-object": "^1.0", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.0.1", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.0.1", + "phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1", + "phpunitgoodpractices/traits": "^1.5.1", + "symfony/phpunit-bridge": "^4.0" + }, + "suggest": { + "ext-mbstring": "For handling non-UTF8 characters in cache signature.", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "For IsIdenticalString constraint.", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "For XmlMatchesXsd constraint.", + "symfony/polyfill-mbstring": "When enabling `ext-mbstring` is not possible." + }, + "bin": [ + "php-cs-fixer" + ], + "type": "application", + "autoload": { + "psr-4": { + "PhpCsFixer\\": "src/" + }, + "classmap": [ + "tests/Test/AbstractFixerTestCase.php", + "tests/Test/AbstractIntegrationCaseFactory.php", + "tests/Test/AbstractIntegrationTestCase.php", + "tests/Test/Assert/AssertTokensTrait.php", + "tests/Test/IntegrationCase.php", + "tests/Test/IntegrationCaseFactory.php", + "tests/Test/IntegrationCaseFactoryInterface.php", + "tests/Test/InternalIntegrationCaseFactory.php", + "tests/TestCase.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Dariusz RumiƄski", + "email": "dariusz.ruminski@gmail.com" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "A tool to automatically fix PHP code style", + "time": "2019-02-17T17:44:13+00:00" + }, + { + "name": "myclabs/deep-copy", + "version": "1.8.1", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", + "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "replace": { + "myclabs/deep-copy": "self.version" + }, + "require-dev": { + "doctrine/collections": "^1.0", + "doctrine/common": "^2.6", + "phpunit/phpunit": "^7.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + }, + "files": [ + "src/DeepCopy/deep_copy.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], "description": "Create deep copies (clones) of your objects", - "homepage": "https://github.com/myclabs/DeepCopy", "keywords": [ "clone", "copy", @@ -101,20 +423,116 @@ "object", "object graph" ], - "time": "2017-04-12T18:52:22+00:00" + "time": "2018-06-11T23:09:50+00:00" }, { - "name": "phpdocumentor/reflection-common", - "version": "1.0", + "name": "paragonie/random_compat", + "version": "v9.99.99", "source": { "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c" + "url": "https://github.com/paragonie/random_compat.git", + "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/144c307535e82c8fdcaacbcfc1d6d8eeb896687c", - "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", + "reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95", + "shasum": "" + }, + "require": { + "php": "^7" + }, + "require-dev": { + "phpunit/phpunit": "4.*|5.*", + "vimeo/psalm": "^1" + }, + "suggest": { + "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com" + } + ], + "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", + "keywords": [ + "csprng", + "polyfill", + "pseudorandom", + "random" + ], + "time": "2018-07-02T15:55:56+00:00" + }, + { + "name": "php-cs-fixer/diff", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/PHP-CS-Fixer/diff.git", + "reference": "78bb099e9c16361126c86ce82ec4405ebab8e756" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHP-CS-Fixer/diff/zipball/78bb099e9c16361126c86ce82ec4405ebab8e756", + "reference": "78bb099e9c16361126c86ce82ec4405ebab8e756", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7.23 || ^6.4.3", + "symfony/process": "^3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "SpacePossum" + } + ], + "description": "sebastian/diff v2 backport support for PHP5.6", + "homepage": "https://github.com/PHP-CS-Fixer", + "keywords": [ + "diff" + ], + "time": "2018-02-15T16:58:55+00:00" + }, + { + "name": "phpdocumentor/reflection-common", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", "shasum": "" }, "require": { @@ -155,33 +573,39 @@ "reflection", "static analysis" ], - "time": "2015-12-27T11:43:31+00:00" + "time": "2017-09-11T18:02:19+00:00" }, { "name": "phpdocumentor/reflection-docblock", - "version": "3.2.2", + "version": "4.3.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "4aada1f93c72c35e22fb1383b47fee43b8f1d157" + "reference": "94fd0001232e47129dd3504189fa1c7225010d08" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/4aada1f93c72c35e22fb1383b47fee43b8f1d157", - "reference": "4aada1f93c72c35e22fb1383b47fee43b8f1d157", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08", + "reference": "94fd0001232e47129dd3504189fa1c7225010d08", "shasum": "" }, "require": { - "php": ">=5.5", - "phpdocumentor/reflection-common": "^1.0@dev", - "phpdocumentor/type-resolver": "^0.3.0", + "php": "^7.0", + "phpdocumentor/reflection-common": "^1.0.0", + "phpdocumentor/type-resolver": "^0.4.0", "webmozart/assert": "^1.0" }, "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^4.4" + "doctrine/instantiator": "~1.0.5", + "mockery/mockery": "^1.0", + "phpunit/phpunit": "^6.4" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.x-dev" + } + }, "autoload": { "psr-4": { "phpDocumentor\\Reflection\\": [ @@ -200,20 +624,20 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2017-08-08T06:39:58+00:00" + "time": "2017-11-30T07:14:17+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "0.3.0", + "version": "0.4.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "fb3933512008d8162b3cdf9e18dba9309b7c3773" + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/fb3933512008d8162b3cdf9e18dba9309b7c3773", - "reference": "fb3933512008d8162b3cdf9e18dba9309b7c3773", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", "shasum": "" }, "require": { @@ -247,37 +671,37 @@ "email": "me@mikevanriel.com" } ], - "time": "2017-06-03T08:32:36+00:00" + "time": "2017-07-14T14:27:02+00:00" }, { "name": "phpspec/prophecy", - "version": "v1.7.0", + "version": "1.8.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "93d39f1f7f9326d746203c7c056f300f7f126073" + "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/93d39f1f7f9326d746203c7c056f300f7f126073", - "reference": "93d39f1f7f9326d746203c7c056f300f7f126073", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4ba436b55987b4bf311cb7c6ba82aa528aac0a06", + "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2", - "sebastian/comparator": "^1.1|^2.0", + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", + "sebastian/comparator": "^1.1|^2.0|^3.0", "sebastian/recursion-context": "^1.0|^2.0|^3.0" }, "require-dev": { "phpspec/phpspec": "^2.5|^3.2", - "phpunit/phpunit": "^4.8 || ^5.6.5" + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6.x-dev" + "dev-master": "1.8.x-dev" } }, "autoload": { @@ -310,7 +734,7 @@ "spy", "stub" ], - "time": "2017-03-02T20:05:34+00:00" + "time": "2018-08-05T17:53:17+00:00" }, { "name": "phpunit/php-code-coverage", @@ -377,16 +801,16 @@ }, { "name": "phpunit/php-file-iterator", - "version": "1.4.2", + "version": "1.4.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5" + "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/3cc8f69b3028d0f96a9078e6295d86e9bf019be5", - "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", + "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", "shasum": "" }, "require": { @@ -420,7 +844,7 @@ "filesystem", "iterator" ], - "time": "2016-10-03T07:40:28+00:00" + "time": "2017-11-27T13:52:08+00:00" }, { "name": "phpunit/php-text-template", @@ -514,29 +938,29 @@ }, { "name": "phpunit/php-token-stream", - "version": "1.4.11", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7" + "reference": "791198a2c6254db10131eecfe8c06670700904db" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/e03f8f67534427a787e21a385a67ec3ca6978ea7", - "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/791198a2c6254db10131eecfe8c06670700904db", + "reference": "791198a2c6254db10131eecfe8c06670700904db", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": ">=5.3.3" + "php": "^7.0" }, "require-dev": { - "phpunit/phpunit": "~4.2" + "phpunit/phpunit": "^6.2.4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -559,20 +983,20 @@ "keywords": [ "tokenizer" ], - "time": "2017-02-27T10:12:30+00:00" + "time": "2017-11-27T05:48:46+00:00" }, { "name": "phpunit/phpunit", - "version": "5.7.21", + "version": "5.7.27", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "3b91adfb64264ddec5a2dee9851f354aa66327db" + "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3b91adfb64264ddec5a2dee9851f354aa66327db", - "reference": "3b91adfb64264ddec5a2dee9851f354aa66327db", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c", + "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c", "shasum": "" }, "require": { @@ -596,8 +1020,8 @@ "sebastian/global-state": "^1.1", "sebastian/object-enumerator": "~2.0", "sebastian/resource-operations": "~1.0", - "sebastian/version": "~1.0.3|~2.0", - "symfony/yaml": "~2.1|~3.0" + "sebastian/version": "^1.0.6|^2.0.1", + "symfony/yaml": "~2.1|~3.0|~4.0" }, "conflict": { "phpdocumentor/reflection-docblock": "3.0.2" @@ -641,7 +1065,7 @@ "testing", "xunit" ], - "time": "2017-06-21T08:11:54+00:00" + "time": "2018-02-01T05:50:59+00:00" }, { "name": "phpunit/phpunit-mock-objects", @@ -700,8 +1124,56 @@ "mock", "xunit" ], + "abandoned": true, "time": "2017-06-30T09:13:00+00:00" }, + { + "name": "psr/log", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", + "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2018-11-20T15:27:04+00:00" + }, { "name": "sebastian/code-unit-reverse-lookup", "version": "1.0.1", @@ -1216,24 +1688,766 @@ "time": "2016-10-03T07:35:21+00:00" }, { - "name": "symfony/yaml", - "version": "v3.3.6", + "name": "squizlabs/php_codesniffer", + "version": "3.4.0", "source": { "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "ddc23324e6cfe066f3dd34a37ff494fa80b617ed" + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "379deb987e26c7cd103a7b387aea178baec96e48" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/ddc23324e6cfe066f3dd34a37ff494fa80b617ed", - "reference": "ddc23324e6cfe066f3dd34a37ff494fa80b617ed", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/379deb987e26c7cd103a7b387aea178baec96e48", + "reference": "379deb987e26c7cd103a7b387aea178baec96e48", "shasum": "" }, "require": { - "php": ">=5.5.9" + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" }, "require-dev": { - "symfony/console": "~2.8|~3.0" + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "http://www.squizlabs.com/php-codesniffer", + "keywords": [ + "phpcs", + "standards" + ], + "time": "2018-12-19T23:57:18+00:00" + }, + { + "name": "symfony/console", + "version": "v4.2.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "1f0ad51dfde4da8a6070f06adc58b4e37cbb37a4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/1f0ad51dfde4da8a6070f06adc58b4e37cbb37a4", + "reference": "1f0ad51dfde4da8a6070f06adc58b4e37cbb37a4", + "shasum": "" + }, + "require": { + "php": "^7.1.3", + "symfony/contracts": "^1.0", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/dependency-injection": "<3.4", + "symfony/process": "<3.3" + }, + "provide": { + "psr/log-implementation": "1.0" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~3.4|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", + "symfony/event-dispatcher": "~3.4|~4.0", + "symfony/lock": "~3.4|~4.0", + "symfony/process": "~3.4|~4.0" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/lock": "", + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.2-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Console Component", + "homepage": "https://symfony.com", + "time": "2019-01-25T14:35:16+00:00" + }, + { + "name": "symfony/contracts", + "version": "v1.0.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/contracts.git", + "reference": "1aa7ab2429c3d594dd70689604b5cf7421254cdf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/contracts/zipball/1aa7ab2429c3d594dd70689604b5cf7421254cdf", + "reference": "1aa7ab2429c3d594dd70689604b5cf7421254cdf", + "shasum": "" + }, + "require": { + "php": "^7.1.3" + }, + "require-dev": { + "psr/cache": "^1.0", + "psr/container": "^1.0" + }, + "suggest": { + "psr/cache": "When using the Cache contracts", + "psr/container": "When using the Service contracts", + "symfony/cache-contracts-implementation": "", + "symfony/service-contracts-implementation": "", + "symfony/translation-contracts-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\": "" + }, + "exclude-from-classmap": [ + "**/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A set of abstractions extracted out of the Symfony components", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "time": "2018-12-05T08:06:11+00:00" + }, + { + "name": "symfony/event-dispatcher", + "version": "v4.2.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "bd09ad265cd50b2b9d09d65ce6aba2d29bc81fe1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/bd09ad265cd50b2b9d09d65ce6aba2d29bc81fe1", + "reference": "bd09ad265cd50b2b9d09d65ce6aba2d29bc81fe1", + "shasum": "" + }, + "require": { + "php": "^7.1.3", + "symfony/contracts": "^1.0" + }, + "conflict": { + "symfony/dependency-injection": "<3.4" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~3.4|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", + "symfony/expression-language": "~3.4|~4.0", + "symfony/stopwatch": "~3.4|~4.0" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.2-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\EventDispatcher\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony EventDispatcher Component", + "homepage": "https://symfony.com", + "time": "2019-01-16T20:35:37+00:00" + }, + { + "name": "symfony/filesystem", + "version": "v4.2.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "7c16ebc2629827d4ec915a52ac809768d060a4ee" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/7c16ebc2629827d4ec915a52ac809768d060a4ee", + "reference": "7c16ebc2629827d4ec915a52ac809768d060a4ee", + "shasum": "" + }, + "require": { + "php": "^7.1.3", + "symfony/polyfill-ctype": "~1.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.2-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Filesystem Component", + "homepage": "https://symfony.com", + "time": "2019-01-16T20:35:37+00:00" + }, + { + "name": "symfony/finder", + "version": "v4.2.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "ef71816cbb264988bb57fe6a73f610888b9aa70c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/ef71816cbb264988bb57fe6a73f610888b9aa70c", + "reference": "ef71816cbb264988bb57fe6a73f610888b9aa70c", + "shasum": "" + }, + "require": { + "php": "^7.1.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.2-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Finder Component", + "homepage": "https://symfony.com", + "time": "2019-01-16T20:35:37+00:00" + }, + { + "name": "symfony/options-resolver", + "version": "v4.2.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/options-resolver.git", + "reference": "831b272963a8aa5a0613a1a7f013322d8161bbbb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/831b272963a8aa5a0613a1a7f013322d8161bbbb", + "reference": "831b272963a8aa5a0613a1a7f013322d8161bbbb", + "shasum": "" + }, + "require": { + "php": "^7.1.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.2-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": "2019-01-16T21:31:25+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.10.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "e3d826245268269cd66f8326bd8bc066687b4a19" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e3d826245268269cd66f8326bd8bc066687b4a19", + "reference": "e3d826245268269cd66f8326bd8bc066687b4a19", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + }, + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "time": "2018-08-06T14:22:27+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.10.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "c79c051f5b3a46be09205c73b80b346e4153e494" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/c79c051f5b3a46be09205c73b80b346e4153e494", + "reference": "c79c051f5b3a46be09205c73b80b346e4153e494", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "time": "2018-09-21T13:07:52+00:00" + }, + { + "name": "symfony/polyfill-php70", + "version": "v1.10.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php70.git", + "reference": "6b88000cdd431cd2e940caa2cb569201f3f84224" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/6b88000cdd431cd2e940caa2cb569201f3f84224", + "reference": "6b88000cdd431cd2e940caa2cb569201f3f84224", + "shasum": "" + }, + "require": { + "paragonie/random_compat": "~1.0|~2.0|~9.99", + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php70\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "time": "2018-09-21T06:26:08+00:00" + }, + { + "name": "symfony/polyfill-php72", + "version": "v1.10.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php72.git", + "reference": "9050816e2ca34a8e916c3a0ae8b9c2fccf68b631" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/9050816e2ca34a8e916c3a0ae8b9c2fccf68b631", + "reference": "9050816e2ca34a8e916c3a0ae8b9c2fccf68b631", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php72\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "time": "2018-09-21T13:07:52+00:00" + }, + { + "name": "symfony/process", + "version": "v4.2.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/process.git", + "reference": "6c05edb11fbeff9e2b324b4270ecb17911a8b7ad" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/process/zipball/6c05edb11fbeff9e2b324b4270ecb17911a8b7ad", + "reference": "6c05edb11fbeff9e2b324b4270ecb17911a8b7ad", + "shasum": "" + }, + "require": { + "php": "^7.1.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.2-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Process\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Process Component", + "homepage": "https://symfony.com", + "time": "2019-01-24T22:05:03+00:00" + }, + { + "name": "symfony/stopwatch", + "version": "v4.2.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/stopwatch.git", + "reference": "b1a5f646d56a3290230dbc8edf2a0d62cda23f67" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/b1a5f646d56a3290230dbc8edf2a0d62cda23f67", + "reference": "b1a5f646d56a3290230dbc8edf2a0d62cda23f67", + "shasum": "" + }, + "require": { + "php": "^7.1.3", + "symfony/contracts": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.2-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Stopwatch\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Stopwatch Component", + "homepage": "https://symfony.com", + "time": "2019-01-16T20:31:39+00:00" + }, + { + "name": "symfony/yaml", + "version": "v4.2.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/yaml.git", + "reference": "d461670ee145092b7e2a56c1da7118f19cadadb0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/yaml/zipball/d461670ee145092b7e2a56c1da7118f19cadadb0", + "reference": "d461670ee145092b7e2a56c1da7118f19cadadb0", + "shasum": "" + }, + "require": { + "php": "^7.1.3", + "symfony/polyfill-ctype": "~1.8" + }, + "conflict": { + "symfony/console": "<3.4" + }, + "require-dev": { + "symfony/console": "~3.4|~4.0" }, "suggest": { "symfony/console": "For validating YAML files using the lint command" @@ -1241,7 +2455,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "4.2-dev" } }, "autoload": { @@ -1268,24 +2482,25 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2017-07-23T12:43:26+00:00" + "time": "2019-01-16T20:35:37+00:00" }, { "name": "webmozart/assert", - "version": "1.2.0", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f" + "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/2db61e59ff05fe5126d152bd0655c9ea113e550f", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f", + "url": "https://api.github.com/repos/webmozart/assert/zipball/83e253c8e0be5b0257b881e1827274667c5c17a9", + "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": "^5.3.3 || ^7.0", + "symfony/polyfill-ctype": "^1.8" }, "require-dev": { "phpunit/phpunit": "^4.6", @@ -1318,7 +2533,7 @@ "check", "validate" ], - "time": "2016-11-23T20:04:58+00:00" + "time": "2018-12-25T11:19:39+00:00" } ], "aliases": [], diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..6d5f469 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,7 @@ + + + Imap coding standard. + src + tests + + \ No newline at end of file diff --git a/src/Core/Connection.php b/src/Core/Connection.php index eac979a..a415224 100644 --- a/src/Core/Connection.php +++ b/src/Core/Connection.php @@ -1,6 +1,8 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core; @@ -8,20 +10,17 @@ namespace Clivern\Imap\Core; use Clivern\Imap\Core\Exception\AuthenticationFailedException; /** - * Connection Class - * - * @package Clivern\Imap\Core + * Connection Class. */ class Connection { - /** * @var string */ protected $server; /** - * @var integer + * @var int */ protected $port; @@ -61,7 +60,7 @@ class Connection protected $timeout; /** - * Class Constructor + * Class Constructor. * * @param string $server * @param string $port @@ -69,9 +68,8 @@ class Connection * @param string $password * @param string $flag * @param string $folder - * @return void */ - public function __construct($server, $port, $email, $password, $flag = "/ssl", $folder = "INBOX") + public function __construct($server, $port, $email, $password, $flag = '/ssl', $folder = 'INBOX') { $this->server = $server; $this->port = $port; @@ -82,55 +80,59 @@ class Connection } /** - * Connect to IMAP Email + * Connect to IMAP Email. + * + * @throws AuthenticationFailedException * * @return Connection - * @throws AuthenticationFailedException */ public function connect() { try { - $this->stream = imap_open("{" . $this->server . ":" . $this->port . $this->flag . "}" . $this->folder, $this->email, $this->password); + $this->stream = imap_open( + '{'.$this->server.':'.$this->port.$this->flag.'}'.$this->folder, + $this->email, + $this->password + ); } catch (\Exception $e) { - throw new AuthenticationFailedException("Error! Connecting to Imap Email."); + throw new AuthenticationFailedException('Error! Connecting to Imap Email.'); } return $this; } - public function reconnect($folder = "INBOX") + public function reconnect($folder = 'INBOX') { try { - imap_reopen($this->stream, "{" . $this->server . ":" . $this->port . $this->flag . "}" . $folder); + imap_reopen($this->stream, '{'.$this->server.':'.$this->port.$this->flag.'}'.$folder); } catch (\Exception $e) { - throw new AuthenticationFailedException("Error! Connecting to Imap Email."); + throw new AuthenticationFailedException('Error! Connecting to Imap Email.'); } } - public function survive($folder = "INBOX") + public function survive($folder = 'INBOX') { - if( !$this->ping() || ($this->folder != $folder) ) { + if (!$this->ping() || ($this->folder !== $folder)) { $this->reconnect($folder); } } /** - * Set Timeout + * Set Timeout. * * @param string $timeout_type it may be IMAP_OPENTIMEOUT, IMAP_READTIMEOUT, IMAP_WRITETIMEOUT, or IMAP_CLOSETIMEOUT - * @param integer $timeout time in seconds or -1 - * @return void + * @param int $timeout time in seconds or -1 */ public function setTimeout($timeout_type, $timeout) { $this->timeout_type = $timeout_type; $this->timeout = $timeout; - return (boolean) imap_timeout($timeout_type, $timeout); + return (bool) imap_timeout($timeout_type, $timeout); } /** - * Get Stream + * Get Stream. * * @return mixed */ @@ -140,7 +142,7 @@ class Connection } /** - * Get Server + * Get Server. * * @return string */ @@ -150,19 +152,20 @@ class Connection } /** - * Check Connection + * Check Connection. * - * @return boolean + * @return bool */ public function checkConnection() { - return (!is_null($this->stream) && imap_ping($this->stream)); + return null !== $this->stream && imap_ping($this->stream); } /** - * Get Quota + * Get Quota. + * + * @param string $folder * - * @param string $folder * @return array */ public function getQuota($folder = 'INBOX') @@ -171,20 +174,21 @@ class Connection return [ 'usage' => (isset($data['usage'])) ? $data['usage'] : false, - 'limit' => (isset($data['limit'])) ? $data['limit'] : false + 'limit' => (isset($data['limit'])) ? $data['limit'] : false, ]; } /** - * Get Status + * Get Status. + * + * @param string $folder + * @param string $flag * - * @param string $folder - * @param string $flag * @return array */ public function getStatus($folder = 'INBOX', $flag = SA_ALL) { - $data = imap_status($this->stream, "{" . $this->server . "}" . $folder, $flag); + $data = imap_status($this->stream, '{'.$this->server.'}'.$folder, $flag); return [ 'flags' => (isset($data->flags)) ? $data->flags : false, @@ -192,12 +196,12 @@ class Connection 'recent' => (isset($data->recent)) ? $data->recent : false, 'unseen' => (isset($data->unseen)) ? $data->unseen : false, 'uidnext' => (isset($data->uidnext)) ? $data->uidnext : false, - 'uidvalidity' => (isset($data->uidvalidity)) ? $data->uidvalidity : false + 'uidvalidity' => (isset($data->uidvalidity)) ? $data->uidvalidity : false, ]; } /** - * Check MailBox Data + * Check MailBox Data. * * @return array */ @@ -210,22 +214,22 @@ class Connection 'driver' => (isset($data->Driver)) ? $data->Driver : false, 'mailbox' => (isset($data->Mailbox)) ? $data->Mailbox : false, 'nmsgs' => (isset($data->Nmsgs)) ? $data->Nmsgs : false, - 'recent' => (isset($data->Recent)) ? $data->Recent : false + 'recent' => (isset($data->Recent)) ? $data->Recent : false, ]; } /** - * Ping Connection + * Ping Connection. * - * @return boolean + * @return bool */ public function ping() { - return (boolean) imap_ping($this->stream); + return (bool) imap_ping($this->stream); } /** - * Get Errors + * Get Errors. * * @return array */ @@ -233,11 +237,11 @@ class Connection { $errors = imap_errors(); - return (is_array($errors)) ? $errors : []; + return (\is_array($errors)) ? $errors : []; } /** - * Get Alerts + * Get Alerts. * * @return array */ @@ -245,11 +249,11 @@ class Connection { $alerts = imap_alerts(); - return (is_array($alerts)) ? $alerts : []; + return (\is_array($alerts)) ? $alerts : []; } /** - * Get Last Error + * Get Last Error. * * @return string */ @@ -261,22 +265,24 @@ class Connection } /** - * Disconnect + * Disconnect. * - * @param integer $flag - * @return boolean + * @param int $flag + * + * @return bool */ public function disconnect($flag = \CL_EXPUNGE) { - if( !is_null($this->stream) && imap_ping($this->stream) ){ - if( imap_close($this->stream, $flag) ){ + if (null !== $this->stream && imap_ping($this->stream)) { + if (imap_close($this->stream, $flag)) { $this->stream = null; + return true; - }else{ - return false; } + + return false; } return false; } -} \ No newline at end of file +} diff --git a/src/Core/Exception/AuthenticationFailedException.php b/src/Core/Exception/AuthenticationFailedException.php index 1d14b70..7a0737a 100644 --- a/src/Core/Exception/AuthenticationFailedException.php +++ b/src/Core/Exception/AuthenticationFailedException.php @@ -1,25 +1,24 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Exception; /** - * Connection Error Class - * - * @package Clivern\Imap\Core\Exception + * Connection Error Class. */ class AuthenticationFailedException extends \Exception { - /** - * Class Constructor + * Class Constructor. * * @param string $error */ public function __construct($error = null) { - parent::__construct(sprintf("Authentication failed with error: %s", $error)); + parent::__construct(sprintf('Authentication failed with error: %s', $error)); } -} \ No newline at end of file +} diff --git a/src/Core/Exception/FolderNotExistException.php b/src/Core/Exception/FolderNotExistException.php index 233d54d..b898cb5 100644 --- a/src/Core/Exception/FolderNotExistException.php +++ b/src/Core/Exception/FolderNotExistException.php @@ -1,25 +1,24 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Exception; /** - * Folder Not Exist Error Class - * - * @package Clivern\Imap\Core\Exception + * Folder Not Exist Error Class. */ class FolderNotExistException extends \Exception { - /** - * Class Constructor + * Class Constructor. * * @param string $folder */ public function __construct($folder = null) { - parent::__construct(sprintf("Mailbox folder not exist: %s", $folder)); + parent::__construct(sprintf('Mailbox folder not exist: %s', $folder)); } -} \ No newline at end of file +} diff --git a/src/Core/Exception/MessageDeleteException.php b/src/Core/Exception/MessageDeleteException.php index 2c54f87..81c5f02 100644 --- a/src/Core/Exception/MessageDeleteException.php +++ b/src/Core/Exception/MessageDeleteException.php @@ -1,25 +1,24 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Exception; /** - * Connection Error Class - * - * @package Clivern\Imap\Core\Exception + * Connection Error Class. */ class MessageDeleteException extends \Exception { - /** - * Class Constructor + * Class Constructor. * - * @param integer $message_number + * @param int $message_number */ public function __construct($message_number) { parent::__construct(sprintf('Message %s cannot be deleted', $message_number)); } -} \ No newline at end of file +} diff --git a/src/Core/Exception/MessageDoesNotExistException.php b/src/Core/Exception/MessageDoesNotExistException.php index ca58661..3ba4964 100644 --- a/src/Core/Exception/MessageDoesNotExistException.php +++ b/src/Core/Exception/MessageDoesNotExistException.php @@ -1,26 +1,25 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Exception; /** - * Connection Error Class - * - * @package Clivern\Imap\Core\Exception + * Connection Error Class. */ class MessageDoesNotExistException extends \Exception { - /** - * Class Constructor + * Class Constructor. * - * @param integer $number + * @param int $number * @param string $error */ public function __construct($number, $error) { parent::__construct(sprintf('Message %s does not exist: %s', $number, $error)); } -} \ No newline at end of file +} diff --git a/src/Core/Exception/MessageMoveException.php b/src/Core/Exception/MessageMoveException.php index 2584632..7424562 100644 --- a/src/Core/Exception/MessageMoveException.php +++ b/src/Core/Exception/MessageMoveException.php @@ -1,26 +1,25 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Exception; /** - * Connection Error Class - * - * @package Clivern\Imap\Core\Exception + * Connection Error Class. */ class MessageMoveException extends \Exception { - /** - * Class Constructor + * Class Constructor. * - * @param integer $message_number + * @param int $message_number * @param string $mailbox */ public function __construct($message_number, $mailbox) { parent::__construct(sprintf('Message %s cannot be moved to %s', $message_number, $mailbox)); } -} \ No newline at end of file +} diff --git a/src/Core/Message.php b/src/Core/Message.php index 2809cbe..86b55a0 100644 --- a/src/Core/Message.php +++ b/src/Core/Message.php @@ -1,20 +1,19 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core; -use Clivern\Imap\Core\Connection; -use Clivern\Imap\Core\Message\Header; use Clivern\Imap\Core\Message\Action; use Clivern\Imap\Core\Message\Attachment; use Clivern\Imap\Core\Message\Body; +use Clivern\Imap\Core\Message\Header; /** - * Message Class - * - * @package Clivern\Imap\Core + * Message Class. */ class Message { @@ -44,17 +43,17 @@ class Message protected $body; /** - * @var integer + * @var int */ protected $uid; /** - * @var integer + * @var int */ protected $msg_number; /** - * Message Constructor + * Message Constructor. * * @param Connection $connection */ @@ -67,9 +66,11 @@ class Message } /** - * Set Message Number + * Set Message Number. + * + * @param int $id + * @param mixed $msg_number * - * @param integer $id * @return Message */ public function setMsgNo($msg_number) @@ -80,9 +81,9 @@ class Message } /** - * Get Message Number + * Get Message Number. * - * @return integer + * @return int */ public function getMsgNo() { @@ -90,9 +91,10 @@ class Message } /** - * Set UID + * Set UID. + * + * @param int $uid * - * @param integer $uid * @return Message */ public function setUid($uid) @@ -103,9 +105,9 @@ class Message } /** - * Get UID + * Get UID. * - * @return integer + * @return int */ public function getUid() { @@ -113,17 +115,17 @@ class Message } /** - * Config Message Number & UID + * Config Message Number & UID. * * @return Message */ public function config() { - if( !$this->msg_number && $this->uid ){ + if (!$this->msg_number && $this->uid) { $this->msg_number = imap_msgno($this->connection->getStream(), $this->uid); } - if( !$this->uid && $this->msg_number ){ + if (!$this->uid && $this->msg_number) { $this->uid = imap_uid($this->connection->getStream(), $this->msg_number); } @@ -131,7 +133,7 @@ class Message } /** - * Get Message Header Object + * Get Message Header Object. * * @return Header */ @@ -141,7 +143,7 @@ class Message } /** - * Get Message Action Object + * Get Message Action Object. * * @return Action */ @@ -151,7 +153,7 @@ class Message } /** - * Get Message Body Object + * Get Message Body Object. * * @return Body */ @@ -161,13 +163,13 @@ class Message } /** - * Get Message Attachments + * Get Message Attachments. * * @return array */ public function attachments() { - if( !is_null($this->attachments) ){ + if (null !== $this->attachments) { return $this->attachments; } @@ -180,21 +182,22 @@ class Message $i = 0; foreach ($structure->parts as $index => $part) { - if (!$part->ifdisposition){ + if (!$part->ifdisposition) { continue; } $this->attachments[$i] = new Attachment($this->connection); $this->attachments[$i]->config($this->getMsgNo(), $this->getUid(), $index + 1, $part); - $i += 1; + ++$i; } return $this->attachments; } /** - * Get Body + * Get Body. + * + * @param int $options * - * @param integer $options * @return string */ public function getBody($options = 0) @@ -203,4 +206,4 @@ class Message return $body; } -} \ No newline at end of file +} diff --git a/src/Core/Message/Action.php b/src/Core/Message/Action.php index 3daaa45..40ddaa6 100644 --- a/src/Core/Message/Action.php +++ b/src/Core/Message/Action.php @@ -1,6 +1,8 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Message; @@ -8,31 +10,27 @@ namespace Clivern\Imap\Core\Message; use Clivern\Imap\Core\Connection; /** - * Action Class - * - * @package Clivern\Imap\Core\Message + * Action Class. */ class Action { - /** * @var Connection */ protected $connection; /** - * @var integer + * @var int */ protected $message_number; /** - * @var integer + * @var int */ protected $message_uid; - /** - * Class Constructor + * Class Constructor. * * @param Connection $connection */ @@ -42,10 +40,11 @@ class Action } /** - * Config Message + * Config Message. + * + * @param int $message_number + * @param int $message_uid * - * @param integer $message_number - * @param integer $message_uid * @return Action */ public function config($message_number, $message_uid) @@ -57,22 +56,22 @@ class Action } /** - * Delete Message + * Delete Message. * - * @return boolean + * @return bool */ public function delete() { - return (boolean) imap_delete($this->connection->getStream(), $this->message_uid, \FT_UID); + return (bool) imap_delete($this->connection->getStream(), $this->message_uid, \FT_UID); } /** - * Undelete Message + * Undelete Message. * - * @return boolean + * @return bool */ public function undelete() { - return (boolean) imap_undelete($this->connection->getStream(), $this->message_uid, \FT_UID); + return (bool) imap_undelete($this->connection->getStream(), $this->message_uid, \FT_UID); } -} \ No newline at end of file +} diff --git a/src/Core/Message/Attachment.php b/src/Core/Message/Attachment.php index 3f6e2a0..05e067f 100644 --- a/src/Core/Message/Attachment.php +++ b/src/Core/Message/Attachment.php @@ -1,6 +1,8 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Message; @@ -8,25 +10,22 @@ namespace Clivern\Imap\Core\Message; use Clivern\Imap\Core\Connection; /** - * Attachment Class - * - * @package Clivern\Imap\Core\Message + * Attachment Class. */ class Attachment { - /** * @var Connection */ protected $connection; /** - * @var integer + * @var int */ protected $message_number; /** - * @var integer + * @var int */ protected $message_uid; @@ -36,13 +35,12 @@ class Attachment protected $attachment; /** - * @var Object + * @var object */ protected $part; - /** - * Class Constructor + * Class Constructor. * * @param Connection $connection */ @@ -52,12 +50,13 @@ class Attachment } /** - * Config Attachment + * Config Attachment. * - * @param integer $message_number - * @param integer $message_uid - * @param integer $attachment_id + * @param int $message_number + * @param int $message_uid + * @param int $attachment_id * @param object $part + * * @return Attachment */ public function config($message_number, $message_uid, $attachment_id, $part) @@ -73,10 +72,11 @@ class Attachment } /** - * Get Attachment Property + * Get Attachment Property. + * + * @param string $key + * @param bool $default * - * @param string $key - * @param boolean $default * @return mixed */ public function get($key, $default = false) @@ -85,7 +85,7 @@ class Attachment } /** - * Get Filename + * Get Filename. * * @return mixed */ @@ -95,7 +95,7 @@ class Attachment } /** - * Get Extension + * Get Extension. * * @return mixed */ @@ -105,7 +105,7 @@ class Attachment } /** - * Get Size + * Get Size. * * @return mixed */ @@ -115,7 +115,7 @@ class Attachment } /** - * Get Encoding + * Get Encoding. * * @return mixed */ @@ -125,7 +125,7 @@ class Attachment } /** - * Get Bytes + * Get Bytes. * * @return mixed */ @@ -135,49 +135,52 @@ class Attachment } /** - * Get Plain Body + * Get Plain Body. * * @return mixed */ public function getPlainBody() { - if( $this->get('plain_body') ){ + if ($this->get('plain_body')) { return $this->get('plain_body'); } - $this->attachment['plain_body'] = imap_fetchbody($this->connection->getStream(), $this->message_number, $this->attachment['index']); + $this->attachment['plain_body'] = imap_fetchbody( + $this->connection->getStream(), + $this->message_number, + $this->attachment['index'] + ); - return $this->get('plain_body'); + return $this->get('plain_body'); } /** - * Get Body + * Get Body. + * + * @throws Exception * * @return mixed - * @throws Exception */ public function getBody() { - - if( $this->get('body') ){ + if ($this->get('body')) { return $this->get('body'); } switch ($this->getEncoding()) { - case 0: // 7BIT - - case 1: // 8BIT - case 2: // BINARY $this->attachment['body'] = $this->getPlainBody(); + return $this->get('body'); case 3: // BASE-64 - $this->attachment['body'] = base64_decode($this->getPlainBody()); + $this->attachment['body'] = base64_decode($this->getPlainBody(), true); + return $this->get('body'); case 4: // QUOTED-PRINTABLE $this->attachment['body'] = imap_qprint($this->getPlainBody()); + return $this->get('body'); } @@ -185,27 +188,29 @@ class Attachment } /** - * Store File + * Store File. * - * @param string $path - * @param boolean $file_name - * @return boolean + * @param string $path + * @param bool $file_name + * + * @return bool */ public function store($path, $file_name = false) { $file_name = ($file_name) ? $file_name : "{$this->getFilename()}.{$this->getExtension()}"; - $path = rtrim($path, '/') . "/"; - return (boolean) file_put_contents($path . $file_name, $this->getBody()); + $path = rtrim($path, '/').'/'; + + return (bool) file_put_contents($path.$file_name, $this->getBody()); } /** - * Parse Parts + * Parse Parts. * - * @return boolean + * @return bool */ protected function parseParts() { - if( (count($this->attachment) > 2) ){ + if ((\count($this->attachment) > 2)) { return true; } @@ -223,19 +228,19 @@ class Attachment $this->attachment['ifdparameters'] = (isset($this->part->ifdparameters)) ? $this->part->ifdparameters : false; $this->attachment['ifparameters'] = (isset($this->part->ifparameters)) ? $this->part->ifparameters : false; - if( is_array($this->part->dparameters) ){ + if (\is_array($this->part->dparameters)) { foreach ($this->part->dparameters as $obj) { - if( in_array(strtolower($obj->attribute), ['filename', 'name']) ){ - $this->attachment[strtolower($obj->attribute)] = pathinfo($obj->value, PATHINFO_FILENAME); + if (\in_array(mb_strtolower($obj->attribute), ['filename', 'name'], true)) { + $this->attachment[mb_strtolower($obj->attribute)] = pathinfo($obj->value, PATHINFO_FILENAME); $this->attachment['extension'] = pathinfo($obj->value, PATHINFO_EXTENSION); } } } - if( is_array($this->part->parameters) ){ + if (\is_array($this->part->parameters)) { foreach ($this->part->parameters as $obj) { - if( in_array(strtolower($obj->attribute), ['filename', 'name']) ){ - $this->attachment[strtolower($obj->attribute)] = pathinfo($obj->value, PATHINFO_FILENAME); + if (\in_array(mb_strtolower($obj->attribute), ['filename', 'name'], true)) { + $this->attachment[mb_strtolower($obj->attribute)] = pathinfo($obj->value, PATHINFO_FILENAME); $this->attachment['extension'] = pathinfo($obj->value, PATHINFO_EXTENSION); } } @@ -243,4 +248,4 @@ class Attachment return true; } -} \ No newline at end of file +} diff --git a/src/Core/Message/Body.php b/src/Core/Message/Body.php index 68765e2..3565024 100644 --- a/src/Core/Message/Body.php +++ b/src/Core/Message/Body.php @@ -1,6 +1,8 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Message; @@ -8,30 +10,27 @@ namespace Clivern\Imap\Core\Message; use Clivern\Imap\Core\Connection; /** - * Body Class - * - * @package Clivern\Imap\Core\Message + * Body Class. */ class Body { - /** * @var Connection */ protected $connection; /** - * @var integer + * @var int */ protected $message_number; /** - * @var integer + * @var int */ protected $message_uid; /** - * @var integer + * @var int */ protected $encoding; @@ -40,9 +39,8 @@ class Body */ protected $message = ''; - /** - * Class Constructor + * Class Constructor. * * @param Connection $connection */ @@ -52,10 +50,11 @@ class Body } /** - * Config Body + * Config Body. + * + * @param int $message_number + * @param int $message_uid * - * @param integer $message_number - * @param integer $message_uid * @return Body */ public function config($message_number, $message_uid) @@ -67,29 +66,29 @@ class Body } /** - * Get Message + * Get Message. + * + * @param int $option * - * @param integer $option * @return string */ public function getMessage($option = 2) { - if( !empty($this->message) ){ + if (!empty($this->message)) { return $this->message; } $structure = imap_fetchstructure($this->connection->getStream(), $this->message_number); - if (isset($structure->parts) && is_array($structure->parts) && isset($structure->parts[1])) { + if (isset($structure->parts) && \is_array($structure->parts) && isset($structure->parts[1])) { $part = $structure->parts[1]; - $this->message = imap_fetchbody($this->connection->getStream(),$this->message_number , $option); - + $this->message = imap_fetchbody($this->connection->getStream(), $this->message_number, $option); $this->encoding = $part->encoding; - if($part->encoding == 3) { + if (3 === $part->encoding) { $this->message = imap_base64($this->message); - } elseif($part->encoding == 1) { + } elseif (1 === $part->encoding) { $this->message = imap_8bit($this->message); } else { $this->message = imap_qprint($this->message); @@ -102,9 +101,9 @@ class Body } /** - * Get Encoding + * Get Encoding. * - * @return integer + * @return int */ public function getEncoding() { diff --git a/src/Core/Message/Header.php b/src/Core/Message/Header.php index f981f37..049e571 100644 --- a/src/Core/Message/Header.php +++ b/src/Core/Message/Header.php @@ -1,6 +1,8 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Message; @@ -8,25 +10,22 @@ namespace Clivern\Imap\Core\Message; use Clivern\Imap\Core\Connection; /** - * Header Class - * - * @package Clivern\Imap\Core\Message + * Header Class. */ class Header { - /** * @var Connection */ protected $connection; /** - * @var integer + * @var int */ protected $message_number; /** - * @var integer + * @var int */ protected $message_uid; @@ -35,9 +34,8 @@ class Header */ protected $header = []; - /** - * Class Constructor + * Class Constructor. * * @param Connection $connection */ @@ -47,15 +45,17 @@ class Header } /** - * Config Message + * Config Message. + * + * @param int $message_number + * @param int $message_uid + * @param mixed $options * - * @param integer $message_number - * @param integer $message_uid * @return Header */ public function config($message_number, $message_uid, $options = 0) { - if( !empty($this->header) ){ + if (!empty($this->header)) { return $this; } @@ -67,37 +67,41 @@ class Header } /** - * Get From Header + * Get From Header. + * + * @param string $key + * @param bool $default * - * @param string $key - * @param boolean $default * @return mixed */ public function get($key, $default = false) { - return (isset($this->header[strtolower($key)])) ? $this->header[strtolower($key)] : $default; + return (isset($this->header[mb_strtolower($key)])) ? $this->header[mb_strtolower($key)] : $default; } /** - * Check if header has key + * Check if header has key. * - * @param string $key - * @return boolean + * @param string $key + * + * @return bool */ public function has($key) { - return (isset($this->header[strtolower($key)])); + return isset($this->header[mb_strtolower($key)]); } /** - * Parse Address List + * Parse Address List. * * @param string $address_string + * @param mixed $default_host + * * @return array */ - public function parseAddressList($address_string, $default_host = "example.com") + public function parseAddressList($address_string, $default_host = 'example.com') { - $address_array = imap_rfc822_parse_adrlist($address_string, $default_host); + $address_array = imap_rfc822_parse_adrlist($address_string, $default_host); $address_list = []; foreach ($address_array as $id => $val) { @@ -105,7 +109,7 @@ class Header 'mailbox' => $val->mailbox, 'host' => $val->host, 'personal' => $val->personal, - 'adl' => $val->adl + 'adl' => $val->adl, ]; } @@ -113,9 +117,10 @@ class Header } /** - * Load Header Data + * Load Header Data. * * @param mixed $options + * * @return Header */ protected function load($options = 0) @@ -129,7 +134,8 @@ class Header $this->header['date'] = (isset($item_overview->date)) ? $item_overview->date : false; $this->header['message_id'] = (isset($item_overview->message_id)) ? $item_overview->message_id : false; $this->header['in_reply_to'] = (isset($item_overview->in_reply_to)) ? $item_overview->in_reply_to : false; - $this->header['references'] = (isset($item_overview->references)) ? explode(" ", $item_overview->references) : false; + $this->header['references'] = (isset($item_overview->references)) ? + explode(' ', $item_overview->references) : false; $this->header['size'] = (isset($item_overview->size)) ? $item_overview->size : false; $this->header['uid'] = (isset($item_overview->uid)) ? $item_overview->uid : false; $this->header['msgno'] = (isset($item_overview->msgno)) ? $item_overview->msgno : false; @@ -144,4 +150,4 @@ class Header return $this; } -} \ No newline at end of file +} diff --git a/src/Core/MessageIterator.php b/src/Core/MessageIterator.php index 515c6cd..343c387 100644 --- a/src/Core/MessageIterator.php +++ b/src/Core/MessageIterator.php @@ -1,34 +1,31 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core; -use Clivern\Imap\Core\Message; -use Clivern\Imap\Core\Connection; -use Clivern\Imap\Core\Message\Header; use Clivern\Imap\Core\Message\Action; use Clivern\Imap\Core\Message\Body; +use Clivern\Imap\Core\Message\Header; /** - * Message Iterator Class - * - * @package Clivern\Imap\Core + * Message Iterator Class. */ class MessageIterator extends \ArrayIterator { - /** * @var Connection */ protected $connection; /** - * Constructor + * Constructor. * * @param Connection $connection - * @param array $message_numbers + * @param array $message_numbers */ public function __construct(Connection $connection, array $message_numbers) { @@ -37,13 +34,19 @@ class MessageIterator extends \ArrayIterator } /** - * Get current message + * Get current message. * * @return Message */ public function current() { - $message = new Message($this->connection, new Header($this->connection), new Action($this->connection), new Body($this->connection)); + $message = new Message( + $this->connection, + new Header($this->connection), + new Action($this->connection), + new Body($this->connection) + ); + return $message->setUid(parent::current())->config(); } -} \ No newline at end of file +} diff --git a/src/Core/Search.php b/src/Core/Search.php index 8d8320d..377e5d0 100644 --- a/src/Core/Search.php +++ b/src/Core/Search.php @@ -1,6 +1,8 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core; @@ -8,22 +10,30 @@ namespace Clivern\Imap\Core; use Clivern\Imap\Core\Search\Contract\Condition; /** - * Search Class - * - * @package Clivern\Imap\Core + * Search Class. */ class Search { - /** * @var array */ protected $conditions = []; /** - * Add Condition + * Get Conditions Query. + * + * @return string + */ + public function __toString() + { + return (!empty($this->conditions)) ? implode(' ', $this->conditions) : ''; + } + + /** + * Add Condition. * * @param Condition $condition + * * @return Search */ public function addCondition(Condition $condition) @@ -34,7 +44,7 @@ class Search } /** - * Get Conditions + * Get Conditions. * * @return array */ @@ -42,14 +52,4 @@ class Search { return $this->conditions; } - - /** - * Get Conditions Query - * - * @return string - */ - public function __toString() - { - return (!empty($this->conditions)) ? implode(" ", $this->conditions) : ""; - } -} \ No newline at end of file +} diff --git a/src/Core/Search/Condition/All.php b/src/Core/Search/Condition/All.php index fc325c9..d9c6c27 100644 --- a/src/Core/Search/Condition/All.php +++ b/src/Core/Search/Condition/All.php @@ -1,6 +1,8 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Search\Condition; @@ -8,20 +10,17 @@ namespace Clivern\Imap\Core\Search\Condition; use Clivern\Imap\Core\Search\Contract\Condition; /** - * All Class - * - * @package Clivern\Imap\Core\Search\Condition + * All Class. */ class All implements Condition { - /** - * Query String + * Query String. * * @return string */ public function __toString() { - return "ALL"; + return 'ALL'; } -} \ No newline at end of file +} diff --git a/src/Core/Search/Condition/Answered.php b/src/Core/Search/Condition/Answered.php index 37ce5f1..dab1637 100644 --- a/src/Core/Search/Condition/Answered.php +++ b/src/Core/Search/Condition/Answered.php @@ -1,6 +1,8 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Search\Condition; @@ -8,20 +10,17 @@ namespace Clivern\Imap\Core\Search\Condition; use Clivern\Imap\Core\Search\Contract\Condition; /** - * Answered Class - * - * @package Clivern\Imap\Core\Search\Condition + * Answered Class. */ class Answered implements Condition { - /** - * Query String + * Query String. * * @return string */ public function __toString() { - return "ANSWERED"; + return 'ANSWERED'; } -} \ No newline at end of file +} diff --git a/src/Core/Search/Condition/BCC.php b/src/Core/Search/Condition/BCC.php index c1247ea..4c9efd8 100644 --- a/src/Core/Search/Condition/BCC.php +++ b/src/Core/Search/Condition/BCC.php @@ -1,6 +1,8 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Search\Condition; @@ -8,20 +10,17 @@ namespace Clivern\Imap\Core\Search\Condition; use Clivern\Imap\Core\Search\Contract\Condition; /** - * BCC Class - * - * @package Clivern\Imap\Core\Search\Condition + * BCC Class. */ class BCC implements Condition { - /** * @var string */ protected $data; /** - * Class Constructor + * Class Constructor. * * @param string $data */ @@ -31,7 +30,7 @@ class BCC implements Condition } /** - * Query String + * Query String. * * @return string */ @@ -39,4 +38,4 @@ class BCC implements Condition { return "BCC \"{$this->data}\""; } -} \ No newline at end of file +} diff --git a/src/Core/Search/Condition/Before.php b/src/Core/Search/Condition/Before.php index 9eabd72..bebccab 100644 --- a/src/Core/Search/Condition/Before.php +++ b/src/Core/Search/Condition/Before.php @@ -1,6 +1,8 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Search\Condition; @@ -8,20 +10,17 @@ namespace Clivern\Imap\Core\Search\Condition; use Clivern\Imap\Core\Search\Contract\Condition; /** - * Before Class - * - * @package Clivern\Imap\Core\Search\Condition + * Before Class. */ class Before implements Condition { - /** * @var string */ protected $data; /** - * Class Constructor + * Class Constructor. * * @param string $data */ @@ -31,7 +30,7 @@ class Before implements Condition } /** - * Query String + * Query String. * * @return string */ @@ -39,4 +38,4 @@ class Before implements Condition { return "BEFORE \"{$this->data}\""; } -} \ No newline at end of file +} diff --git a/src/Core/Search/Condition/Body.php b/src/Core/Search/Condition/Body.php index 80d48ad..11328d0 100644 --- a/src/Core/Search/Condition/Body.php +++ b/src/Core/Search/Condition/Body.php @@ -1,6 +1,8 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Search\Condition; @@ -8,20 +10,17 @@ namespace Clivern\Imap\Core\Search\Condition; use Clivern\Imap\Core\Search\Contract\Condition; /** - * Body Class - * - * @package Clivern\Imap\Core\Search\Condition + * Body Class. */ class Body implements Condition { - /** * @var string */ protected $data; /** - * Class Constructor + * Class Constructor. * * @param string $data */ @@ -31,7 +30,7 @@ class Body implements Condition } /** - * Query String + * Query String. * * @return string */ @@ -39,4 +38,4 @@ class Body implements Condition { return "BODY \"{$this->data}\""; } -} \ No newline at end of file +} diff --git a/src/Core/Search/Condition/CC.php b/src/Core/Search/Condition/CC.php index 208b58a..79c4189 100644 --- a/src/Core/Search/Condition/CC.php +++ b/src/Core/Search/Condition/CC.php @@ -1,6 +1,8 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Search\Condition; @@ -8,20 +10,17 @@ namespace Clivern\Imap\Core\Search\Condition; use Clivern\Imap\Core\Search\Contract\Condition; /** - * CC Class - * - * @package Clivern\Imap\Core\Search\Condition + * CC Class. */ class CC implements Condition { - /** * @var string */ protected $data; /** - * Class Constructor + * Class Constructor. * * @param string $data */ @@ -31,7 +30,7 @@ class CC implements Condition } /** - * Query String + * Query String. * * @return string */ @@ -39,4 +38,4 @@ class CC implements Condition { return "CC \"{$this->data}\""; } -} \ No newline at end of file +} diff --git a/src/Core/Search/Condition/Deleted.php b/src/Core/Search/Condition/Deleted.php index 484bd7f..3c00c96 100644 --- a/src/Core/Search/Condition/Deleted.php +++ b/src/Core/Search/Condition/Deleted.php @@ -1,6 +1,8 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Search\Condition; @@ -8,20 +10,17 @@ namespace Clivern\Imap\Core\Search\Condition; use Clivern\Imap\Core\Search\Contract\Condition; /** - * Deleted Class - * - * @package Clivern\Imap\Core\Search\Condition + * Deleted Class. */ class Deleted implements Condition { - /** - * Query String + * Query String. * * @return string */ public function __toString() { - return "DELETED"; + return 'DELETED'; } -} \ No newline at end of file +} diff --git a/src/Core/Search/Condition/Flagged.php b/src/Core/Search/Condition/Flagged.php index c772a79..ce8ca39 100644 --- a/src/Core/Search/Condition/Flagged.php +++ b/src/Core/Search/Condition/Flagged.php @@ -1,6 +1,8 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Search\Condition; @@ -8,20 +10,17 @@ namespace Clivern\Imap\Core\Search\Condition; use Clivern\Imap\Core\Search\Contract\Condition; /** - * Flagged Class - * - * @package Clivern\Imap\Core\Search\Condition + * Flagged Class. */ class Flagged implements Condition { - /** - * Query String + * Query String. * * @return string */ public function __toString() { - return "FLAGGED"; + return 'FLAGGED'; } -} \ No newline at end of file +} diff --git a/src/Core/Search/Condition/From.php b/src/Core/Search/Condition/From.php index 6b83739..42370f3 100644 --- a/src/Core/Search/Condition/From.php +++ b/src/Core/Search/Condition/From.php @@ -1,6 +1,8 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Search\Condition; @@ -8,20 +10,17 @@ namespace Clivern\Imap\Core\Search\Condition; use Clivern\Imap\Core\Search\Contract\Condition; /** - * From Class - * - * @package Clivern\Imap\Core\Search\Condition + * From Class. */ class From implements Condition { - /** * @var string */ protected $data; /** - * Class Constructor + * Class Constructor. * * @param string $data */ @@ -31,7 +30,7 @@ class From implements Condition } /** - * Query String + * Query String. * * @return string */ @@ -39,4 +38,4 @@ class From implements Condition { return "FROM \"{$this->data}\""; } -} \ No newline at end of file +} diff --git a/src/Core/Search/Condition/Keyword.php b/src/Core/Search/Condition/Keyword.php index df51231..3ab2ff6 100644 --- a/src/Core/Search/Condition/Keyword.php +++ b/src/Core/Search/Condition/Keyword.php @@ -1,6 +1,8 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Search\Condition; @@ -8,20 +10,17 @@ namespace Clivern\Imap\Core\Search\Condition; use Clivern\Imap\Core\Search\Contract\Condition; /** - * Keyword Class - * - * @package Clivern\Imap\Core\Search\Condition + * Keyword Class. */ class Keyword implements Condition { - /** * @var string */ protected $data; /** - * Class Constructor + * Class Constructor. * * @param string $data */ @@ -31,7 +30,7 @@ class Keyword implements Condition } /** - * Query String + * Query String. * * @return string */ @@ -39,4 +38,4 @@ class Keyword implements Condition { return "KEYWORD \"{$this->data}\""; } -} \ No newline at end of file +} diff --git a/src/Core/Search/Condition/NewFlag.php b/src/Core/Search/Condition/NewFlag.php index ee1e770..7c293f7 100644 --- a/src/Core/Search/Condition/NewFlag.php +++ b/src/Core/Search/Condition/NewFlag.php @@ -1,6 +1,8 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Search\Condition; @@ -8,20 +10,17 @@ namespace Clivern\Imap\Core\Search\Condition; use Clivern\Imap\Core\Search\Contract\Condition; /** - * New Flag Class - * - * @package Clivern\Imap\Core\Search\Condition + * New Flag Class. */ class NewFlag implements Condition { - /** - * Query String + * Query String. * * @return string */ public function __toString() { - return "NEW"; + return 'NEW'; } -} \ No newline at end of file +} diff --git a/src/Core/Search/Condition/Old.php b/src/Core/Search/Condition/Old.php index 604d9bb..eb7e12a 100644 --- a/src/Core/Search/Condition/Old.php +++ b/src/Core/Search/Condition/Old.php @@ -1,6 +1,8 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Search\Condition; @@ -8,20 +10,17 @@ namespace Clivern\Imap\Core\Search\Condition; use Clivern\Imap\Core\Search\Contract\Condition; /** - * Old Class - * - * @package Clivern\Imap\Core\Search\Condition + * Old Class. */ class Old implements Condition { - /** - * Query String + * Query String. * * @return string */ public function __toString() { - return "OLD"; + return 'OLD'; } -} \ No newline at end of file +} diff --git a/src/Core/Search/Condition/On.php b/src/Core/Search/Condition/On.php index 9ff3aa3..f911610 100644 --- a/src/Core/Search/Condition/On.php +++ b/src/Core/Search/Condition/On.php @@ -1,6 +1,8 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Search\Condition; @@ -8,20 +10,17 @@ namespace Clivern\Imap\Core\Search\Condition; use Clivern\Imap\Core\Search\Contract\Condition; /** - * On Class - * - * @package Clivern\Imap\Core\Search\Condition + * On Class. */ class On implements Condition { - /** * @var string */ protected $data; /** - * Class Constructor + * Class Constructor. * * @param string $data */ @@ -31,7 +30,7 @@ class On implements Condition } /** - * Query String + * Query String. * * @return string */ @@ -39,4 +38,4 @@ class On implements Condition { return "ON \"{$this->data}\""; } -} \ No newline at end of file +} diff --git a/src/Core/Search/Condition/Recent.php b/src/Core/Search/Condition/Recent.php index 3dac8ae..7070817 100644 --- a/src/Core/Search/Condition/Recent.php +++ b/src/Core/Search/Condition/Recent.php @@ -1,6 +1,8 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Search\Condition; @@ -8,20 +10,17 @@ namespace Clivern\Imap\Core\Search\Condition; use Clivern\Imap\Core\Search\Contract\Condition; /** - * All Class - * - * @package Clivern\Imap\Core\Search\Condition + * All Class. */ class Recent implements Condition { - /** - * Query String + * Query String. * * @return string */ public function __toString() { - return "RECENT"; + return 'RECENT'; } -} \ No newline at end of file +} diff --git a/src/Core/Search/Condition/Seen.php b/src/Core/Search/Condition/Seen.php index d912db6..eb8339e 100644 --- a/src/Core/Search/Condition/Seen.php +++ b/src/Core/Search/Condition/Seen.php @@ -1,6 +1,8 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Search\Condition; @@ -8,20 +10,17 @@ namespace Clivern\Imap\Core\Search\Condition; use Clivern\Imap\Core\Search\Contract\Condition; /** - * Seen Class - * - * @package Clivern\Imap\Core\Search\Condition + * Seen Class. */ class Seen implements Condition { - /** - * Query String + * Query String. * * @return string */ public function __toString() { - return "SEEN"; + return 'SEEN'; } -} \ No newline at end of file +} diff --git a/src/Core/Search/Condition/Since.php b/src/Core/Search/Condition/Since.php index 0bec57d..da10828 100644 --- a/src/Core/Search/Condition/Since.php +++ b/src/Core/Search/Condition/Since.php @@ -1,6 +1,8 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Search\Condition; @@ -8,20 +10,17 @@ namespace Clivern\Imap\Core\Search\Condition; use Clivern\Imap\Core\Search\Contract\Condition; /** - * Since Class - * - * @package Clivern\Imap\Core\Search\Condition + * Since Class. */ class Since implements Condition { - /** * @var string */ protected $data; /** - * Class Constructor + * Class Constructor. * * @param string $data */ @@ -31,7 +30,7 @@ class Since implements Condition } /** - * Query String + * Query String. * * @return string */ @@ -39,4 +38,4 @@ class Since implements Condition { return "SINCE \"{$this->data}\""; } -} \ No newline at end of file +} diff --git a/src/Core/Search/Condition/Subject.php b/src/Core/Search/Condition/Subject.php index 3d88618..d96db36 100644 --- a/src/Core/Search/Condition/Subject.php +++ b/src/Core/Search/Condition/Subject.php @@ -1,6 +1,8 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Search\Condition; @@ -8,20 +10,17 @@ namespace Clivern\Imap\Core\Search\Condition; use Clivern\Imap\Core\Search\Contract\Condition; /** - * Subject Class - * - * @package Clivern\Imap\Core\Search\Condition + * Subject Class. */ class Subject implements Condition { - /** * @var string */ protected $data; /** - * Class Constructor + * Class Constructor. * * @param string $data */ @@ -31,7 +30,7 @@ class Subject implements Condition } /** - * Query String + * Query String. * * @return string */ @@ -39,4 +38,4 @@ class Subject implements Condition { return "SUBJECT \"{$this->data}\""; } -} \ No newline at end of file +} diff --git a/src/Core/Search/Condition/Text.php b/src/Core/Search/Condition/Text.php index 343b836..9e00da3 100644 --- a/src/Core/Search/Condition/Text.php +++ b/src/Core/Search/Condition/Text.php @@ -1,6 +1,8 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Search\Condition; @@ -8,20 +10,17 @@ namespace Clivern\Imap\Core\Search\Condition; use Clivern\Imap\Core\Search\Contract\Condition; /** - * Text Class - * - * @package Clivern\Imap\Core\Search\Condition + * Text Class. */ class Text implements Condition { - /** * @var string */ protected $data; /** - * Class Constructor + * Class Constructor. * * @param string $data */ @@ -31,7 +30,7 @@ class Text implements Condition } /** - * Query String + * Query String. * * @return string */ @@ -39,4 +38,4 @@ class Text implements Condition { return "TEXT \"{$this->data}\""; } -} \ No newline at end of file +} diff --git a/src/Core/Search/Condition/To.php b/src/Core/Search/Condition/To.php index f69e8ba..945f8b3 100644 --- a/src/Core/Search/Condition/To.php +++ b/src/Core/Search/Condition/To.php @@ -1,6 +1,8 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Search\Condition; @@ -8,20 +10,17 @@ namespace Clivern\Imap\Core\Search\Condition; use Clivern\Imap\Core\Search\Contract\Condition; /** - * To Class - * - * @package Clivern\Imap\Core\Search\Condition + * To Class. */ class To implements Condition { - /** * @var string */ protected $data; /** - * Class Constructor + * Class Constructor. * * @param string $data */ @@ -31,7 +30,7 @@ class To implements Condition } /** - * Query String + * Query String. * * @return string */ @@ -39,4 +38,4 @@ class To implements Condition { return "TO \"{$this->data}\""; } -} \ No newline at end of file +} diff --git a/src/Core/Search/Condition/UnAnswered.php b/src/Core/Search/Condition/UnAnswered.php index 0f873cc..9d48586 100644 --- a/src/Core/Search/Condition/UnAnswered.php +++ b/src/Core/Search/Condition/UnAnswered.php @@ -1,6 +1,8 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Search\Condition; @@ -8,20 +10,17 @@ namespace Clivern\Imap\Core\Search\Condition; use Clivern\Imap\Core\Search\Contract\Condition; /** - * UnAnswered Class - * - * @package Clivern\Imap\Core\Search\Condition + * UnAnswered Class. */ class UnAnswered implements Condition { - /** - * Query String + * Query String. * * @return string */ public function __toString() { - return "UNANSWERED"; + return 'UNANSWERED'; } -} \ No newline at end of file +} diff --git a/src/Core/Search/Condition/UnDeleted.php b/src/Core/Search/Condition/UnDeleted.php index 1c79312..b190c2a 100644 --- a/src/Core/Search/Condition/UnDeleted.php +++ b/src/Core/Search/Condition/UnDeleted.php @@ -1,6 +1,8 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Search\Condition; @@ -8,20 +10,17 @@ namespace Clivern\Imap\Core\Search\Condition; use Clivern\Imap\Core\Search\Contract\Condition; /** - * UnDeleted Class - * - * @package Clivern\Imap\Core\Search\Condition + * UnDeleted Class. */ class UnDeleted implements Condition { - /** - * Query String + * Query String. * * @return string */ public function __toString() { - return "UNDELETED"; + return 'UNDELETED'; } -} \ No newline at end of file +} diff --git a/src/Core/Search/Condition/UnFlagged.php b/src/Core/Search/Condition/UnFlagged.php index 28bc662..ec4412a 100644 --- a/src/Core/Search/Condition/UnFlagged.php +++ b/src/Core/Search/Condition/UnFlagged.php @@ -1,6 +1,8 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Search\Condition; @@ -8,20 +10,17 @@ namespace Clivern\Imap\Core\Search\Condition; use Clivern\Imap\Core\Search\Contract\Condition; /** - * UnFlagged Class - * - * @package Clivern\Imap\Core\Search\Condition + * UnFlagged Class. */ class UnFlagged implements Condition { - /** - * Query String + * Query String. * * @return string */ public function __toString() { - return "UNFLAGGED"; + return 'UNFLAGGED'; } -} \ No newline at end of file +} diff --git a/src/Core/Search/Condition/UnKeyword.php b/src/Core/Search/Condition/UnKeyword.php index 35265fe..8e121c7 100644 --- a/src/Core/Search/Condition/UnKeyword.php +++ b/src/Core/Search/Condition/UnKeyword.php @@ -1,6 +1,8 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Search\Condition; @@ -8,20 +10,17 @@ namespace Clivern\Imap\Core\Search\Condition; use Clivern\Imap\Core\Search\Contract\Condition; /** - * UnKeyword Class - * - * @package Clivern\Imap\Core\Search\Condition + * UnKeyword Class. */ class UnKeyword implements Condition { - /** * @var string */ protected $data; /** - * Class Constructor + * Class Constructor. * * @param string $data */ @@ -31,7 +30,7 @@ class UnKeyword implements Condition } /** - * Query String + * Query String. * * @return string */ @@ -39,4 +38,4 @@ class UnKeyword implements Condition { return "UNKEYWORD \"{$this->data}\""; } -} \ No newline at end of file +} diff --git a/src/Core/Search/Condition/UnSeen.php b/src/Core/Search/Condition/UnSeen.php index 9e5b8e4..98f75ab 100644 --- a/src/Core/Search/Condition/UnSeen.php +++ b/src/Core/Search/Condition/UnSeen.php @@ -1,6 +1,8 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Search\Condition; @@ -8,20 +10,17 @@ namespace Clivern\Imap\Core\Search\Condition; use Clivern\Imap\Core\Search\Contract\Condition; /** - * UnSeen Class - * - * @package Clivern\Imap\Core\Search\Condition + * UnSeen Class. */ class UnSeen implements Condition { - /** - * Query String + * Query String. * * @return string */ public function __toString() { - return "UNSEEN"; + return 'UNSEEN'; } -} \ No newline at end of file +} diff --git a/src/Core/Search/Contract/Condition.php b/src/Core/Search/Contract/Condition.php index aa52245..a480b37 100644 --- a/src/Core/Search/Contract/Condition.php +++ b/src/Core/Search/Contract/Condition.php @@ -1,16 +1,16 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap\Core\Search\Contract; /** - * Condition Interface - * - * @package Clivern\Imap\Core\Search\Contract + * Condition Interface. */ interface Condition { public function __toString(); -} \ No newline at end of file +} diff --git a/src/MailBox.php b/src/MailBox.php index 731ae44..838d04c 100644 --- a/src/MailBox.php +++ b/src/MailBox.php @@ -1,28 +1,27 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Clivern\Imap; use Clivern\Imap\Core\Connection; -use Clivern\Imap\Core\MessageIterator; +use Clivern\Imap\Core\Exception\FolderNotExistException; use Clivern\Imap\Core\Message; -use Clivern\Imap\Core\Search; -use Clivern\Imap\Core\Message\Header; use Clivern\Imap\Core\Message\Action; use Clivern\Imap\Core\Message\Attachments; use Clivern\Imap\Core\Message\Body; -use Clivern\Imap\Core\Exception\FolderNotExistException; +use Clivern\Imap\Core\Message\Header; +use Clivern\Imap\Core\MessageIterator; +use Clivern\Imap\Core\Search; /** - * MailBox Class - * - * @package Clivern\Imap + * MailBox Class. */ class MailBox { - /** * @var string */ @@ -38,9 +37,8 @@ class MailBox */ protected $folders = []; - /** - * Constructor + * Constructor. * * @param Connection $connection IMAP connection */ @@ -50,14 +48,15 @@ class MailBox } /** - * Set Folder Name + * Set Folder Name. * * @param string $folder + * * @return MailBox */ public function setFolder($folder) { - if( !in_array($folder, $this->getFolders()) ){ + if (!\in_array($folder, $this->getFolders(), true)) { throw new FolderNotExistException($folder); } @@ -67,7 +66,7 @@ class MailBox } /** - * Get Folder name + * Get Folder name. * * @return string */ @@ -77,20 +76,22 @@ class MailBox } /** - * Get number of messages in this mailbox + * Get number of messages in this mailbox. * * @return int */ public function count() { $this->connection->survive($this->folder); + return imap_num_msg($this->connection->getStream()); } /** - * Get message ids + * Get message ids. * * @param Search $search + * * @return MessageIterator */ public function getMessages(Search $search = null) @@ -99,7 +100,7 @@ class MailBox $query = ($search) ? (string) $search : 'ALL'; $message_numbers = imap_search($this->connection->getStream(), $query, \SE_UID); - if (false == $message_numbers) { + if (false === $message_numbers) { // imap_search can also return false $message_numbers = []; } @@ -108,53 +109,61 @@ class MailBox } /** - * Get a message by message number or uid + * Get a message by message number or uid. + * + * @param bool|int $message_number + * @param bool|int $message_uid * - * @param int|boolean $message_number - * @param int|boolean $message_uid * @return Message */ public function getMessage($message_number = false, $message_uid = false) { $this->connection->survive($this->folder); - $message = new Message($this->connection, new Header($this->connection), new Action($this->connection), new Attachments($this->connection), new Body($this->connection)); + $message = new Message( + $this->connection, + new Header($this->connection), + new Action($this->connection), + new Attachments($this->connection), + new Body($this->connection) + ); - if( $message_number == false ){ + if (false === $message_number) { return $message->setUid($message_uid)->config(); - }else{ - return $message->setMsgNo($message_number)->config(); } + + return $message->setMsgNo($message_number)->config(); } /** - * Delete all messages marked for deletion + * Delete all messages marked for deletion. * - * @return boolean + * @return bool */ public function expunge() { $this->connection->survive($this->folder); - return (boolean) imap_expunge($this->connection->getStream()); + + return (bool) imap_expunge($this->connection->getStream()); } /** - * Get Folders List + * Get Folders List. * * @return array */ public function getFolders() { - if( !empty($this->folders) ){ + if (!empty($this->folders)) { return $this->folders; } - $this->folders = imap_getmailboxes($this->connection->getStream(), "{" . $this->connection->getServer() . "}", "*"); + $this->folders = imap_getmailboxes($this->connection->getStream(), '{'.$this->connection->getServer().'}', '*'); foreach ($this->folders as $key => $folder) { - $this->folders[$key] = str_replace("{" . $this->connection->getServer() . "}", "", $folder->name); + $this->folders[$key] = str_replace('{'.$this->connection->getServer().'}', '', $folder->name); } return $this->folders; } -} \ No newline at end of file +} diff --git a/tests/Core/ConnectionTest.php b/tests/Core/ConnectionTest.php index b2c7b0a..7371280 100644 --- a/tests/Core/ConnectionTest.php +++ b/tests/Core/ConnectionTest.php @@ -1,4 +1,10 @@ + */ + namespace Tests\Core; use PHPUnit\Framework\TestCase; @@ -7,10 +13,10 @@ class ConnectionTest extends TestCase { public function testConnect() { - #$email = getenv("TEST_EMAIL"); - #$password = getenv("TEST_EMAIL_PASS"); - #$connection = new \Clivern\Imap\Core\Connection("imap.gmail.com", "993", $email, $password, "/ssl", "INBOX"); - #$this->assertTrue($connection->connect()->checkConnection()); - #$this->assertTrue($connection->connect()->disconnect()); + //$email = getenv("TEST_EMAIL"); + //$password = getenv("TEST_EMAIL_PASS"); + //$connection = new \Clivern\Imap\Core\Connection("imap.gmail.com", "993", $email, $password, "/ssl", "INBOX"); + //$this->assertTrue($connection->connect()->checkConnection()); + //$this->assertTrue($connection->connect()->disconnect()); } -} \ No newline at end of file +} diff --git a/tests/Core/SearchTest.php b/tests/Core/SearchTest.php index 53da585..24564ab 100644 --- a/tests/Core/SearchTest.php +++ b/tests/Core/SearchTest.php @@ -1,4 +1,10 @@ + */ + namespace Tests\Core; use PHPUnit\Framework\TestCase; @@ -8,8 +14,32 @@ class SearchTest extends TestCase public function testConditionBuilder() { $search = new \Clivern\Imap\Core\Search(); - $search->addCondition(new \Clivern\Imap\Core\Search\Condition\All())->addCondition(new \Clivern\Imap\Core\Search\Condition\Answered())->addCondition(new \Clivern\Imap\Core\Search\Condition\BCC("val"))->addCondition(new \Clivern\Imap\Core\Search\Condition\Before("val"))->addCondition(new \Clivern\Imap\Core\Search\Condition\Body("val"))->addCondition(new \Clivern\Imap\Core\Search\Condition\CC("val"))->addCondition(new \Clivern\Imap\Core\Search\Condition\Deleted())->addCondition(new \Clivern\Imap\Core\Search\Condition\Flagged())->addCondition(new \Clivern\Imap\Core\Search\Condition\From("val"))->addCondition(new \Clivern\Imap\Core\Search\Condition\Keyword("val"))->addCondition(new \Clivern\Imap\Core\Search\Condition\NewFlag())->addCondition(new \Clivern\Imap\Core\Search\Condition\Old())->addCondition(new \Clivern\Imap\Core\Search\Condition\On("val"))->addCondition(new \Clivern\Imap\Core\Search\Condition\Recent())->addCondition(new \Clivern\Imap\Core\Search\Condition\Seen())->addCondition(new \Clivern\Imap\Core\Search\Condition\Since("val"))->addCondition(new \Clivern\Imap\Core\Search\Condition\Subject("val"))->addCondition(new \Clivern\Imap\Core\Search\Condition\Text("val"))->addCondition(new \Clivern\Imap\Core\Search\Condition\To("val"))->addCondition(new \Clivern\Imap\Core\Search\Condition\UnAnswered())->addCondition(new \Clivern\Imap\Core\Search\Condition\UnDeleted())->addCondition(new \Clivern\Imap\Core\Search\Condition\UnFlagged())->addCondition(new \Clivern\Imap\Core\Search\Condition\UnKeyword("val"))->addCondition(new \Clivern\Imap\Core\Search\Condition\UnSeen()); - $this->assertEquals($search->getConditions(), [ + $search->addCondition(new \Clivern\Imap\Core\Search\Condition\All()) + ->addCondition(new \Clivern\Imap\Core\Search\Condition\Answered()) + ->addCondition(new \Clivern\Imap\Core\Search\Condition\BCC('val')) + ->addCondition(new \Clivern\Imap\Core\Search\Condition\Before('val')) + ->addCondition(new \Clivern\Imap\Core\Search\Condition\Body('val')) + ->addCondition(new \Clivern\Imap\Core\Search\Condition\CC('val')) + ->addCondition(new \Clivern\Imap\Core\Search\Condition\Deleted()) + ->addCondition(new \Clivern\Imap\Core\Search\Condition\Flagged()) + ->addCondition(new \Clivern\Imap\Core\Search\Condition\From('val')) + ->addCondition(new \Clivern\Imap\Core\Search\Condition\Keyword('val')) + ->addCondition(new \Clivern\Imap\Core\Search\Condition\NewFlag()) + ->addCondition(new \Clivern\Imap\Core\Search\Condition\Old()) + ->addCondition(new \Clivern\Imap\Core\Search\Condition\On('val')) + ->addCondition(new \Clivern\Imap\Core\Search\Condition\Recent()) + ->addCondition(new \Clivern\Imap\Core\Search\Condition\Seen()) + ->addCondition(new \Clivern\Imap\Core\Search\Condition\Since('val')) + ->addCondition(new \Clivern\Imap\Core\Search\Condition\Subject('val')) + ->addCondition(new \Clivern\Imap\Core\Search\Condition\Text('val')) + ->addCondition(new \Clivern\Imap\Core\Search\Condition\To('val')) + ->addCondition(new \Clivern\Imap\Core\Search\Condition\UnAnswered()) + ->addCondition(new \Clivern\Imap\Core\Search\Condition\UnDeleted()) + ->addCondition(new \Clivern\Imap\Core\Search\Condition\UnFlagged()) + ->addCondition(new \Clivern\Imap\Core\Search\Condition\UnKeyword('val')) + ->addCondition(new \Clivern\Imap\Core\Search\Condition\UnSeen()); + + $this->assertSame($search->getConditions(), [ 'ALL', 'ANSWERED', 'BCC "val"', @@ -33,8 +63,13 @@ class SearchTest extends TestCase 'UNDELETED', 'UNFLAGGED', 'UNKEYWORD "val"', - 'UNSEEN' + 'UNSEEN', ]); - $this->assertEquals((string) $search, 'ALL ANSWERED BCC "val" BEFORE "val" BODY "val" CC "val" DELETED FLAGGED FROM "val" KEYWORD "val" NEW OLD ON "val" RECENT SEEN SINCE "val" SUBJECT "val" TEXT "val" TO "val" UNANSWERED UNDELETED UNFLAGGED UNKEYWORD "val" UNSEEN'); + $this->assertSame( + (string) $search, + 'ALL ANSWERED BCC "val" BEFORE "val" BODY "val" CC "val" DELETED FLAGGED FROM "val" KEYWORD "val" '. + 'NEW OLD ON "val" RECENT SEEN SINCE "val" SUBJECT "val" TEXT "val" TO "val" UNANSWERED UNDELETED '. + 'UNFLAGGED UNKEYWORD "val" UNSEEN' + ); } -} \ No newline at end of file +} diff --git a/tests/MailBoxTest.php b/tests/MailBoxTest.php index 3f802a7..998c1f7 100644 --- a/tests/MailBoxTest.php +++ b/tests/MailBoxTest.php @@ -1,6 +1,8 @@ + +/* + * This file is part of the Imap PHP package. + * (c) Clivern */ namespace Tests; @@ -8,9 +10,7 @@ namespace Tests; use PHPUnit\Framework\TestCase; /** - * MailBox Class Test - * - * @package Tests + * MailBox Class Test. */ class MailBoxTest extends TestCase { @@ -18,4 +18,4 @@ class MailBoxTest extends TestCase { $this->assertTrue(true); } -} \ No newline at end of file +}