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

Vector::increaseCapacity()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
crap 2
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