BaseSet   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 9 2
A remove() 0 10 2
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