Completed
Push — master ( b1984c...7df504 )
by Iman
02:16
created

BaseWidget::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
4
namespace Imanghafoori\Widgets;
5
6
7
abstract class BaseWidget
8
{
9
    public $template = null;
10
    public $minifyOutput = true;
11
    public $cacheLifeTime = 'env_default';
12
    public $contextAs = '$data';
13
    public $presenter = 'default';
14
    public $controller = null;
15
    public $cacheTags = null;
16
17
    /**
18
     * This method is called when you try to invoke the object like a function in blade files.
19
     * like this : {!! $myWidgetObj('param1') !!}
20
     * @param array $args
21
     * @return string
22
     */
23
    public function __invoke(...$args)
24
    {
25
        return $this->render(...$args);;
26
    }
27
    /**
28
     * This method is called when you try to print the object like an string in blade files.
29
     * like this : {!! $myWidgetObj !!}
30
     */
31
    public function __toString()
32
    {
33
        return $this->render();;
34
    }
35
36
    public function render(...$args)
37
    {
38
        return app('imanghafoori.widget.renderer')->renderWidget($this,...$args);
39
    }
40
41
}