ContextAsNormalizer::normalize()   A
last analyzed

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
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