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

BaseRepository::findRecordClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
ccs 0
cts 3
cp 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
crap 2
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