Completed
Push — master ( 703410...c5e5be )
by Marcus
09:24
created

PHPMailerAutoload.php ➔ PHPMailerAutoload()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 2
rs 9.4285
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 24 and the first side effect is on line 36.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * PHPMailer SPL autoloader.
4
 * PHP Version 5
5
 * @package PHPMailer
6
 * @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
7
 * @author Marcus Bointon (Synchro/coolbru) <[email protected]>
8
 * @author Jim Jagielski (jimjag) <[email protected]>
9
 * @author Andy Prevost (codeworxtech) <[email protected]>
10
 * @author Brent R. Matzelle (original founder)
11
 * @copyright 2012 - 2014 Marcus Bointon
12
 * @copyright 2010 - 2012 Jim Jagielski
13
 * @copyright 2004 - 2009 Andy Prevost
14
 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
15
 * @note This program is distributed in the hope that it will be useful - WITHOUT
16
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17
 * FITNESS FOR A PARTICULAR PURPOSE.
18
 */
19
20
/**
21
 * PHPMailer SPL autoloader.
22
 * @param string $classname The name of the class to load
23
 */
24
function PHPMailerAutoload($classname)
25
{
26
    //Can't use __DIR__ as it's only in PHP 5.3+
27 3
    $filename = dirname(__FILE__).DIRECTORY_SEPARATOR.'class.'.strtolower($classname).'.php';
28 3
    if (is_readable($filename)) {
29 3
        require $filename;
30 3
    }
31 3
}
32
33
if (version_compare(PHP_VERSION, '5.1.2', '>=')) {
34
    //SPL autoloading was introduced in PHP 5.1.2
35
    if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
36
        spl_autoload_register('PHPMailerAutoload', true, true);
37
    } else {
38
        spl_autoload_register('PHPMailerAutoload');
39
    }
40
} else {
41
    /**
42
     * Fall back to traditional autoload for old PHP versions
43
     * @param string $classname The name of the class to load
44
     */
45
    function __autoload($classname)
46
    {
47
        PHPMailerAutoload($classname);
48
    }
49
}
50