Test Failed
Pull Request — master (#68)
by yasin
04:44
created

SlotRenderer::hasSlot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Imanghafoori\Widgets\Utils;
4
5
trait SlotRenderer 
6
{
7
	protected $slotName;
8
9
	protected $slots = [];
10
11
	public function startSlot($name)
12
	{
13
		if(ob_start()){
14
			$this->slotName = $name;
15
		}
16
	}
17
18
	public function renderSlot($data)
19
	{
20
		$this->slots[$this->slotName] = $data ?? "";
21
	}
22
23
	public function hasSlot()
24
	{
25
		return !empty($this->slots);
26
	}
27
28
    /**
29
     * Assign slots to $_viewData
30
     */
31
    private function assignSlots()
32
    {
33
        if($this->hasSlot())
34
            $this->_viewData = array_merge($this->_viewData, $this->slots);
0 ignored issues
show
Bug Best Practice introduced by
The property _viewData does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
35
    }
36
}