ModulesStack   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 36
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A push() 0 4 1
A pop() 0 4 1
A top() 0 4 2
A bottom() 0 4 2
1
<?php declare(strict_types=1);
2
3
/*
4
 * This file is part of the pinepain/js-sandbox PHP library.
5
 *
6
 * Copyright (c) 2016-2017 Bogdan Padalko <[email protected]>
7
 *
8
 * Licensed under the MIT license: http://opensource.org/licenses/MIT
9
 *
10
 * For the full copyright and license information, please view the
11
 * LICENSE file that was distributed with this source or visit
12
 * http://opensource.org/licenses/MIT
13
 */
14
15
16
namespace Pinepain\JsSandbox\Modules;
17
18
19
class ModulesStack implements ModulesStackInterface
20
{
21
    private $stack = [];
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function push(ModuleInterface $module)
27
    {
28
        $this->stack[] = $module;
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function pop(): ModuleInterface
35
    {
36
        return array_pop($this->stack);
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function top(): ?ModuleInterface
43
    {
44
        return reset($this->stack) ?: null;
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function bottom(): ?ModuleInterface
51
    {
52
        return end($this->stack) ?: null;
53
    }
54
}
55