Completed
Push — master ( 077f63...ceb768 )
by Andrii
02:53
created

BaseRepository   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
c 0
b 0
f 0
lcom 0
cbo 2
dl 0
loc 39
ccs 0
cts 26
cp 0
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A find() 0 6 1
A getTable() 0 4 1
A setRecordClass() 0 4 1
A getRecordClass() 0 8 2
A findRecordClass() 0 6 1
1
<?php
2
/**
3
 * HiAPI Yii2 base project for building API
4
 *
5
 * @link      https://github.com/hiqdev/hiapi
6
 * @package   hiapi
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiapi\repositories;
12
13
use Yii;
14
15
abstract class BaseRepository extends \yii\base\Component
16
{
17
    public $table;
18
19
    public function find(ActiveQuery $query)
20
    {
21
        $query->setRepository($this);
22
23
        return $query;
24
    }
25
26
    public function getTable()
27
    {
28
        return $this->table;
29
    }
30
31
    protected $_recordClass;
32
33
    public function setRecordClass($value)
34
    {
35
        $this->recordClass = $value;
0 ignored issues
show
Bug introduced by
The property recordClass does not seem to exist. Did you mean _recordClass?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
36
    }
37
38
    public function getRecordClass()
39
    {
40
        if ($this->recordClass === null) {
0 ignored issues
show
Bug introduced by
The property recordClass does not seem to exist. Did you mean _recordClass?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
41
            $this->recordClass = $this->findRecordClass();
0 ignored issues
show
Bug introduced by
The property recordClass does not seem to exist. Did you mean _recordClass?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
42
        }
43
44
        return $this->recordClass;
0 ignored issues
show
Bug introduced by
The property recordClass does not seem to exist. Did you mean _recordClass?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
45
    }
46
47
    public function findRecordClass()
48
    {
49
        $parts = explode('\\', get_called_class());
50
51
        return implode('\\', $parts);
52
    }
53
}
54