PHP code example of cse / helpers-email

1. Go to this page and download the library: Download cse/helpers-email library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

cse / helpers-email example snippets


switch (true) {
    case Email::is($emial):
        break;
    case Email::exist($emial):
        $emial = Email::extract($emial);
        break;
    default:
        new Exception('Email is not exist');
}

$emial = Email::hide($emial);

Email::hide('[email protected]');
// m***@google.com

Email::hide('[email protected]');
// m***[email protected]

Email::hide('[email protected]');
// e***l***[email protected]

$domain = 'google.com';
Email::checkDomain('[email protected]', $domain);
// true
Email::checkDomain('[email protected]', $domain);
// false

Email::is('[email protected]');
// true

Email::is('Example text [email protected]');
// false

Email::exist('[email protected]');
// true

Email::exist('Example text [email protected]');
// true

Email::exist('Example text [email protected]', '([a-z][email protected])');
// false

Email::extract('Example text [email protected]');
// [email protected]

Email::extract('Example text [email protected]', '([a-z][email protected])');
// null

Email::extract('Example text [email protected], [email protected]');
/**
* [
*     0 => '[email protected]',
*     1 => '[email protected]'
* ]
*/

Email::extract('Example text [email protected], [email protected]', '([a-z][email protected])');
/**
* [
*     0 => '[email protected]'
* ]
*/
bash
phpunit PATH/TO/PROJECT/tests/
bash
phpunit --configuration PATH/TO/PROJECT/phpunit.xml