WidgetFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 4
Bugs 0 Features 2
Metric Value
wmc 2
c 4
b 0
f 2
lcom 1
cbo 3
dl 0
loc 30
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A initWidget() 0 5 1
A asExpression() 0 4 1
1
<?php
2
3
namespace Benrowe\Laravel\Widgets\Factories;
4
5
use Arrilot\Widgets\Factories\WidgetFactory as BaseWidgetFactory;
6
use Arrilot\Widgets\AbstractWidget;
7
use Benrowe\Laravel\Widgets\Expression;
8
use Benrowe\Laravel\Widgets\Traits\WidgetWrapperFactory;
9
10
/**
11
 * Widget Factory
12
 *
13
 * @package Benrowe\Laravel\Widgets
14
 */
15
class WidgetFactory extends BaseWidgetFactory
16
{
17
    use WidgetWrapperFactory;
18
19
    /**
20
     * Instanciate the widget, based on the provided configuration
21
     * and return the instance of the widget
22
     *
23
     * @param  array $params widget parameters
24
     * @return AbstractWidget
25
     */
26
    public function initWidget(array $params = [])
27
    {
28
        $this->instantiateWidget($params);
29
        return $this->widget;
30
    }
31
32
    /**
33
     * Convert the outputted html to an expression.
34
     * The expression represents both the output (string) and the instance of
35
     * the related widget
36
     *
37
     * @param  string $html
38
     * @return Expression
39
     */
40
    protected function asExpression($html)
41
    {
42
        return new Expression($html, $this->widget);
43
    }
44
}
45