MorphToMany   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 11
c 1
b 0
f 0
dl 0
loc 25
ccs 9
cts 9
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A newPivot() 0 13 2
1
<?php
2
3
namespace Cino\LaravelChronos\Eloquent\Relations;
4
5
use Cino\LaravelChronos\Eloquent\Concerns\ChronosGetPivotClass;
6
use Cino\LaravelChronos\Eloquent\Concerns\ChronosRelations;
7
use Illuminate\Database\Eloquent\Relations\MorphToMany as BaseMorphToMany;
8
9
class MorphToMany extends BaseMorphToMany
10
{
11
    use ChronosGetPivotClass;
12
    use ChronosRelations;
13
14
    /**
15
     * Create a new pivot model instance.
16
     *
17
     * @param array $attributes
18
     * @param bool $exists
19
     * @return \Cino\LaravelChronos\Eloquent\Relations\MorphPivot
20
     */
21 1
    public function newPivot(array $attributes = [], $exists = false)
22
    {
23 1
        $using = $this->using;
24
25 1
        $pivot = $using
26 1
            ? $using::fromRawAttributes($this->parent, $attributes, $this->table, $exists)
27 1
            : MorphPivot::fromAttributes($this->parent, $attributes, $this->table, $exists);
28
29 1
        $pivot->setPivotKeys($this->foreignPivotKey, $this->relatedPivotKey)
30 1
            ->setMorphType($this->morphType)
31 1
            ->setMorphClass($this->morphClass);
32
33 1
        return $pivot;
34
    }
35
}
36