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

DimensionParamTest::valueProvider()   B

Complexity

Conditions 6
Paths 2

Size

Total Lines 53

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 53
rs 8.4032
c 0
b 0
f 0
cc 6
nc 2
nop 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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 DimensionParamTest extends ParamDefinitionTest {
10
11
	/**
12
	 * @see ParamDefinitionTest::getDefinitions
13
	 * @return array
14
	 */
15
	public function getDefinitions() {
16
		$params = parent::getDefinitions();
17
18
		$params['auto'] = [
19
			'allowauto' => true,
20
		];
21
22
		$params['allunits'] = [
23
			'units' => [ 'px', 'ex', 'em', '%', '' ],
24
		];
25
26
		$params['bounds'] = [
27
			'lowerbound' => 42,
28
			'upperbound' => 9000,
29
			'maxpercentage' => 34,
30
			'minpercentage' => 23,
31
			'units' => [ 'px', 'ex', '%', '' ],
32
		];
33
34
		return $params;
35
	}
36
37
	/**
38
	 * @see ParamDefinitionTest::valueProvider
39
	 *
40
	 * @param boolean $stringlyTyped
41
	 *
42
	 * @return array
43
	 */
44
	public function valueProvider( $stringlyTyped = true ) {
45
		$values = [
46
			'empty' => [
47
				[ '100px', true, '100px' ],
48
				[ '100', true, '100px' ],
49
				[ 42, true, '42px' ],
50
				[ 42.5, true, '42.5px' ],
51
				[ 'over9000', false ],
52
				[ 'yes', false ],
53
				[ 'auto', false ],
54
				[ '100%', false ],
55
			],
56
			'values' => [
57
				[ 1, true, '1px' ],
58
//				array( 2, false ),
59
				[ 'yes', false ],
60
				[ 'no', false ],
61
			],
62
			'auto' => [
63
				[ 'auto', true, 'auto' ],
64
			],
65
			'allunits' => [
66
				[ '100%', true, '100%' ],
67
				[ '100em', true, '100em' ],
68
				[ '100ex', true, '100ex' ],
69
				[ '101%', false ],
70
			],
71
			'bounds' => [
72
				[ '30%', true, '30%' ],
73
				[ '20%', false ],
74
				[ '40%', false ],
75
				[ '100px', true, '100px' ],
76
				[ '100ex', true, '100ex' ],
77
				[ '10px', false ],
78
				[ '9001ex', false ],
79
			],
80
		];
81
82
		if ( $stringlyTyped ) {
83
			foreach ( $values as &$set ) {
84
				foreach ( $set as &$value ) {
85
					if ( is_int( $value[0] ) || is_float( $value[0] ) ) {
86
						$value[0] = (string)$value[0];
87
					}
88
				}
89
			}
90
91
//			$values['empty'][] = array( 42, false );
92
//			$values['empty'][] = array( 42.5, false );
93
		}
94
95
		return $values;
96
	}
97
98
	/**
99
	 * @see ParamDefinitionTest::getType
100
	 * @return string
101
	 */
102
	public function getType() {
103
		return 'dimension';
104
	}
105
106
}
107