ContextAsNormalizer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 16
ccs 5
cts 5
cp 1
rs 10
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
use Imanghafoori\Widgets\Utils\NormalizerContract;
6
7
class ContextAsNormalizer implements NormalizerContract
8
{
9
    /**
10
     * Figures out what the variable name should be in view file.
11
     *
12
     * @param  object  $widget
13
     * @return void
14
     */
15 24
    public function normalize($widget): void
16
    {
17 24
        $contextAs = 'data';
18 24
        if (property_exists($widget, 'contextAs')) {
19
            // removes the $ sign.
20 1
            $contextAs = str_replace('$', '', (string) $widget->contextAs);
21
        }
22 24
        $widget->contextAs = $contextAs;
23 24
    }
24
}
25