Passed
Branch 0.3.0 (b16461)
by Anton
03:42
created

Id   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A statement() 0 4 2
A cast() 0 4 4
1
<?php
2
3
namespace Modules\Entitizer\Utils\Definition\Item\Param {
4
5
	use Modules\Entitizer\Utils\Definition;
6
7
	class Id extends Definition\Item\Param {
8
9
		protected $auto_increment = true;
10
11
		# Constructor
12
13
		public function __construct(bool $auto_increment = true) {
14
15
			$this->name = 'id'; $this->auto_increment = $auto_increment;
16
		}
17
18
		# Get statement
19
20
		public function statement() {
21
22
			return ("`" . $this->name . "` int(10) UNSIGNED NOT NULL" . ($this->auto_increment ? " AUTO_INCREMENT" : ""));
23
		}
24
25
		# Cast value
26
27
		public function cast($value = null) {
28
29
			return (((null !== $value) && is_scalar($value) && (($value = intval($value)) >= 0)) ? $value : 0);
30
		}
31
	}
32
}
33