Completed
Push — master ( 5856c5...90f7ba )
by Rudi
05:12
created

Vector::increaseCapacityWhenFull()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 7
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
crap 6
1
<?php
2
namespace Ds;
3
4
/**
5
 * Vector
6
 *
7
 * @package Ds
8
 */
9
final class Vector implements \IteratorAggregate, \ArrayAccess, Sequence
10
{
11
    use Traits\Collection;
12
    use Traits\Sequence;
13
    use Traits\Capacity;
14
15
    const MIN_CAPACITY = 10;
16
17
    /**
18
     * Increase capacity
19
     */
20 86
    protected function increaseCapacity()
21
    {
22 86
        $size = count($this);
23
24 86
        if ($size > $this->capacity) {
25 56
            $this->capacity = max(intval($this->capacity * 1.5), $size);
26
        }
27 86
    }
28
}
29