Completed
Push — master ( b6ba98...5eb9ae )
by Stefano
02:30
created

Email::send()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 14
rs 9.4285
cc 1
eloc 11
nc 1
nop 1
1
<?php
2
3
/**
4
 * Email
5
 *
6
 * Send messages via Email services.
7
 *
8
 * @package core
9
 * @author [email protected]
10
 * @copyright Caffeina srl - 2015 - http://caffeina.it
11
 */
12
13
class Email {
14
  use Module;
15
16
  protected static $driver,
17
                   $options,
18
                   $driver_name;
19
20
  protected static function instance(){
21
    return static::$driver;
22
  }
23
24
  public static function using($driver, $options = null){
25
    $class = '\\Email\\'.ucfirst(strtolower($driver));
26
    if ( ! class_exists($class) ) throw new \Exception("[Core.Email] : $driver driver not found.");
27
    static::$driver_name = $driver;
28
    static::$options = $options;
29
    static::$driver = new $class($options);
30
  }
31
32
  public static function clear(){
33
    static::using( static::$driver_name, static::$options );
34
  }
35
36
  public static function send(array $options){
37
    $mail = static::instance();
38
39
    $options = array_merge([
0 ignored issues
show
Unused Code introduced by
$options is not used, you could remove the assignment.

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.

Loading history...
40
      'to'          => false,
41
      'from'        => false,
42
      'replyTo'     => false,
43
      'subject'     => false,
44
      'message'     => false,
45
      'attachments' => [],
46
    ],$options);
47
48
    return $mail->send(new Envelope($option));
0 ignored issues
show
Bug introduced by
The variable $option does not exist. Did you mean $options?

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.

Loading history...
49
  }
50
51
}
52
53
Email::using('native');
54