HasLaunchButton   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A button() 0 10 2
A link() 0 2 1
1
<?php 
2
3
namespace Epesi\Core\System\Modules\Concerns;
4
5
use Epesi\Core\System\View\LaunchButton;
6
use Epesi\Core\System\Modules\ModuleView;
7
8
trait HasLaunchButton
9
{
10
	/**
11
	 * Label to display on the launch button
12
	 */
13
	abstract public function label();
14
	
15
	/**
16
	 * Icon to display on the launch button
17
	 */
18
	abstract public function icon();
19
	
20
	/**
21
	 * Define the launch button link
22
	 * 
23
	 * @return array|string
24
	 */
25
	public function link() {
26
		return '';
27
	}
28
29
	/**
30
	 * Define the launch button
31
	 * 
32
	 * @return LaunchButton
33
	 */
34
	final public function button()
35
	{
36
		$link = $this->link();
37
		
38
		$link = is_array($link)? ModuleView::moduleLink(...$link): $link;
39
		
40
		return (new LaunchButton([
41
				'label' => $this->label(),
42
				'icon' => $this->icon()
43
		]))->link($link);
44
	}
45
	
46
}