Completed
Push — master ( e0916e...38b230 )
by Rudi
05:33
created

Vector::allocate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
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 increaseCapacity()
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