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

ContextAsNormalizer::normalizeContextAs()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 1
dl 0
loc 9
rs 9.6666
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
    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