BaseDictionary::keys()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
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\Dictionary;
15
16
/**
17
 * Basic dictionary implementation.
18
 */
19
class BaseDictionary extends BaseCollection implements Dictionary {
20
21
	public function has( $key ) {
22
		return array_key_exists($key, $this->items);
23
	}
24
25
	public function get( $key, $default = null ) {
26
		return isset($this->items[$key]) ? $this->items[$key] : $default;
27
	}
28
29
	public function set( $key, $item ) {
30
31
		$current = $this->get($key);
32
33
		$this->items[$key] = $item;
34
35
		return $current;
36
37
	}
38
39
	public function remove( $key ) {
40
		$current = $this->get($key);
41
		unset($this->items[$key]);
42
		return $current;
43
	}
44
45
	public function keys() {
46
		return array_keys($this->items);
47
	}
48
49
50
}
51
52
// EOF