BoolParamTest::getDefinitions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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 BoolParamTest extends ParamDefinitionTest {
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
				[ 'yes', true, true ],
32
				[ 'on', true, true ],
33
				[ '1', true, true ],
34
				[ 'no', true, false ],
35
				[ 'off', true, false ],
36
				[ '0', true, false ],
37
				[ 'foobar', false ],
38
				[ '2', false ],
39
				[ [], false ],
40
				[ 42, false ],
41
			],
42
			'values' => [],
43
//			'values' => array(
44
//				array( '1', true, true ),
45
//				array( 'yes', true, true ),
46
//				array( 'no', false ),
47
//				array( 'foobar', false ),
48
//			),
49
		];
50
51
		if ( !$stringlyTyped ) {
52
			foreach ( $values as &$set ) {
53
				foreach ( $set as &$value ) {
54
					if ( in_array( $value[0], [ 'yes', 'on', '1', '0', 'off', 'no' ], true ) ) {
55
						$value[0] = in_array( $value[0], [ 'yes', 'on', '1' ], true );
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 'boolean';
70
	}
71
72
}
73