Completed
Push — master ( 8f9a32...40960a )
by
unknown
05:49
created

SelectMultipleManyToMany   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 5
dl 0
loc 35
ccs 11
cts 11
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setup() 0 5 1
A persist() 0 6 2
A getColumn() 0 4 1
1
<?php
2
namespace Anavel\Crud\Abstractor\Eloquent\Relation;
3
4
use Anavel\Crud\Abstractor\Eloquent\Relation\Traits\CheckRelationCompatibility;
5
use Anavel\Crud\Abstractor\Eloquent\Relation\Traits\CheckRelationConfig;
6
use Anavel\Crud\Repository\Criteria\InArrayCriteria;
7
use App;
8
use Doctrine\DBAL\Schema\Column;
9
use Illuminate\Http\Request;
10
11
class SelectMultipleManyToMany extends SelectMultiple
12
{
13
    use CheckRelationCompatibility;
14
15
    protected $compatibleEloquentRelations = array(
16
        'Illuminate\Database\Eloquent\Relations\BelongsToMany'
17
    );
18
19 6
    public function setup()
20
    {
21 6
        $this->checkRelationCompatibility();
22 6
        $this->checkDisplayConfig();
23 6
    }
24
25
    /**
26
     * @param array|null $relationArray
27
     * @return mixed
28
     */
29 1
    public function persist(array $relationArray = null, Request $request)
30
    {
31 1
        if (! empty($relationArray)) {
32 1
            $this->eloquentRelation->sync($relationArray[$this->eloquentRelation->getRelated()->getKeyName()]);
33 1
        }
34 1
    }
35
36
    /**
37
     * @param \ANavallaSuiza\Laravel\Database\Contracts\Dbal\AbstractionLayer $dbal
38
     * @return Column
39
     */
40 1
    protected function getColumn($dbal)
41
    {
42 1
        return $dbal->getTableColumn($this->eloquentRelation->getRelated()->getKeyName());
43
    }
44
45
}
46