Completed
Push — master ( 4b2870...b9812c )
by Cheren
02:31
created

Event   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 33
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A data() 0 4 1
1
<?php
2
/**
3
 * CakeCMS Core
4
 *
5
 * This file is part of the of the simple cms based on CakePHP 3.
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 *
9
 * @package   Core
10
 * @license   MIT
11
 * @copyright MIT License http://www.opensource.org/licenses/mit-license.php
12
 * @link      https://github.com/CakeCMS/Core".
13
 * @author    Sergey Kalistratov <[email protected]>
14
 */
15
16
namespace Core\Event;
17
18
use Cake\Event\Event as CakeEvent;
19
20
use JBZoo\Data\Data;
21
22
/**
23
 * Class Event
24
 *
25
 * @package Core\Event
26
 */
27
class Event extends CakeEvent
28
{
29
30
    /**
31
     * Custom data for the method that receives the event
32
     *
33
     * @var Data
34
     */
35
    public $data;
36
37
    /**
38
     * Event constructor.
39
     *
40
     * @param string $name
41
     * @param null|string $subject
42
     * @param null|array $data
43
     */
44
    public function __construct($name, $subject = null, $data = null)
45
    {
46
        parent::__construct($name, $subject, $data);
0 ignored issues
show
Bug introduced by
It seems like $subject defined by parameter $subject on line 44 can also be of type string; however, Cake\Event\Event::__construct() does only seem to accept object|null, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
47
        $this->data = new Data($data);
0 ignored issues
show
Bug introduced by
It seems like $data defined by parameter $data on line 44 can also be of type null; however, JBZoo\Data\Data::__construct() does only seem to accept array|string, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
48
    }
49
50
    /**
51
     * Access the event data/payload.
52
     *
53
     * @return array
54
     */
55
    public function data()
56
    {
57
        return $this->data->getArrayCopy();
58
    }
59
}
60