diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml index 7ad6534..2e1718b 100644 --- a/.github/workflows/rector.yml +++ b/.github/workflows/rector.yml @@ -62,5 +62,5 @@ jobs: - name: Analyze for refactoring run: | - composer global require --dev rector/rector:^0.15.1 + composer global require --dev rector/rector:^0.18.7 rector process --dry-run --no-progress-bar diff --git a/README.md b/README.md index 1b4ffb5..22e6737 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,19 @@ [Farsi](./README.fa-IR.md) | English ## CodeIgniter DEA Rule [![PHPUnit](https://github.com/datamweb/codeigniter-dea-rule/actions/workflows/phpunit.yml/badge.svg)](https://github.com/datamweb/codeigniter-dea-rule/actions/workflows/phpunit.yml) +[![Coverage Status](https://coveralls.io/repos/github/datamweb/codeigniter-dea-rule/badge.svg?branch=develop)](https://coveralls.io/github/datamweb/codeigniter-dea-rule?branch=develop) [![PHPStan](https://github.com/datamweb/codeigniter-dea-rule/actions/workflows/phpstan.yml/badge.svg)](https://github.com/datamweb/codeigniter-dea-rule/actions/workflows/phpstan.yml) [![Rector](https://github.com/datamweb/codeigniter-dea-rule/actions/workflows/rector.yml/badge.svg)](https://github.com/datamweb/codeigniter-dea-rule/actions/workflows/rector.yml) [![Psalm](https://github.com/datamweb/codeigniter-dea-rule/actions/workflows/psalm.yml/badge.svg)](https://github.com/datamweb/codeigniter-dea-rule/actions/workflows/psalm.yml) -[![PHPCSFixer](https://github.com/datamweb/codeigniter-dea-ruleactions/workflows/phpcsfixer.yml/badge.svg)](https://github.com/datamweb/codeigniter-dea-ruleactions/workflows/phpcsfixer.yml) -[![PHPCPD](https://github.com/datamweb/codeigniter-dea-ruleactions/workflows/phpcpd.yml/badge.svg)](https://github.com/datamweb/codeigniter-dea-ruleactions/workflows/phpcpd.yml) +[![PHPCSFixer](https://github.com/datamweb/codeigniter-dea-rule/actions/workflows/phpcsfixer.yml/badge.svg)](https://github.com/datamweb/codeigniter-dea-rule/actions/workflows/phpcsfixer.yml) +[![PHPCPD](https://github.com/datamweb/codeigniter-dea-rule/actions/workflows/phpcpd.yml/badge.svg)](https://github.com/datamweb/codeigniter-dea-rule/actions/workflows/phpcpd.yml) [![Unused](https://github.com/datamweb/codeigniter-dea-rule/actions/workflows/unused.yml/badge.svg)](https://github.com/datamweb/codeigniter-dea-rule/actions/workflows/unused.yml) [![Deptrac](https://github.com/datamweb/codeigniter-dea-rule/actions/workflows/deptrac.yml/badge.svg)](https://github.com/datamweb/codeigniter-dea-rule/actions/workflows/deptrac.yml)

CodeIgniter DEA Rule

-[![Latest Stable Version](http://poser.pugx.org/datamweb/codeigniter-dea-rulev?style=for-the-badge)](https://packagist.org/packages/datamweb/shield-oauth) [![Total Downloads](http://poser.pugx.org/datamweb/codeigniter-dea-ruledownloads?style=for-the-badge)](https://packagist.org/packages/datamweb/shield-oauth) [![Latest Unstable Version](http://poser.pugx.org/datamweb/codeigniter-dea-rulev/unstable?style=for-the-badge)](https://packagist.org/packages/datamweb/shield-oauth) [![License](http://poser.pugx.org/datamweb/codeigniter-dea-rulelicense?style=for-the-badge)](https://packagist.org/packages/datamweb/shield-oauth) [![PHP Version Require](http://poser.pugx.org/datamweb/codeigniter-dea-rulerequire/php?style=for-the-badge)](https://packagist.org/packages/datamweb/shield-oauth) +[![Latest Stable Version](http://poser.pugx.org/datamweb/codeigniter-dea-rule/v?style=for-the-badge)](https://packagist.org/packages/datamweb/codeigniter-dea-rule) [![Total Downloads](http://poser.pugx.org/datamweb/codeigniter-dea-rule/downloads?style=for-the-badge)](https://packagist.org/packages/datamweb/codeigniter-dea-rule) [![Latest Unstable Version](http://poser.pugx.org/datamweb/codeigniter-dea-rule/v/unstable?style=for-the-badge)](https://packagist.org/packages/datamweb/codeigniter-dea-rule) [![License](http://poser.pugx.org/datamweb/codeigniter-dea-rule/license?style=for-the-badge)](https://packagist.org/packages/datamweb/codeigniter-dea-rule) [![PHP Version Require](http://poser.pugx.org/datamweb/codeigniter-dea-rule/require/php?style=for-the-badge)](https://packagist.org/packages/datamweb/codeigniter-dea-rule) **`CodeIgniter DEA Rule`** helps you to validate the email provided by the user and to deal with it if the email was of Temporary & Disponsable Emails(DEA) use type. diff --git a/docs/index.md b/docs/index.md index cdac2a5..0f1ad72 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,5 +1,6 @@ ## CodeIgniter DEA Rule [![PHPUnit](https://github.com/datamweb/codeigniter-dea-rule/actions/workflows/phpunit.yml/badge.svg)](https://github.com/datamweb/codeigniter-dea-rule/actions/workflows/phpunit.yml) +[![Coverage Status](https://coveralls.io/repos/github/datamweb/codeigniter-dea-rule/badge.svg?branch=develop)](https://coveralls.io/github/datamweb/codeigniter-dea-rule?branch=develop) [![PHPStan](https://github.com/datamweb/codeigniter-dea-rule/actions/workflows/phpstan.yml/badge.svg)](https://github.com/datamweb/codeigniter-dea-rule/actions/workflows/phpstan.yml) [![Rector](https://github.com/datamweb/codeigniter-dea-rule/actions/workflows/rector.yml/badge.svg)](https://github.com/datamweb/codeigniter-dea-rule/actions/workflows/rector.yml) [![Psalm](https://github.com/datamweb/codeigniter-dea-rule/actions/workflows/psalm.yml/badge.svg)](https://github.com/datamweb/codeigniter-dea-rule/actions/workflows/psalm.yml) diff --git a/phpstan-baseline.php b/phpstan-baseline.php index 145db48..9183266 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -2,9 +2,14 @@ $ignoreErrors = []; -// $ignoreErrors[] = [ -// 'message' => '#^Property Datamweb\\\\CodeIgniterDEARule\\\\Database\\\\Migrations\\\\LogsTempEmailMigration\\:\\:\\$attributes type has no value type specified in iterable type array\\.$#', -// 'count' => 1, -// 'path' => __DIR__ . '/src/Database/Migrations/2023-11-11-105553_LogsTempEmailMigration.php', -// ]; +$ignoreErrors[] = [ + 'message' => '#^Property Tests\\\\Support\\\\Config\\\\Registrar\\:\\:\\$dbConfig type has no value type specified in iterable type array\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/tests/_support/Config/Registrar.php', +]; +$ignoreErrors[] = [ + 'message' => '#^Method Tests\\\\Support\\\\Config\\\\Registrar\\:\\:Database\\(\\) return type has no value type specified in iterable type array\\.$#', + 'count' => 1, + 'path' => __DIR__ . '/tests/_support/Config/Registrar.php', +]; return ['parameters' => ['ignoreErrors' => $ignoreErrors]]; diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 609c716..e89b18e 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -91,13 +91,13 @@ - + - + diff --git a/rector.php b/rector.php index 106fdf5..67c6bdb 100644 --- a/rector.php +++ b/rector.php @@ -94,6 +94,7 @@ TypedPropertyFromAssignsRector::class => [ __DIR__ . '/src/Models/LogsTempEmailModel.php', __DIR__ . '/src/Commands/DEARulePublish.php', + __DIR__ . '/tests/_support/Config/Registrar.php', ], ]); diff --git a/src/Commands/DEARulePublish.php b/src/Commands/DEARulePublish.php index 2df1409..f02b0fc 100644 --- a/src/Commands/DEARulePublish.php +++ b/src/Commands/DEARulePublish.php @@ -3,7 +3,7 @@ declare(strict_types=1); /** - * This file is part of CodeIgniter4 GO TO PAY. + * This file is part of CodeIgniter-DEA-Rule. * * (c) 2023 Datamweb * diff --git a/src/Config/DEARule.php b/src/Config/DEARule.php index b3a50da..a3fe45b 100644 --- a/src/Config/DEARule.php +++ b/src/Config/DEARule.php @@ -27,8 +27,8 @@ class DEARule */ public array $filesBlacklisted = [ 'https://raw.githubusercontent.com/wesbos/burner-email-providers/master/emails.txt', - //'https://raw.githubusercontent.com/disposable-email-domains/disposable-email-domains/master/disposable_email_blocklist.conf', - //'https://gist.githubusercontent.com/saaiful/dd2b4b34a02171d7f9f0b979afe48f65/raw/2ad5590be72b69a51326b3e9d229f615e866f2e5/blocklist.txt', + // 'https://raw.githubusercontent.com/disposable-email-domains/disposable-email-domains/master/disposable_email_blocklist.conf', + // 'https://gist.githubusercontent.com/saaiful/dd2b4b34a02171d7f9f0b979afe48f65/raw/2ad5590be72b69a51326b3e9d229f615e866f2e5/blocklist.txt', // APPPATH . 'myCustomDomainBlacklisted.txt', ]; diff --git a/tests/_support/Config/Registrar.php b/tests/_support/Config/Registrar.php new file mode 100644 index 0000000..7cfcff4 --- /dev/null +++ b/tests/_support/Config/Registrar.php @@ -0,0 +1,145 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace Tests\Support\Config; + +/** + * Class Registrar + * + * Provides a basic registrar class for testing BaseConfig registration functions. + */ +class Registrar +{ + /** + * DB config array for testing purposes. + * + * @var array + * + * @psalm-suppress RedundantCondition + */ + protected static $dbConfig = [ + 'MySQLi' => [ + 'DSN' => '', + 'hostname' => '127.0.0.1', + 'username' => 'root', + 'password' => '', + 'database' => 'test', + 'DBDriver' => 'MySQLi', + 'DBPrefix' => 'db_', + 'pConnect' => false, + 'DBDebug' => true, + 'charset' => 'utf8', + 'DBCollat' => 'utf8_general_ci', + 'swapPre' => '', + 'encrypt' => false, + 'compress' => false, + 'strictOn' => false, + 'failover' => [], + 'port' => 3306, + ], + 'Postgre' => [ + 'DSN' => '', + 'hostname' => 'localhost', + 'username' => 'postgres', + 'password' => 'postgres', + 'database' => 'test', + 'DBDriver' => 'Postgre', + 'DBPrefix' => 'db_', + 'pConnect' => false, + 'DBDebug' => true, + 'charset' => 'utf8', + 'DBCollat' => 'utf8_general_ci', + 'swapPre' => '', + 'encrypt' => false, + 'compress' => false, + 'strictOn' => false, + 'failover' => [], + 'port' => 5432, + ], + 'SQLite3' => [ + 'DSN' => '', + 'hostname' => 'localhost', + 'username' => '', + 'password' => '', + 'database' => 'database.db', + 'DBDriver' => 'SQLite3', + 'DBPrefix' => 'db_', + 'pConnect' => false, + 'DBDebug' => true, + 'charset' => 'utf8', + 'DBCollat' => 'utf8_general_ci', + 'swapPre' => '', + 'encrypt' => false, + 'compress' => false, + 'strictOn' => false, + 'failover' => [], + 'port' => 3306, + 'foreignKeys' => true, + ], + 'SQLSRV' => [ + 'DSN' => '', + 'hostname' => 'localhost', + 'username' => 'sa', + 'password' => '1Secure*Password1', + 'database' => 'test', + 'DBDriver' => 'SQLSRV', + 'DBPrefix' => 'db_', + 'pConnect' => false, + 'DBDebug' => true, + 'charset' => 'utf8', + 'DBCollat' => 'utf8_general_ci', + 'swapPre' => '', + 'encrypt' => false, + 'compress' => false, + 'strictOn' => false, + 'failover' => [], + 'port' => 1433, + ], + 'OCI8' => [ + 'DSN' => 'localhost:1521/XEPDB1', + 'hostname' => '', + 'username' => 'ORACLE', + 'password' => 'ORACLE', + 'database' => '', + 'DBDriver' => 'OCI8', + 'DBPrefix' => 'db_', + 'pConnect' => false, + 'DBDebug' => true, + 'charset' => 'utf8', + 'DBCollat' => 'utf8_general_ci', + 'swapPre' => '', + 'encrypt' => false, + 'compress' => false, + 'strictOn' => false, + 'failover' => [], + ], + ]; + + /** + * Override database config + * + * @return array + */ + public static function Database() + { + $config = []; + + // Under GitHub Actions, we can set an ENV var named 'DB' + // so that we can test against multiple databases. + if (($group = getenv('DB')) && ! isset(self::$dbConfig[$group])) { + $config['tests'] = self::$dbConfig[$group]; + } + + return $config; + } +}