Completed
Pull Request — develop (#716)
by Agel_Nash
06:45 queued 44s
created

Event   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 87
rs 10
c 0
b 0
f 0
wmc 11
lcom 1
cbo 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
B alert() 0 14 5
A output() 0 4 1
A setOutput() 0 4 1
A getOutput() 0 4 1
A stopPropagation() 0 4 1
A _resetEventObject() 0 8 1
1
<?php namespace EvolutionCMS;
2
3
class Event implements Interfaces\EventInterface
0 ignored issues
show
Coding Style introduced by
The property $_propagate is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
Coding Style introduced by
The property $_output is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
4
{
5
    public $name = '';
6
    public $_propagate = true;
7
    /**
8
     * @deprecated use setOutput(), getOutput()
9
     * @var string
10
     */
11
    public $_output;
12
    public $activated = false;
13
    public $activePlugin = '';
14
    public $params = array();
15
16
    /**
17
     * @param string $name Name of the event
18
     */
19
    public function __construct($name = "")
20
    {
21
        $this->_resetEventObject();
22
        $this->name = $name;
23
    }
24
25
    /**
26
     * Display a message to the user
27
     *
28
     * @global array $SystemAlertMsgQueque
29
     * @param string $msg The message
30
     */
31
    public function alert($msg)
32
    {
33
        global $SystemAlertMsgQueque;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
34
        if ($msg == "") {
35
            return;
36
        }
37
        if (is_array($SystemAlertMsgQueque)) {
38
            $title = '';
39
            if ($this->name && $this->activePlugin) {
40
                $title = "<div><b>" . $this->activePlugin . "</b> - <span style='color:maroon;'>" . $this->name . "</span></div>";
41
            }
42
            $SystemAlertMsgQueque[] = "$title<div style='margin-left:10px;margin-top:3px;'>$msg</div>";
43
        }
44
    }
45
46
    /**
47
     * Output
48
     *
49
     * @param string $msg
50
     * @deprecated see addOutput
51
     */
52
    public function output($msg)
53
    {
54
        $this->_output .= $msg;
0 ignored issues
show
Deprecated Code introduced by
The property EvolutionCMS\Event::$_output has been deprecated with message: use setOutput(), getOutput()

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
55
    }
56
57
    /**
58
     * @param mixed $data
59
     */
60
    public function setOutput($data)
61
    {
62
        $this->_output = $data;
0 ignored issues
show
Deprecated Code introduced by
The property EvolutionCMS\Event::$_output has been deprecated with message: use setOutput(), getOutput()

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
63
    }
64
65
    /**
66
     * @return mixed
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use string.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
67
     */
68
    public function getOutput()
69
    {
70
        return $this->_output;
0 ignored issues
show
Deprecated Code introduced by
The property EvolutionCMS\Event::$_output has been deprecated with message: use setOutput(), getOutput()

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
71
    }
72
73
    /**
74
     * Stop event propogation
75
     */
76
    public function stopPropagation()
77
    {
78
        $this->_propagate = false;
79
    }
80
81
    public function _resetEventObject()
82
    {
83
        unset ($this->returnedValues);
84
        $this->name = "";
85
        $this->setOutput(null);
86
        $this->_propagate = true;
87
        $this->activated = false;
88
    }
89
}
90