Completed
Push — master ( c5d87a...35c5f2 )
by Rudi
03:52
created

Vector::increaseCapacityWhenFull()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
nc 2
cc 2
eloc 4
nop 0
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
    protected function increaseCapacityWhenFull()
21
    {
22
        $size = count($this);
23
24
        if ($size > $this->capacity) {
25
            $this->capacity = max(intval($this->capacity * 1.5), $size);
26
        }
27
    }
28
}
29