Completed
Push — master ( 7c623d...b84c7d )
by Siro Díaz
01:29
created

ListAbstract   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 30
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A count() 0 3 1
A size() 0 3 1
A empty() 0 3 1
1
<?php
2
3
namespace DataStructures\Lists;
4
5
use DataStructures\Lists\Interfaces\ListInterface;
6
7
abstract class ListAbstract implements ListInterface {
8
    protected $size;
9
10
    /**
11
     * Binds to count() method. This is equal to make $this->tree->size().
12
     *
13
     * @return integer the tree size. 0 if it is empty.
14
     */
15
    public function count() {
16
        return $this->size;
17
    }
18
19
    /**
20
     * Returns the array size.
21
     *
22
     * @return int the length
23
     */
24
    public function size() : int {
25
        return $this->size;
26
    }
27
28
    /**
29
     * Checks if the list is empty.
30
     *
31
     * @return boolean true if is empty, else false.
32
     */
33
    public function empty() : bool {
34
        return $this->size === 0;
35
    }
36
}