BaseSet::remove()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 10
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
/*
3
 * This file is part of Yolk - Gamer Network's PHP Framework.
4
 *
5
 * Copyright (c) 2015 Gamer Network Ltd.
6
 *
7
 * Distributed under the MIT License, a copy of which is available in the
8
 * LICENSE file that was bundled with this package, or online at:
9
 * https://github.com/gamernetwork/yolk-support
10
 */
11
12
namespace yolk\support\collections;
13
14
use yolk\contracts\support\collections\Set;
15
16
/**
17
 * Basic set implementation.
18
 */
19
class BaseSet extends BaseCollection implements Set {
20
21
	public function add( $item ) {
22
23
		$new = !$this->contains($item);
24
25
		if( $new )
26
			$this->items[] = $item;
27
28
		return $new;
29
	}
30
31
	public function remove( $item ) {
32
33
		$key = array_search($item, $this->items);
34
35
		if( $key !== false )
36
			unset($this->items[$key]);
37
38
		return $key !== false;
39
40
	}
41
42
}
43
44
// EOF