Completed
Pull Request — master (#22)
by Sergey
17:35 queued 02:34
created

ElasticsearchModel::getRelationshipKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Isswp101\Persimmon\Model;
4
5
use Isswp101\Persimmon\Collection\IElasticsearchCollection;
6
use Isswp101\Persimmon\DI\Container;
7
use Isswp101\Persimmon\DI\DI;
8
use Isswp101\Persimmon\QueryBuilder\IQueryBuilder;
9
use Isswp101\Persimmon\Relationship\BelongsToRelationship;
10
use Isswp101\Persimmon\Relationship\HasManyRelationship;
11
use Isswp101\Persimmon\Relationship\RelationshipKey;
12
13
/**
14
 * @method static static find($id, array $columns = [])
15
 * @method static IElasticsearchCollection all(IQueryBuilder $query, callable $callback = null)
16
 */
17
class ElasticsearchModel extends Eloquent implements IElasticsearchModel
18
{
19
    protected $relationshipKey;
20
21
    protected static function di(): Container
22
    {
23
        return DI::make(DI::ELASTICSEARCH);
24
    }
25
26
    public function getRelationshipKey(): RelationshipKey
27
    {
28
        return $this->relationshipKey;
29
    }
30
31
    public function setRelationshipKey(RelationshipKey $relationshipKey)
32
    {
33
        $this->relationshipKey = $relationshipKey;
34
    }
35
36
    protected function belongsTo(string $class)
37
    {
38
        return new BelongsToRelationship($this, $class);
39
    }
40
41
    protected function hasMany(string $class)
42
    {
43
        return new HasManyRelationship($this, $class);
44
    }
45
}