Passed
Push — 1.x ( a81357...387986 )
by Ulises Jeremias
02:45
created

ImmutableArray::insert()   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 2
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\Sequenceable as SequenceableInterface;
12
use Mbh\Collection\Exceptions\ImmutableException;
13
14
/**
15
 * The Immutable Array
16
 *
17
 * This provides special methods for quickly creating an immutable array,
18
 * either from any Traversable, or using a C-optimized fromArray() to directly
19
 * instantiate from. Also includes methods fundamental to functional
20
 * programming, e.g. map, filter, join, and sort.
21
 *
22
 * @package structures
23
 * @author Ulises Jeremias Cornejo Fandos <[email protected]>
24
 */
25
26
class ImmutableArray extends FixedArray
27
{
28
    /**
29
    * @inheritDoc
30
    */
31
    public function clear()
32
    {
33
        throw ImmutableException::cannotModify(__CLASS__, __METHOD__);
34
    }
35
36
    /**
37
     * @inheritDoc
38
     */
39
    public function insert(int $index, ...$values)
40
    {
41
        throw ImmutableException::cannotModify(__CLASS__, __METHOD__);
42
    }
43
44
    /**
45
     * @inheritDoc
46
     */
47
    public function offsetSet($offset, $value)
48
    {
49
        throw ImmutableException::cannotModify(__CLASS__, __METHOD__);
50
    }
51
52
    /**
53
     * @inheritDoc
54
     */
55
    public function offsetUnset($offset)
56
    {
57
        throw ImmutableException::cannotModify(__CLASS__, __METHOD__);
58
    }
59
60
    /**
61
     * @inheritDoc
62
     */
63
    public function pop()
64
    {
65
        throw ImmutableException::cannotModify(__CLASS__, __METHOD__);
66
    }
67
68
    /**
69
     * @inheritDoc
70
     */
71
    public function push(...$values)
72
    {
73
        throw ImmutableException::cannotModify(__CLASS__, __METHOD__);
74
    }
75
76
    /**
77
     * @inheritDoc
78
     */
79
    public function remove(int $index)
80
    {
81
        throw ImmutableException::cannotModify(__CLASS__, __METHOD__);
82
    }
83
84
    /**
85
    * @inheritDoc
86
    */
87
    public function set(int $index, $value)
88
    {
89
        throw ImmutableException::cannotModify(__CLASS__, __METHOD__);
90
    }
91
92
    /**
93
     * @inheritDoc
94
     */
95
    public function shift()
96
    {
97
        throw ImmutableException::cannotModify(__CLASS__, __METHOD__);
98
    }
99
100
    /**
101
    * @inheritDoc
102
    */
103
    public function sort(callable $callback = null): SequenceableInterface
104
    {
105
        throw ImmutableException::cannotModify(__CLASS__, __METHOD__);
106
    }
107
108
    public function unserialize($values)
109
    {
110
        throw ImmutableException::cannotModify(__CLASS__, __METHOD__);
111
    }
112
113
    /**
114
     * @inheritDoc
115
     */
116
    public function unshift(...$values)
117
    {
118
        throw ImmutableException::cannotModify(__CLASS__, __METHOD__);
119
    }
120
}
121