BladeExtension::script()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
ccs 4
cts 4
cp 1
crap 1
1
<?php
2
3
namespace LaravelPlus\Extension\Templates;
4
5
class BladeExtension
6
{
7
    /**
8
     * Compile Blade comments into valid PHP.
9
     *
10
     * @return \Closure
11
     */
12
    public static function comment()
13
    {
14 2
        return function ($value) {
15 1
            $pattern = sprintf('/%s((.|\s)*?)%s/', '{#', '#}');
16
17 1
            return preg_replace($pattern, '<?php /*$1*/ ?>', $value);
18 2
        };
19
    }
20
21
    /**
22
     * Compile Blade script into valid PHP.
23
     *
24
     * @return \Closure
25
     */
26
    public static function script()
27
    {
28 2
        return function ($value) {
29 1
            $pattern = sprintf('/%s((.|\s)*?)%s/', '{@', '@}');
30
31 1
            return preg_replace($pattern, '<?php $1; ?>', $value);
32 2
        };
33
    }
34
}
35