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

Checkbox   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 34
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A render() 0 17 3
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