GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

SplArrayStack::isEmpty()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
/**
3
 * This file is part of the O2System Framework package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @author         Steeve Andrian Salim
9
 * @copyright      Copyright (c) Steeve Andrian Salim
10
 */
11
12
// ------------------------------------------------------------------------
13
14
namespace O2System\Spl\DataStructures;
15
16
// ------------------------------------------------------------------------
17
18
use O2System\Spl\Interfaces\SplArrayInterface;
19
20
/**
21
 * Class SplArrayStack
22
 *
23
 * The SplStack class provides the main functionalities of a stack implemented using a doubly linked list and
24
 * the iterator mode is based on LIFO (Last In First Out).
25
 *
26
 * @package O2System\Spl\DataStructures
27
 */
28
class SplArrayStack extends \SplStack implements SplArrayInterface
29
{
30
    /**
31
     * SplArrayStack::__construct
32
     *
33
     * @param array $stack
34
     */
35
    public function __construct(array $stack = [])
36
    {
37
        if (count($stack)) {
38
            foreach ($stack as $item) {
39
                $this->push($item);
40
            }
41
        }
42
    }
43
44
    // -----------------------------------------------------------------------
45
46
    /**
47
     * SplArrayStack::isEmpty
48
     *
49
     * Checks if the array storage is empty.
50
     *
51
     * @return bool
52
     */
53
    public function isEmpty()
54
    {
55
        return ($this->count() == 0 ? true : false);
56
    }
57
58
    // -----------------------------------------------------------------------
59
60
    /**
61
     * SplArrayStack::has
62
     *
63
     * Checks if a value exists in the storage.
64
     *
65
     * @param mixed $needle The searched value.
66
     * @param bool  $strict If the third parameter strict is set to TRUE then the in_array() function will also check
67
     *                      the types of the needle in the haystack.
68
     *
69
     * @return bool
70
     */
71
    public function has($needle, $strict = false)
72
    {
73
        return in_array($needle, $this->getArrayCopy(), $strict);
74
    }
75
76
    // -----------------------------------------------------------------------
77
78
    /**
79
     * SplArrayStack::getArrayCopy
80
     *
81
     * Creates a copy of the storage.
82
     *
83
     * @return array A copy of the storage.
84
     */
85
    public function getArrayCopy()
86
    {
87
        $arrayCopy = [];
88
89
        for ($this->rewind(); $this->valid(); $this->next()) {
90
            $arrayCopy[] = $this->current();
91
        }
92
93
        return $arrayCopy;
94
    }
95
}