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

DependencyResolverTrait   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 45
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getModel() 0 4 1
A getDatatable() 0 4 1
A getStoreFormRequest() 0 4 1
A getUpdateFormRequest() 0 4 1
A getValidated() 0 6 1
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