Test Failed
Pull Request — master (#107)
by Alex
03:44
created

MetadataProvider   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 41.67%

Importance

Changes 9
Bugs 0 Features 0
Metric Value
wmc 5
c 9
b 0
f 0
lcom 1
cbo 2
dl 0
loc 33
ccs 5
cts 12
cp 0.4167
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getRelationHolder() 0 4 1
A calculateRoundTripRelations() 0 13 3
1
<?php
2
3
namespace AlgoWeb\PODataLaravel\Providers;
4
5
use AlgoWeb\PODataLaravel\Models\MetadataRelationHolder;
6
7
class MetadataProvider extends MetadataProviderOld
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 1
     */
21
    public function getRelationHolder()
22 1
    {
23
        return $this->relationHolder;
24
    }
25 1
26
    public function calculateRoundTripRelations()
27
    {
28 1
        $modelNames = $this->getCandidateModels();
29 1
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