Completed
Pull Request — 2.0 (#75)
by Julien
02:32
created

SendNotificationTrait   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 30
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
getSession() 0 1 ?
A sendNotification() 0 10 1
1
<?php
2
/*
3
 * This file is part of the Pomm's Foundation package.
4
 *
5
 * (c) 2014 - 2015 Grégoire HUBERT <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace PommProject\Foundation\Listener;
11
12
/**
13
 * SendNotificationTrait
14
 *
15
 * Trait to add sendNotification method to clients.
16
 *
17
 * @package     Foundation
18
 * @copyright   2014 - 2015 Grégoire HUBERT
19
 * @author      Grégoire HUBERT
20
 * @license     X11 {@link http://opensource.org/licenses/mit-license.php}
21
 */
22
trait SendNotificationTrait
23
{
24
    /**
25
     * getSession
26
     *
27
     * sendNotification needs to access the session.
28
     */
29
    abstract protected function getSession();
30
31
    /**
32
     * sendNotification
33
     *
34
     * Send notification to the listener pooler.
35
     *
36
     * @access protected
37
     * @param  string $name
38
     * @param  array $data
39
     * @return mixed $this
40
     */
41
    protected function sendNotification($name, array $data)
42
    {
43
        $this
44
            ->getSession()
45
            ->getPoolerForType('listener')
46
            ->notify($name, $data)
47
            ;
48
49
        return $this;
50
    }
51
}
52