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

MetadataProviderNew::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 5
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
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
    }
16
17
    /**
18
     * @return MetadataRelationHolder
19
     */
20
    public function getRelationHolder()
21
    {
22
        return $this->relationHolder;
23
    }
24
25
    public function calculateRoundTripRelations()
26
    {
27
        $modelNames = $this->getCandidateModels();
28
29
        foreach ($modelNames as $name) {
30
            if (!$this->getRelationHolder()->hasClass($name)) {
31
                $model = new $name();
32
                $this->getRelationHolder()->addModel($model);
33
            }
34
        }
35
36
        return $this->getRelationHolder()->getRelations();
37
    }
38
}
39