Completed
Push — master ( 20d8fe...40dd32 )
by Harald
09:20 queued 04:54
created

email::execute()   B

Complexity

Conditions 8
Paths 4

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 8
eloc 9
nc 4
nop 2
dl 0
loc 18
rs 7.7777
c 0
b 0
f 0
1
<?php
2
/**
3
  * osCommerce Online Merchant
4
  *
5
  * @copyright (c) 2016 osCommerce; https://www.oscommerce.com
6
  * @license GPL; https://www.oscommerce.com/gpllicense.txt
7
  */
8
9
namespace OSC\OM\Is;
10
11
class email
12
{
13
    public static function execute($email, $disable_dns_check = false)
14
    {
15
        $email = trim($email);
16
17
        if (!empty($email) && (strlen($email) <= 255) && filter_var($email, FILTER_VALIDATE_EMAIL)) {
18
            if (($disable_dns_check === false) && (ENTRY_EMAIL_ADDRESS_CHECK == 'true')) {
19
                $domain = explode('@', $email);
20
21
                if (!checkdnsrr($domain[1], 'MX') && !checkdnsrr($domain[1], 'A')) {
22
                    return false;
23
                }
24
            }
25
26
            return true;
27
        }
28
29
        return false;
30
    }
31
}
32