Completed
Push — master ( 635aa4...d2c914 )
by Tomáš
02:02
created

Base::setId()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 6
ccs 5
cts 5
cp 1
crap 3
rs 10
1
<?php
2
3
namespace TournamentGenerator;
4
5
/**
6
 *
7
 */
8
class Base
9
{
10
11
	private $name = '';
12
	private $id = 'null';
13
14 24
	public function __toString() {
15 24
		return $this->name;
16
	}
17
18 107
	public function setName(string $name) {
19 107
		$this->name = $name;
20 107
	}
21 13
	public function getName() {
22 13
		return $this->name;
23
	}
24 107
	public function setId($id) {
25 107
		if (!is_string($id) && !is_int($id)) {
26 3
			$this->id = uniqid();
27 3
			throw new \Exception('Unsupported id type ('.gettype($id).') - expected type of string or int');
28
		}
29 107
		$this->id = $id;
30 107
	}
31 83
	public function getId() {
32 83
		return $this->id;
33
	}
34
35
}
36