Completed
Push — master ( 8f08c7...7bd638 )
by Mohamed
02:25
created

DependencyResolverTrait::getModel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Microboard\Foundations\Traits;
4
5
use Illuminate\Http\Request;
6
7
trait DependencyResolverTrait
8
{
9
    /**
10
     * @return string
11
     */
12
    protected function getModel(): string
13
    {
14
        return app()->getNamespace() . $this->baseName;
0 ignored issues
show
Bug introduced by
The property baseName does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
15
    }
16
17
    /**
18
     * @return string
19
     */
20
    protected function getDatatable(): string
21
    {
22
        return app()->getNamespace() . 'DataTables\\' . str_replace('Controller', 'DataTable', class_basename($this));
23
    }
24
25
    /**
26
     * @return string
27
     */
28
    protected function getStoreFormRequest(): string
29
    {
30
        return app()->getNamespace() . 'Http\\Requests\\' . $this->baseName . '\\StoreFormRequest';
31
    }
32
33
    /**
34
     * @return string
35
     */
36
    protected function getUpdateFormRequest(): string
37
    {
38
        return app()->getNamespace() . 'Http\\Requests\\' . $this->baseName . '\\UpdateFormRequest';
39
    }
40
41
    /**
42
     * @param Request $request
43
     * @return mixed
44
     */
45
    protected function getValidated(Request $request)
46
    {
47
        return array_filter($request->validated(), function ($input) {
48
            return !empty($input);
49
        });
50
    }
51
}
52