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

ContextAsNormalizer::normalize()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 2
rs 10
c 0
b 0
f 0
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