Test Failed
Push — master ( 54db62...a5394f )
by Terzi
06:48
created

Architect   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 55
rs 10
c 0
b 0
f 0
wmc 9

4 Methods

Rating   Name   Duplication   Size   Complexity  
A humanize() 0 7 2
A resourceByEntity() 0 10 5
A path() 0 3 1
A routes() 0 3 1
1
<?php
2
3
namespace Terranet\Administrator;
4
5
use Illuminate\Database\Eloquent\Model;
0 ignored issues
show
Bug introduced by
The type Illuminate\Database\Eloquent\Model was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Illuminate\Support\Str;
7
8
class Architect
9
{
10
    /**
11
     * Get the AdminArchitect URI path.
12
     *
13
     * @return \Illuminate\Config\Repository|mixed
0 ignored issues
show
Bug introduced by
The type Illuminate\Config\Repository was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
     */
15
    public static function path()
16
    {
17
        return config('administrator.prefix', 'cms');
0 ignored issues
show
Bug introduced by
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

17
        return /** @scrutinizer ignore-call */ config('administrator.prefix', 'cms');
Loading history...
18
    }
19
20
    /**
21
     * Finds first module which uses a model.
22
     *
23
     * @param Model|string $model
24
     * @param string $urlKey
25
     *
26
     * @return mixed
27
     */
28
    public static function resourceByEntity($model, string $urlKey = null)
29
    {
30
        return app('scaffold.modules')->first(function ($module) use ($model, $urlKey) {
0 ignored issues
show
Bug introduced by
The function app was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
        return /** @scrutinizer ignore-call */ app('scaffold.modules')->first(function ($module) use ($model, $urlKey) {
Loading history...
31
            $urlEquals = $urlKey ? $module->url() === $urlKey : true;
32
33
            if (\is_string($model)) {
34
                return \get_class($module->model()) === $model && $urlEquals;
35
            }
36
37
            return \get_class($module->model()) === \get_class($model) && $urlEquals;
38
        });
39
    }
40
41
    /**
42
     * Humanize the given value into a proper name.
43
     *
44
     * @param string $value
45
     *
46
     * @return string
47
     */
48
    public static function humanize($value)
49
    {
50
        if (\is_object($value)) {
0 ignored issues
show
introduced by
The condition is_object($value) is always false.
Loading history...
51
            return static::humanize(class_basename(\get_class($value)));
52
        }
53
54
        return str_replace('_', ' ', Str::title(Str::snake($value, ' ')));
55
    }
56
57
    /**
58
     * @return ArchitectRoutes
59
     */
60
    public static function routes()
61
    {
62
        return new ArchitectRoutes();
63
    }
64
}
65