Completed
Push — master ( 15db70...750821 )
by Dennis
01:29
created

Group::render()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace lloc\Msls\Component\Input;
5
6
use lloc\Msls\Component\InputInterface;
7
8
/**
9
 * Class Options
10
 * @package lloc\Msls\Component\Input
11
 */
12
class Group implements InputInterface {
13
14
	/**
15
	 * @var array
16
	 */
17
	protected $arr = [];
18
19
	/**
20
	 * @var string
21
	 */
22
	protected $glue = '';
23
24
	/**
25
	 * Options constructor.
26
	 *
27
	 * @param string $glue
28
	 */
29
	public function __construct( string $glue = ' ' ) {
30
		$this->glue = $glue;
31
	}
32
33
	/**
34
	 * @param InputInterface $input
35
	 *
36
	 * @return self
37
	 */
38
	public function add( InputInterface $input ): self {
39
		$this->arr[] = $input;
40
41
		return $this;
42
	}
43
44
	/**
45
	 * @return string
46
	 */
47
	public function render(): string {
48
		$items = array_map( function( InputInterface $input ) {
49
			return $input->render();
50
		}, $this->arr );
51
52
		return implode( $this->glue, $items );
53
	}
54
55
}