Passed
Push — 1.x ( 52a2d2...558ce0 )
by Ulises Jeremias
02:27
created

FixedArray::getGrowthFactor()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php namespace Mbh\Collection;
2
3
/**
4
 * MBHFramework
5
 *
6
 * @link      https://github.com/MBHFramework/mbh-framework
7
 * @copyright Copyright (c) 2017 Ulises Jeremias Cornejo Fandos
8
 * @license   https://github.com/MBHFramework/mbh-framework/blob/master/LICENSE (MIT License)
9
 */
10
11
use Mbh\Collection\Interfaces\Collection as CollectionInterface;
12
use Mbh\Collection\Interfaces\Sequenceable as SequenceableInterface;
13
use Mbh\Collection\CallbackHeap;
14
use Mbh\Iterator\SliceIterator;
15
use Mbh\Iterator\ConcatIterator;
16
use SplFixedArray;
17
use SplHeap;
18
use SplStack;
19
use LimitIterator;
20
use Iterator;
21
use ArrayAccess;
22
use Countable;
23
use CallbackFilterIterator;
24
use JsonSerializable;
25
use RuntimeException;
26
use Traversable;
27
use ReflectionClass;
28
29
/**
30
 * The Fixed Array
31
 *
32
 * A FixedArray is a sequence of values in a contiguous buffer that grows and
33
 * shrinks automatically. It’s the most efficient sequential structure because
34
 * a value’s index is a direct mapping to its index in the buffer, and the
35
 * growth factor isn't bound to a specific multiple or exponent.
36
 *
37
 * @package structures
38
 * @author Ulises Jeremias Cornejo Fandos <[email protected]>
39
 */
40
41
class FixedArray implements SequenceableInterface
42
{
43
    use Traits\Collection;
44
    use Traits\Sequenceable;
45
    use Traits\Functional;
46
    use Traits\Capacity;
47
48
    const MIN_CAPACITY = 8;
49
50
    /**
51
     * @inheritDoc
52
     */
53
    protected function getGrowthFactor(): float
54
    {
55
        return 1.5;
56
    }
57
58
    /**
59
     * @inheritDoc
60
     */
61
    protected function shouldIncreaseCapacity(): bool
62
    {
63
        return count($this) > $this->capacity;
64
    }
65
}
66