Passed
Push — master ( 2178f0...b67c9a )
by Reza
11:23
created

get_icon()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 23
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 6
Bugs 1 Features 2
Metric Value
cc 3
eloc 19
c 6
b 1
f 2
nc 3
nop 1
dl 0
loc 23
rs 9.6333
1
<?php
2
3
use EasyPanel\Contracts\CRUDComponent;
4
5
if(! function_exists('getRouteName')) {
6
    function getRouteName(){
7
        $routeName = config('easy_panel.route_prefix');
8
        $routeName = trim($routeName, '/');
9
        $routeName = str_replace('/', '.', $routeName);
10
        return $routeName;
11
    }
12
}
13
14
if(! function_exists('getCrudConfig')) {
15
    function getCrudConfig($name){
16
17
        $crudName=ucfirst($name);
18
        $namespace = "\\App\\CRUD\\{$crudName}Component";
19
20
        if (!file_exists(app_path("/CRUD/{$crudName}Component.php")) or !class_exists($namespace)){
21
            abort(403, "Class with {$namespace} namespace doesn't exist");
22
        }
23
24
        $instance = app()->make($namespace);
25
26
        if (!$instance instanceof CRUDComponent){
27
            abort(403, "{$namespace} should implement CRUDComponent interface");
28
        }
29
30
        return $instance;
31
    }
32
}
33
34
if(! function_exists('crud')) {
35
    function crud($name){
36
        return \EasyPanel\Models\CRUD::query()->where('name', $name)->first();
37
    }
38
}
39