Completed
Push — master ( be83ab...fe4249 )
by Sergey
44:41 queued 29:39
created

Relationshipable::setParent()   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
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Isswp101\Persimmon\Traits;
4
5
use Isswp101\Persimmon\ElasticsearchModel;
6
7
trait Relationshipable
8
{
9
    /**
10
     * @var ElasticsearchModel
11
     */
12
    protected $_parent;
13
14
    /**
15
     * @var mixed
16
     */
17
    protected $_parentId;
18
19
    /**
20
     * @return mixed
21
     */
22
    public function getParentId()
23
    {
24
        return $this->_parentId;
25
    }
26
27
    /**
28
     * @param mixed $id
29
     */
30
    public function setParentId($id)
31
    {
32
        $this->_parentId = $id;
33
    }
34
35
    /**
36
     * Return parent document.
37
     *
38
     * @return static
39
     */
40
    public function getParent()
41
    {
42
        return $this->_parent;
43
    }
44
45
    /**
46
     * Set parent document.
47
     *
48
     * @param ElasticsearchModel $parent
49
     */
50
    public function setParent(ElasticsearchModel $parent)
51
    {
52
        $this->_parent = $parent;
53
        $this->setParentId($parent->getId());
54
    }
55
}