Completed
Push — dev ( 6f78cf...ec46b6 )
by Marc
02:13
created

Artificer   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 92
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 16
Bugs 5 Features 4
Metric Value
wmc 13
c 16
b 5
f 4
lcom 0
cbo 2
dl 0
loc 92
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
B getCurrentAction() 0 16 6
A getModel() 0 4 1
A pluginManager() 0 4 1
A widgetManager() 0 4 1
A buildStyles() 0 3 1
A getCurrentModelId() 0 4 1
A addMenu() 0 4 1
A getMenu() 0 4 1
1
<?php namespace Mascame\Artificer;
2
3
use \App;
4
use Mascame\Artificer\Http\Controllers\BaseModelController;
5
use Mascame\Artificer\Model\Model;
6
7
class Artificer
8
{
9
10
    /**
11
     * Returns the current user's action.
12
     *
13
     * @return null|string list, edit, create, show
14
     */
15
    public static function getCurrentAction()
16
    {
17
        switch (\Route::currentRouteName()) {
18
            case 'admin.model.create':
19
                return 'create';
20
            case 'admin.model.edit':
21
                return 'edit';
22
            case 'admin.model.show':
23
                return 'show';
24
            case 'admin.model.all':
25
            case 'admin.model.filter':
26
                return 'list';
27
            default:
28
                return null;
29
        }
30
    }
31
32
    /**
33
     * @return Model
34
     */
35
    public static function getModel()
36
    {
37
        return App::make('ArtificerModel');
38
    }
39
40
    /**
41
     * @return \Mascame\Artificer\Plugin\Manager
42
     */
43
    public static function pluginManager()
44
    {
45
        return App::make('ArtificerPluginManager');
46
    }
47
48
    /**
49
     * @return \Mascame\Artificer\Widget\Manager
50
     */
51
    public static function widgetManager()
52
    {
53
        return App::make('ArtificerWidgetManager');
54
    }
55
56
    protected static function buildStyles($styles) {
0 ignored issues
show
Unused Code introduced by
The parameter $styles is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
57
58
    }
59
60
    public static function getCurrentModelId($items)
61
    {
62
        return BaseModelController::getCurrentModelId($items);
63
    }
64
65
    
66
    public static function addMenu($options)
67
    {
68
        return config(['admin.menu' => array_merge(self::getMenu(), $options)]);
69
    }
70
71
    protected static function getMenu()
72
    {
73
        return config('admin.menu');
74
    }
75
76
    // Todo is it used anywhere?
77
//    public static function store($filepath = null, $content, $overide = false)
78
//    {
79
//        if (!$filepath) {
80
//            $pathinfo = pathinfo($filepath);
81
//            $filepath = $pathinfo['dirname'];
82
//        }
83
//
84
//        $path = explode('/', $filepath);
85
//        array_pop($path);
86
//        $path = join('/', $path);
87
//
88
//        if (!file_exists($path)) {
89
//            \File::makeDirectory($path, 0777, true, true);
90
//        }
91
//
92
//        if (!file_exists($filepath) || $overide) {
93
//            return \File::put($filepath, $content);
94
//        }
95
//
96
//        return false;
97
//    }
98
}