EdgeSet::remove()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Graphp\Edge;
4
5
use ArrayObject;
6
7
/**
8
 * Class EdgeSet
9
 *
10
 * @package Graphp\Edge
11
 */
12
class EdgeSet extends ArrayObject
13
{
14
    /**
15
     * Construct a set of edges
16
     *
17
     * @param array $input - array of edges
18
     */
19 48
    public function __construct(array $input = [])
20
    {
21 48
        parent::__construct($input, ArrayObject::ARRAY_AS_PROPS);
22 48
    }
23
    
24
    /**
25
     * Check if the set contains the edge
26
     *
27
     * @param EdgeInterface $edge - niddle
28
     */
29 31
    public function contains(EdgeInterface $edge): bool
30
    {
31 31
        return in_array($edge, $this->getArrayCopy());
32
    }
33
    
34
    /**
35
     * Remove the edge from the set
36
     *
37
     * @param EdgeInterface $edge - niddle
38
     */
39 3
    public function remove(EdgeInterface $edge): void
40
    {
41 3
        if (($id = array_search($edge, $this->getArrayCopy())) !== false) {
42 3
            unset($this[$id]);
43
        }
44 3
    }
45
}
46