Completed
Push — master ( 94d3aa...1e9c69 )
by Iman
05:12
created

ContextAsNormalizer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 16
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A normalize() 0 8 2
1
<?php
2
3
namespace Imanghafoori\Widgets\Utils\Normalizers;
4
5
class ContextAsNormalizer
6
{
7
    /**
8
     * Figures out what the variable name should be in view file.
9
     *
10
     * @param object $widget
11
     * @return null
12
     */
13 16
    public function normalize($widget)
14
    {
15 16
        $contextAs = 'data';
16 16
        if (property_exists($widget, 'contextAs')) {
17
            // removes the $ sign.
18 1
            $contextAs = str_replace('$', '', (string) $widget->contextAs);
19
        }
20 16
        $widget->contextAs = $contextAs;
21 16
    }
22
}
23