Completed
Push — master ( f1f202...f49b06 )
by Iman
01:39
created

ContextAsNormalizer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A normalizeContextAs() 0 9 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
    public function normalizeContextAs($widget)
14
    {
15
        $contextAs = 'data';
16
        if (property_exists($widget, 'contextAs')) {
17
            // removes the $ sign.
18
            $contextAs = str_replace('$', '', (string) $widget->contextAs);
19
        }
20
        $widget->contextAs = $contextAs;
21
    }
22
}
23