Proxy::onInit()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Email\Proxy
5
 *
6
 * Simple proxy driver. It pass all emails to an event
7
 *
8
 * @package core
9
 * @author [email protected]
10
 * @copyright Caffeina srl - 2016 - http://caffeina.com
11
 */
12
13
namespace Email;
14
15
class Proxy implements Driver {
16
17
  protected $listener = 'core.email.proxy.send';
18
19
  public function onInit($options){
20
    if (!empty($options['hook'])) $this->listener = $options['hook'];
21
  }
22
23
  public function onSend(Envelope $envelope){
24
    return array_reduce( (array) \Event::trigger($this->listener, $envelope), function($carry, $item) {
25
    	 if (is_bool($item)) $carry[] = $item;
26
    	 return $carry;
27
    }, []);
28
  }
29
30
}
31
32