Passed
Push — 1.x ( bace11...65e39f )
by Ulises Jeremias
02:35
created

ImmutableArray   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 20
rs 10
c 1
b 0
f 1
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A offsetUnset() 0 3 1
A offsetSet() 0 3 1
A clear() 0 3 1
A sort() 0 3 1
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 RuntimeException;
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
    public function sort(callable $callback = null): SequenceableInterface
29
    {
30
        throw new RuntimeException('Attempt to mutate immutable ' . __CLASS__ . ' object.');
31
    }
32
33
    public function offsetSet($offset, $value)
34
    {
35
        throw new RuntimeException('Attempt to mutate immutable ' . __CLASS__ . ' object.');
36
    }
37
38
    public function offsetUnset($offset)
39
    {
40
        throw new RuntimeException('Attempt to mutate immutable ' . __CLASS__ . ' object.');
41
    }
42
43
    public function clear()
44
    {
45
        throw new RuntimeException('Attempt to mutate immutable ' . __CLASS__ . ' object.');
46
    }
47
}
48