Completed
Push — master ( 77ad63...c6d6d5 )
by Jeroen De
01:44
created

ParameterTypes   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 32
ccs 2
cts 4
cp 0.5
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getCoreTypes() 0 28 2
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace ParamProcessor;
6
7
use ParamProcessor\Definition\DimensionParam;
8
use ParamProcessor\Definition\StringParam;
9
use ValueParsers\BoolParser;
10
use ValueParsers\FloatParser;
11
use ValueParsers\IntParser;
12
use ValueValidators\DimensionValidator;
13
use ValueValidators\RangeValidator;
14
use ValueValidators\StringValidator;
15
16
/**
17
 * @licence GNU GPL v2+
18
 * @author Jeroen De Dauw < [email protected] >
19
 */
20
class ParameterTypes {
21
22 20
	public static function getCoreTypes(): array {
23
		return [
24
			'boolean' => [
25
				'string-parser' => BoolParser::class,
26
				'validation-callback' => 'is_bool',
27
			],
28
			'float' => [
29
				'string-parser' => FloatParser::class,
30
				'validation-callback' => function( $value ) {
31 20
					return is_float( $value ) || is_int( $value );
32
				},
33
				'validator' => RangeValidator::class,
34
			],
35
			'integer' => [
36
				'string-parser' => IntParser::class,
37
				'validation-callback' => 'is_int',
38
				'validator' => RangeValidator::class,
39
			],
40
			'string' => [
41
				'validator' => StringValidator::class,
42
				'definition' => StringParam::class,
43
			],
44
			'dimension' => [
45
				'definition' => DimensionParam::class,
46
				'validator' => DimensionValidator::class,
47
			],
48
		];
49
	}
50
51
}
52