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

Relationshipable   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
c 2
b 0
f 0
lcom 1
cbo 1
dl 0
loc 49
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getParentId() 0 4 1
A setParentId() 0 4 1
A getParent() 0 4 1
A setParent() 0 5 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
}