Passed
Push — master ( 02118d...11fb63 )
by Petr
03:00
created

AReadWriteDatabase::loadRecordByPk()   B

Complexity

Conditions 10
Paths 32

Size

Total Lines 47
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 26
CRAP Score 10

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 10
eloc 26
c 1
b 0
f 1
nc 32
nop 1
dl 0
loc 47
ccs 26
cts 26
cp 1
crap 10
rs 7.6666

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace kalanis\kw_mapper\Mappers\Database;
4
5
6
use kalanis\kw_mapper\MapperException;
7
use kalanis\kw_mapper\Mappers\AMapper;
8
use kalanis\kw_mapper\Storage;
9
10
11
/**
12
 * Class AReadWriteDatabase
13
 * @package kalanis\kw_mapper\Mappers\Database
14
 * Separated Read and write DB entry without need to reload mapper
15
 * The most parts are similar to usual read/write one, just with separation of read-write operations
16
 */
17
abstract class AReadWriteDatabase extends AMapper
18
{
19
    use TTable;
20
    use TReadDatabase;
21
    use TWriteDatabase;
22
23
    /**
24
     * @throws MapperException
25
     */
26 4
    public function __construct()
27
    {
28 4
        parent::__construct();
29
30 4
        $this->initTReadDatabase();
31 4
        $this->initTWriteDatabase();
32 4
    }
33
34 14
    public function getAlias(): string
35
    {
36 14
        return $this->getTable();
37
    }
38
}
39