Completed
Push — master ( d8ac6c...cd03ce )
by Jesse
02:57
created

HasBackReference   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A inProperty() 0 3 1
A name() 0 3 1
A __construct() 0 3 1
A value() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stratadox\Hydration\Mapping\Property\Relationship;
6
7
use Stratadox\Hydration\MapsProperty;
8
9
/**
10
 * Maps a back-reference in a bidirectional relationship.
11
 *
12
 * @package Stratadox\Hydrate
13
 * @author Stratadox
14
 */
15
class HasBackReference implements MapsProperty
16
{
17
    private $name;
18
19
    protected function __construct(string $name)
20
    {
21
        $this->name = $name;
22
    }
23
24
    public static function inProperty(string $name) : MapsProperty
25
    {
26
        return new static($name);
27
    }
28
29
    public function name() : string
30
    {
31
        return $this->name;
32
    }
33
34
    /** @inheritdoc @return mixed|object */
35
    public function value(array $data, $owner = null)
36
    {
37
        return $owner;
38
    }
39
}
40