SetManager   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 6
c 2
b 0
f 2
lcom 0
cbo 1
dl 0
loc 41
ccs 17
cts 17
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 14 3
A remove() 0 11 3
1
<?php
2
3
namespace Accessible\MethodManager;
4
5
class SetManager extends CollectionManager
6
{
7
    /**
8
     * Adds an element to the set if it is not already present.
9
     *
10
     * @param array|Traversable $set
11
     * @param array $args
12
     */
13 4
    public static function add(&$set, $args)
14
    {
15 4
        self::assertArgsNumber(1, $args);
16
17 4
        $value = $args[0];
18
19 4
        foreach ($set as $item) {
20 4
            if ($item === $value) {
21 1
                return;
22
            }
23 4
        }
24
25 4
        $set[] = $value;
26 4
    }
27
28
    /**
29
     * Removes an element from the set.
30
     *
31
     * @param  array|Traversable $set
32
     * @param  array $args
33
     */
34 4
    public static function remove(&$set, $args)
35
    {
36 4
        self::assertArgsNumber(1, $args);
37
38 4
        foreach ($set as $key => $value) {
39 4
            if ($value === $args[0]) {
40 4
                unset($set[$key]);
41 4
                return;
42
            }
43 3
        }
44 1
    }
45
}
46