Completed
Branch master (411345)
by Rémi
11:20
created

MorphOne::initRelation()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 2
dl 10
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Analogue\ORM\Relationships;
4
5
class MorphOne extends MorphOneOrMany
6
{
7
    /**
8
     * Get the results of the relationship.
9
     *
10
     * @param  $relation
11
     * @return mixed
12
     */
13
    public function getResults($relation)
14
    {
15
        $result = $this->query->first();
16
17
        $this->cacheRelation($result, $relation);
18
19
        return $result;
20
    }
21
22
    /**
23
     * Match the eagerly loaded results to their parents.
24
     *
25
     * @param  array            $results
26
     * @param  string           $relation
27
     * @return array
28
     */
29
    public function match(array $results, $relation)
30
    {
31
        return $this->matchOne($results, $relation);
32
    }
33
}
34