MetadataRelationsTrait   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 13
Bugs 0 Features 0
Metric Value
wmc 1
eloc 4
c 13
b 0
f 0
dl 0
loc 18
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getRelationships() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
/**
5
 * Created by PhpStorm.
6
 * User: alex
7
 * Date: 13/02/20
8
 * Time: 1:08 PM.
9
 */
10
namespace AlgoWeb\PODataLaravel\Models;
11
12
use Illuminate\Database\Eloquent\Model;
13
use Illuminate\Database\Eloquent\Relations\BelongsTo;
14
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
15
use Illuminate\Database\Eloquent\Relations\MorphMany;
16
use Illuminate\Database\Eloquent\Relations\MorphOne;
17
use Illuminate\Database\Eloquent\Relations\MorphToMany;
18
use Illuminate\Database\Eloquent\Relations\Relation;
19
use Mockery\Mock;
20
use POData\Common\InvalidOperationException;
21
use ReflectionException;
22
23
trait MetadataRelationsTrait
24
{
25
    /**
26
     * @var array|string[]|null a cache for the relationship names
27
     */
28
    private static $relationNames = null;
29
30
    /**
31
     * Get model's relationships.
32
     *
33
     * @throws InvalidOperationException
34
     * @throws ReflectionException
35
     * @return array
36
     */
37
    public function getRelationships()
38
    {
39
        return self::$relationNames = self::$relationNames ??
40
                                      ModelReflectionHelper::getRelationshipsFromMethods(/* @scrutinizer ignore-type */$this);
41
    }
42
}
43