Passed
Push — master ( 761e95...f1e6ba )
by Jeroen De
05:40
created

FloatParamTest::valueProvider()   B

Complexity

Conditions 6
Paths 2

Size

Total Lines 35

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 35
rs 8.7377
c 0
b 0
f 0
cc 6
nc 2
nop 1
1
<?php
2
3
namespace ParamProcessor\Tests\Integration\Definitions;
4
5
/**
6
 * @licence GNU GPL v2+
7
 * @author Jeroen De Dauw < [email protected] >
8
 */
9
class FloatParamTest extends NumericParamTest {
10
11
	/**
12
	 * @see ParamDefinitionTest::getDefinitions
13
	 * @return array
14
	 */
15
	public function getDefinitions() {
16
		$params = parent::getDefinitions();
17
18
		return $params;
19
	}
20
21
	/**
22
	 * @see ParamDefinitionTest::valueProvider
23
	 *
24
	 * @param boolean $stringlyTyped
25
	 *
26
	 * @return array
27
	 */
28
	public function valueProvider( $stringlyTyped = true ) {
29
		$values = [
30
			'empty' => [
31
				[ 1, true, 1.0 ],
32
				[ 1.0, true, 1.0 ],
33
				[ 1.1, true, 1.1 ],
34
				[ 0.2555, true, 0.2555 ],
35
				[ '1.1.1', false ],
36
				[ 'foobar', false ],
37
				[ [], false ],
38
				[ 'yes', false ],
39
				[ false, false ],
40
			],
41
			'values' => [],
42
//			'values' => array(
43
//				array( 1, true, 1 ),
44
//				array( 'yes', false ),
45
//				array( 'no', false ),
46
//				array( 0.1, true, 0.1 ),
47
//				array( 0.2555, false ),
48
//			),
49
		];
50
51
		if ( $stringlyTyped ) {
52
			foreach ( $values as &$set ) {
53
				foreach ( $set as &$value ) {
54
					if ( is_float( $value[0] ) || is_int( $value[0] ) ) {
55
						$value[0] = (string)$value[0];
56
					}
57
				}
58
			}
59
		}
60
61
		return $values;
62
	}
63
64
	/**
65
	 * @see ParamDefinitionTest::getType
66
	 * @return string
67
	 */
68
	public function getType() {
69
		return 'float';
70
	}
71
72
}
73