Liberation   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 33
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __callStatic() 0 23 2
1
<?php
2
3
namespace Liberation;
4
5
use Illuminate\View\FileViewFinder;
6
use InvalidArgumentException;
7
8
class Liberation
9
{
10
    /**
11
     * callStatic
12
     *
13
     * @param $name
14
     * @param $arguments
15
     * @return string
16
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
17
     */
18
    public static function __callStatic($name, $arguments)
19
    {
20
        $app = app();
21
        $view = view();
22
23
        if (count($arguments) === 0) {
24
            throw new InvalidArgumentException();
25
        }
26
27
        $fileName = $arguments[0];
28
        $params = $arguments[1] ?? [];
29
        $orgFinder = $view->getFinder();
30
        $sqlPath = resource_path() . '/' . $name;
31
32
        $newFinder = new FileViewFinder($app['files'], [$sqlPath]);
33
        $view->setFinder($newFinder);
34
        $view->addExtension($name, 'blade');
35
        $obj = $view->make($fileName, $params);
36
37
        $result = $obj->render();
38
        $view->setFinder($orgFinder);
39
40
        return $result;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $result also could return the type array which is incompatible with the documented return type string.
Loading history...
41
    }
42
}
43