GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( b39c41...650c48 )
by Hong
03:19
created

EventPrototypeTrait::newEvent()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 18
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 18
rs 9.4285
cc 3
eloc 14
nc 3
nop 3
1
<?php
2
/**
3
 * Phossa Project
4
 *
5
 * PHP version 5.4
6
 *
7
 * @category  Library
8
 * @package   Phossa2\Event
9
 * @copyright Copyright (c) 2016 phossa.com
10
 * @license   http://mit-license.org/ MIT License
11
 * @link      http://www.phossa.com/
12
 */
13
/*# declare(strict_types=1); */
14
15
namespace Phossa2\Event\Traits;
16
17
use Phossa2\Event\Event;
18
use Phossa2\Event\Interfaces\EventInterface;
19
20
/**
21
 * EventPrototypeTrait
22
 *
23
 * Injecting a event prototype for creating new ones
24
 *
25
 * @package Phossa2\Event
26
 * @author  Hong Zhang <[email protected]>
27
 * @version 2.1.1
28
 * @since   2.1.1 added
29
 */
30
trait EventPrototypeTrait
31
{
32
    /**
33
     * event prototype
34
     *
35
     * @var    EventInterface
36
     * @access protected
37
     */
38
    protected $event_proto;
39
40
    /**
41
     * {@inheritDoc}
42
     */
43
    public function setEventPrototype(EventInterface $eventPrototype = null)
44
    {
45
        $this->event_proto = $eventPrototype;
46
        return $this;
47
    }
48
49
    /**
50
     * Create an event
51
     *
52
     * @param  string|EventInterface $event
53
     * @param  mixed $target
54
     * @param  array $parameters
55
     * @return EventInterface
56
     * @access protected
57
     */
58
    protected function newEvent(
59
        $event,
60
        $target = null,
61
        array $parameters = []
62
    )/*# : EventInterface */ {
63
        if (is_object($event)) {
64
            return $event;
65
        } elseif (is_null($this->event_proto)) {
66
            return new Event($event, $target, $parameters);
67
        } else {
68
            // clone the prototype
69
            $evt = clone $this->event_proto;
70
            $evt->setName($event);
71
            $evt->setTarget($target);
72
            $evt->setParams($parameters);
73
            return $evt;
74
        }
75
    }
76
}
77