Passed
Pull Request — master (#10)
by Anton
04:10
created

Index   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getType() 0 6 2
A __construct() 0 6 2
A statement() 0 6 2
1
<?php
2
3
namespace Modules\Entitizer\Utils\Definition\Item {
4
5
	use Modules\Entitizer\Utils\Definition;
6
7
	class Index extends Definition\Item {
8
9
		protected $type = null;
10
11
		# Get type
12
13
		private function getType(string $value) {
14
15
			$value = strtoupper($value); $range = ['PRIMARY', 'UNIQUE', 'FULLTEXT'];
16
17
			return (in_array($value, $range, true) ? $value : null);
18
		}
19
20
		# Constructor
21
22
		public function __construct(string $name, string $type = null) {
23
24
			$this->name = $name;
25
26
			if (null !== $type) $this->type = $this->getType($type);
27
		}
28
29
		# Get statement
30
31
		public function statement() {
32
33
			return ((null !== $this->type) ? ($this->type . " ") : "") .
34
35
			       ("KEY `" . $this->name . "` (`" . $this->name . "`)");
36
		}
37
	}
38
}
39