Passed
Push — master ( 5ca280...347b45 )
by Georgi
02:45
created

Applet::renderView()   A

Complexity

Conditions 5
Paths 9

Size

Total Lines 32
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 15
nc 9
nop 0
dl 0
loc 32
rs 9.4555
c 0
b 0
f 0
1
<?php
2
3
namespace Epesi\Base\Dashboard\Seeds;
4
5
use atk4\ui\View;
6
7
class Applet extends View
8
{
9
	public $ui = 'applet segment raised';
10
	public $defaultTemplate = 'applet.html';
11
	
12
	protected $appletId;
13
	protected $jointClass;
14
	protected $options;
15
	protected $admin = false;
16
	protected $locked = false;
17
	
18
	public function renderView()
19
	{		
20
		/**
21
		 * @var \Epesi\Base\Dashboard\Integration\Joints\AppletJoint $joint
22
		 */
23
		$joint = new $this->jointClass();
24
25
		$this->set('Name', $joint->caption())->setAttr('applet-id', $this->appletId);
26
		
27
		if ($this->admin) {
28
			$this->set($joint->info())->setAttr('searchkey', strtolower($joint->caption() . ';' . $joint->info()));
29
		}
30
		else {
31
			if (! $this->locked) {
32
				$this->addControl('close', 'applet-close')->setAttr('title', __('Close applet'));
33
			}
34
			
35
			$this->addControl('ellipsis vertical')->setAttr('title', __('Applet settings'))->link($this->app->moduleLink('dashboard', 'showSettings', [$this->appletId]));
36
			
37
			if ($link = $joint->go()) {
1 ignored issue
show
Bug introduced by
Are you sure the assignment to $link is correct as $joint->go() targeting Epesi\Base\Dashboard\Int...oints\AppletJoint::go() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
38
				$this->addControl('expand')->setAttr('title', __('Full screen'))->link($link);
39
			}			
40
41
			ob_start();
42
			$joint->body($this, $this->options?? $joint->defaultOptions());
43
44
			if ($content = ob_get_clean()) {
45
				$this->set($content);
46
			}
47
		}
48
		
49
		parent::renderView();
50
	}
51
	
52
	public function addControl($icon, $ui = null)
53
	{
54
		return $this->addAction($icon, 'applet-control ' . $ui);
55
	}
56
	
57
	public function addAction($icon, $ui = null)
58
	{
59
		$control = $this->add(['View', 'ui' => $ui], 'Controls')->link('#');
60
		$control->add(['Icon', $icon]);
61
		
62
		return $control;
63
	}
64
}
65