HasTaxonomyablesToMany   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A vocabulariesToMany() 0 5 1
A termsToMany() 0 5 1
1
<?php
2
3
namespace Fomvasss\Taxonomy\Models\Traits;
4
5
use Fomvasss\Taxonomy\Models\Term;
6
use Fomvasss\Taxonomy\Models\Vocabulary;
7
8
/**
9
 * Сущность текущей модели "относится" к разным
10
 * словарям или термам
11
 * (для класса модели к которому подключен трейт - методы не используются для категоризации)
12
 *
13
 * Trait HasTaxonomyablesToMany
14
 *
15
 * @package App\Models\Traits
16
 */
17
trait HasTaxonomyablesToMany
18
{
19
    /**
20
     * Сущность текущей модели "относится" к разным словарям.
21
     * Получить к список словарей, к которым относится.
22
     *
23
     * @return $this
24
     */
25
    public function vocabulariesToMany()
26
    {
27
        $related = config('taxonomy.models.vocabulary', Vocabulary::class);
0 ignored issues
show
Bug introduced by
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

27
        $related = /** @scrutinizer ignore-call */ config('taxonomy.models.vocabulary', Vocabulary::class);
Loading history...
28
        
29
        return $this->morphToMany($related, 'vocabularyable');
0 ignored issues
show
Bug introduced by
It seems like morphToMany() 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

29
        return $this->/** @scrutinizer ignore-call */ morphToMany($related, 'vocabularyable');
Loading history...
30
    }
31
32
    /**
33
     * Сущность текущей модели "относится" к разным термам.
34
     * Получить список термов, к которым относится.
35
     *
36
     * @return $this
37
     */
38
    public function termsToMany()
39
    {
40
        $related = config('taxonomy.models.term', Term::class);
0 ignored issues
show
Bug introduced by
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

40
        $related = /** @scrutinizer ignore-call */ config('taxonomy.models.term', Term::class);
Loading history...
41
        
42
        return $this->morphToMany($related, 'termable');
43
    }
44
}
45