Completed
Push — develop ( efbf23...556e46 )
by Paul
02:08
created

Checkbox::render()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 10
nc 4
nop 0
1
<?php
2
3
namespace GeminiLabs\Castor\Forms\Fields;
4
5
use GeminiLabs\Castor\Forms\Fields\Base;
6
7
class Checkbox extends Base
8
{
9
	protected $element = 'input';
10
11
	public function __construct( array $args = [] )
12
	{
13
		parent::__construct( $args );
14
15
		if( count( $args['options'] ) > 1 ) {
16
			$this->multi = true;
17
		}
18
	}
19
20
	/**
21
	 * @return string
22
	 */
23
	public function render()
24
	{
25
		$inline = $this->args['inline'] ? ' class="inline"' : '';
26
27
		if( $this->multi ) {
28
			return sprintf( '<ul%s>%s</ul>%s',
29
				$inline,
30
				$this->implodeOptions( 'multi_input_checkbox' ),
31
				$this->generateDescription()
32
			);
33
		}
34
35
		return sprintf( '%s%s',
36
			$this->implodeOptions( 'single_input' ),
37
			$this->generateDescription()
38
		);
39
	}
40
}
41