Completed
Push — master ( c2ab20...6fd91f )
by Alex
14s queued 12s
created

MetadataRelationsTrait   A

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