From 3d25c67afdf8bf7836bd11147e9f973e6c9d519d Mon Sep 17 00:00:00 2001 From: Dima Teplukhin Date: Sun, 3 Sep 2023 08:38:15 +0300 Subject: [PATCH] feat(app): add helper email check --- website/composer.json | 8 +- website/composer.lock | 153 +++++++++++++++++++++++++++++++++- website/index.php | 15 ++++ website/src/Helpers/Email.php | 35 ++++++++ 4 files changed, 209 insertions(+), 2 deletions(-) create mode 100644 website/src/Helpers/Email.php diff --git a/website/composer.json b/website/composer.json index 8205c8a3f..ee87fa0fe 100644 --- a/website/composer.json +++ b/website/composer.json @@ -8,6 +8,11 @@ "vlucas/phpdotenv": "^5.5", "php-amqplib/php-amqplib": "^2.0" }, + "autoload": { + "psr-4": { + "App\\" : "src/" + } + }, "license": "MIT", "authors": [ { @@ -16,7 +21,8 @@ ], "minimum-stability": "stable", "require-dev": { - "squizlabs/php_codesniffer": "^3.7" + "squizlabs/php_codesniffer": "^3.7", + "symfony/var-dumper": "^6.3" }, "scripts": { "phpcs": "phpcs --standard=PSR2" diff --git a/website/composer.lock b/website/composer.lock index ddc8dfe8d..8378c5a2e 100644 --- a/website/composer.lock +++ b/website/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e7ea40406d4197f95f66def04ab12791", + "content-hash": "952d8ee90fcef8cd5a9b3fee15932d6c", "packages": [ { "name": "graham-campbell/result-type", @@ -607,6 +607,157 @@ "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" }, "time": "2023-02-22T23:07:41+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v3.3.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/7c3aff79d10325257a001fcf92d991f24fc967cf", + "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.4-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.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": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.3.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-05-23T14:45:45+00:00" + }, + { + "name": "symfony/var-dumper", + "version": "v6.3.4", + "source": { + "type": "git", + "url": "https://github.com/symfony/var-dumper.git", + "reference": "2027be14f8ae8eae999ceadebcda5b4909b81d45" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/2027be14f8ae8eae999ceadebcda5b4909b81d45", + "reference": "2027be14f8ae8eae999ceadebcda5b4909b81d45", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "symfony/deprecation-contracts": "^2.5|^3", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/console": "<5.4" + }, + "require-dev": { + "ext-iconv": "*", + "symfony/console": "^5.4|^6.0", + "symfony/http-kernel": "^5.4|^6.0", + "symfony/process": "^5.4|^6.0", + "symfony/uid": "^5.4|^6.0", + "twig/twig": "^2.13|^3.0.4" + }, + "bin": [ + "Resources/bin/var-dump-server" + ], + "type": "library", + "autoload": { + "files": [ + "Resources/functions/dump.php" + ], + "psr-4": { + "Symfony\\Component\\VarDumper\\": "" + }, + "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": "Provides mechanisms for walking through any arbitrary PHP variable", + "homepage": "https://symfony.com", + "keywords": [ + "debug", + "dump" + ], + "support": { + "source": "https://github.com/symfony/var-dumper/tree/v6.3.4" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-08-24T14:51:05+00:00" } ], "aliases": [], diff --git a/website/index.php b/website/index.php index 2b9f53941..60aad17af 100644 --- a/website/index.php +++ b/website/index.php @@ -2,4 +2,19 @@ declare(strict_types=1); +use App\Helpers\Email; + require 'vendor/autoload.php'; + +$emailRecords = [ + 'test@ya.ru', + 'teststatic@ya.ru', + 'werewr.ertr', + '12221@123.qwe' +]; + +try { + dump(Email::validateEmails($emailRecords)); +} catch (RuntimeException $e) { + dump($e); +} \ No newline at end of file diff --git a/website/src/Helpers/Email.php b/website/src/Helpers/Email.php new file mode 100644 index 000000000..acff20ff1 --- /dev/null +++ b/website/src/Helpers/Email.php @@ -0,0 +1,35 @@ + 0; + } catch (\RuntimeException $e) { + $resultEmail = false; + } + + static::$DNS[$domain] = $resultEmail; + return $resultEmail; + } +} \ No newline at end of file