Test Failed
Push — master ( 322858...27bed3 )
by Rudi
03:26
created

Vector   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 21
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getGrowthFactor() 0 4 1
A shouldIncreaseCapacity() 0 4 1
1
<?php
2
namespace Ds;
3
4
/**
5
 * A Vector is a sequence of values in a contiguous buffer that grows and
6
 * shrinks automatically. It’s the most efficient sequential structure because
7
 * a value’s index is a direct mapping to its index in the buffer, and the
8
 * growth factor isn't bound to a specific multiple or exponent.
9
 *
10
 * @package Ds
11
 */
12
final class Vector implements \IteratorAggregate, \ArrayAccess, Sequence
13
{
14
    use Traits\GenericCollection;
15
    use Traits\GenericSequence;
16
    use Traits\Capacity;
17
18
    const MIN_CAPACITY = 8;
19
20
    protected function getGrowthFactor(): float
21
    {
22
        return 1.5;
23 86
    }
24
25 86
    /**
26
     * @return whether capacity should be increased.
0 ignored issues
show
Documentation introduced by
Should the return type not be boolean?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
27 86
     */
28 56
    protected function shouldIncreaseCapacity(): bool
29
    {
30 86
        return count($this) > $this->capacity;
31
    }
32
}
33