for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Email
*
* Send messages via Email services.
* @package core
* @author [email protected]
* @copyright Caffeina srl - 2015 - http://caffeina.it
*/
class Email {
use Module;
protected static $driver,
$options,
$driver_name;
protected static function instance(){
return static::$driver;
}
public static function using($driver, $options = null){
$class = '\\Email\\'.ucfirst(strtolower($driver));
if ( ! class_exists($class) ) throw new \Exception("[Core.Email] : $driver driver not found.");
static::$driver_name = $driver;
static::$options = $options;
static::$driver = new $class($options);
public static function clear(){
static::using( static::$driver_name, static::$options );
public static function send(array $options){
$mail = static::instance();
$options = array_merge([
$options
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
$myVar = 'Value'; $higher = false; if (rand(1, 6) > 3) { $higher = true; } else { $higher = false; }
Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.
$myVar
$higher
'to' => false,
'from' => false,
'replyTo' => false,
'subject' => false,
'message' => false,
'attachments' => [],
],$options);
return $mail->send(new Envelope($option));
$option
This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.
The variable may have been renamed without also renaming all references.
Email::using('native');
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.