Passed
Pull Request — develop (#912)
by Shandak
05:39
created

RHelperDispatcher::trigger()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
/**
3
 * @package     Redcore
4
 * @subpackage  Helper
5
 *
6
 * @copyright   Copyright (C) 2008 - 2020 redWEB.dk. All rights reserved.
7
 * @license     GNU General Public License version 2 or later, see LICENSE.
8
 */
9
10
use Joomla\CMS\Factory;
0 ignored issues
show
Bug introduced by
The type Joomla\CMS\Factory was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
12
defined('JPATH_REDCORE') or die;
13
14
/**
15
 * dispatcher adpater for J4
16
 *
17
 * @package     Redcore
18
 * @subpackage  Helper
19
 * @since       __deploy_version__
20
 */
21
final class RHelperDispatcher
22
{
23
	/**
24
	 * Stores the singleton instance of the dispatcher.
25
	 *
26
	 * @var    RHelperDispatcher
27
	 * @since  __deploy_version__
28
	 */
29
	protected static $instance = null;
30
31
	/**
32
	 * Returns the global Event Dispatcher object, only creating it
33
	 * if it doesn't already exist.
34
	 *
35
	 * @return  RHelperDispatcher  The EventDispatcher object.
36
	 *
37
	 * @since  __deploy_version__
38
	 */
39
	public static function getInstance()
40
	{
41
		if (self::$instance === null)
42
		{
43
			self::$instance = new static;
44
		}
45
46
		return self::$instance;
47
	}
48
49
	/**
50
	 * Triggers an event by dispatching arguments to all observers that handle
51
	 * the event and returning their return values.
52
	 *
53
	 * @param   string  $event  The event to trigger.
54
	 * @param   array   $args   An array of arguments.
55
	 *
56
	 * @return  array  An array of results from each function call.
57
	 *
58
	 * @since   __deploy_version__
59
	 */
60
	public function trigger($event, $args = array())
61
	{
62
		return Factory::getApplication()->triggerEvent($event, $args);
63
	}
64
}