Completed
Push — master ( bcf727...1c002a )
by Terzi
08:06
created

Architect::humanize()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Terranet\Administrator;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Support\Str;
7
8
class Architect
9
{
10
    /**
11
     * Finds first module which uses a model.
12
     *
13
     * @param string|Model $model
14
     *
15
     * @return mixed
16
     */
17
    public static function resourceByEntity($model)
18
    {
19
        return app('scaffold.modules')->first(function ($module) use ($model) {
0 ignored issues
show
Bug introduced by
The method first() does not exist on Illuminate\Foundation\Application. ( Ignorable by Annotation )

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

19
        return app('scaffold.modules')->/** @scrutinizer ignore-call */ first(function ($module) use ($model) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
20
            if (is_string($model)) {
21
                return get_class($module->model()) === $model;
22
            }
23
24
            return get_class($module->model()) === get_class($model);
25
        });
26
    }
27
28
    /**
29
     * Humanize the given value into a proper name.
30
     *
31
     * @param  string $value
32
     * @return string
33
     */
34
    public static function humanize($value)
35
    {
36
        if (is_object($value)) {
0 ignored issues
show
introduced by
The condition is_object($value) is always false.
Loading history...
37
            return static::humanize(class_basename(get_class($value)));
38
        }
39
40
        return Str::title(Str::snake($value, ' '));
41
    }
42
}