AliasRegistry   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
eloc 8
c 2
b 0
f 0
dl 0
loc 30
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 3 1
A getAll() 0 2 1
A get() 0 5 2
1
<?php
2
namespace Kir\MySQL\Tools;
3
4
use RuntimeException;
5
6
class AliasRegistry {
7
	/** @var string[] */
8
	private $aliases = [];
9
10
	/**
11
	 * @param string $alias
12
	 * @param string $string
13
	 * @return $this
14
	 */
15
	public function add(string $alias, string $string) {
16
		$this->aliases[$alias] = $string;
17
		return $this;
18
	}
19
20
	/**
21
	 * @param string $alias
22
	 * @return string
23
	 */
24
	public function get(string $alias): string {
25
		if (!array_key_exists($alias, $this->aliases)) {
26
			throw new RuntimeException("Alias not found: {$alias}");
27
		}
28
		return $this->aliases[$alias];
29
	}
30
31
	/**
32
	 * @return string[]
33
	 */
34
	public function getAll(): array {
35
		return $this->aliases;
36
	}
37
}
38