Creatable   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 23
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 10 2
1
<?php
2
3
namespace Laravel\DataTables\Traits;
4
5
use Arr;
6
use Illuminate\Database\Eloquent\Model;
7
8
trait Creatable
9
{
10
    /**
11
     * Allow Entity Creation.
12
     *
13
     * @var bool
14
     */
15
    public $allowCreation = false;
16
17
    /**
18
     * @param array $data
19
     * @return mixed
20
     */
21
    public function create(array $data): ?Model
22
    {
23
        if (! $this->allowCreation) {
24
            return null;
25
        }
26
27
        return $this->builder()->create(
0 ignored issues
show
Bug introduced by
It seems like builder() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

27
        return $this->/** @scrutinizer ignore-call */ builder()->create(
Loading history...
28
            Arr::only(
29
                $data,
30
                $this->getUpdatableColumns()
0 ignored issues
show
Bug introduced by
It seems like getUpdatableColumns() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

30
                $this->/** @scrutinizer ignore-call */ 
31
                       getUpdatableColumns()
Loading history...
31
            )
32
        );
33
    }
34
}
35