Completed
Branch BETA-4.9-message-activity (793322)
by
unknown
18:25 queued 10s
created

EE_Month_Input   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 16 3
A _zero_pad() 0 3 1
1
<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2
/**
3
 * EE_Month_Input
4
 *
5
 * @package			Event Espresso
6
 * @subpackage
7
 * @author				Mike Nelson
8
 */
9
class EE_Month_Input extends EE_Select_Input{
10
11
	/**
12
	 * @param bool  $leading_zero
13
	 * @param array $input_settings
14
	 * @param bool $january_is_month_1 whether january should have value of 1; or it should be month 0
15
	 */
16
	function __construct( $leading_zero = false, $input_settings = array(), $january_is_month_1 = true){
17
		$key_begin_range = $january_is_month_1 ? 1 : 0;
18
		$key_range = range($key_begin_range, $key_begin_range + 11 );
19
		if($leading_zero){
20
			array_walk( $key_range, array( $this, '_zero_pad' ) );	
21
		}
22
		$value_range = range( 1, 12 );
23
		array_walk( $value_range, array( $this, '_zero_pad' ) );
24
		parent::__construct(
25
			array_combine( 
26
				$key_range, 
27
				$value_range 
28
			),
29
			$input_settings
30
		);
31
	}
32
	
33
	/**
34
	 * Changes int 1 to 01, etc. Useful with array_walk
35
	 * @param int $input
36
	 * @param mixed $key
37
	 */
38
	protected function _zero_pad( &$input, $key ) {
0 ignored issues
show
Unused Code introduced by
The parameter $key is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
39
		$input = str_pad( $input, 2, '0', STR_PAD_LEFT );
40
	}
41
}