SceneManager::getScenes()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * NextFlow (http://github.com/nextflow)
4
 *
5
 * @link http://github.com/nextflow/nextflow-php for the canonical source repository
6
 * @copyright Copyright (c) 2014-2016 NextFlow (http://github.com/nextflow)
7
 * @license https://raw.github.com/nextflow/nextflow-php/master/LICENSE MIT
8
 */
9
10
namespace NextFlow\Core\Scene;
11
12
/**
13
 * A scene manager is able to handle events in multiple scenes.
14
 */
15
final class SceneManager
16
{
17
    /**
18
     * A list with all the scenes.
19
     *
20
     * @var array
21
     */
22
    private $scenes;
23
24
    /**
25
     * Initializes a new instance of the SceneManager class.
26
     */
27
    public function __construct()
28
    {
29
        $this->scenes = [];
30
    }
31
32
    /**
33
     * Adds the given scene to this manager.
34
     *
35
     * @param SceneInterface $scene The scene to add.
36
     */
37
    public function addScene(SceneInterface $scene)
38
    {
39
        $this->scenes[] = $scene;
40
    }
41
42
    /**
43
     * Gets the scenes that this scene manager has.
44
     *
45
     * @return SceneInterface[]
46
     */
47
    public function getScenes()
48
    {
49
        return $this->scenes;
50
    }
51
52
    /**
53
     * Executes the given event.
54
     *
55
     * @param string $name The name of the event to execute.
56
     * @return array
57
     */
58
    public function execute($name)
59
    {
60
        $result = [];
61
62
        foreach ($this->scenes as $scene) {
63
            $result[] = $scene->execute($name);
64
        }
65
66
        return $result;
67
    }
68
}
69