Test Failed
Pull Request — master (#107)
by Alex
07:47
created

MetadataProviderNew::calculateRoundTripRelations()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 13
rs 9.4285
c 1
b 0
f 0
cc 3
eloc 7
nc 3
nop 0
1
<?php
2
3
namespace AlgoWeb\PODataLaravel\Providers;
4
5
use AlgoWeb\PODataLaravel\Models\MetadataRelationHolder;
6
7
class MetadataProviderNew extends MetadataProvider
8
{
9
    protected $relationHolder;
10
11
    public function __construct($app)
12
    {
13
        parent::__construct($app);
14
        $this->relationHolder = new MetadataRelationHolder();
15
        self::$isBooted = false;
16
    }
17
18
    /**
19
     * @return MetadataRelationHolder
20
     */
21
    public function getRelationHolder()
22
    {
23
        return $this->relationHolder;
24
    }
25
26
    public function calculateRoundTripRelations()
27
    {
28
        $modelNames = $this->getCandidateModels();
29
30
        foreach ($modelNames as $name) {
31
            if (!$this->getRelationHolder()->hasClass($name)) {
32
                $model = new $name();
33
                $this->getRelationHolder()->addModel($model);
34
            }
35
        }
36
37
        return $this->getRelationHolder()->getRelations();
38
    }
39
}
40