AbstractSet::isEmpty()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the bisarca/robots-txt package.
5
 *
6
 * (c) Emanuele Minotto <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Bisarca\RobotsTxt;
13
14
use ArrayIterator;
15
use Countable;
16
use IteratorAggregate;
17
use Traversable;
18
19
/**
20
 * Abstract set of utilities for internal sets.
21
 */
22
abstract class AbstractSet implements Countable, IteratorAggregate
23
{
24
    /**
25
     * Contained elements.
26
     *
27
     * @var array
28
     */
29
    protected $data = [];
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function getIterator(): Traversable
35
    {
36
        return new ArrayIterator($this->data);
37
    }
38
39
    /**
40
     * Remove all contained elements.
41
     */
42
    public function clear()
43
    {
44
        $this->data = [];
45
    }
46
47
    /**
48
     * Checks if no elements are contained.
49
     *
50
     * @return bool
51
     */
52
    public function isEmpty(): bool
53
    {
54
        return empty($this->data);
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60
    public function count(): int
61
    {
62
        return count($this->data);
63
    }
64
}
65