Passed
Pull Request — master (#339)
by Sergei
02:54
created

Animal   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 9
dl 0
loc 31
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getDoes() 0 3 1
A setDoes() 0 3 1
A instantiate() 0 5 1
A __construct() 0 5 1
A getTableName() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\ActiveRecord\Tests\Stubs\MagicActiveRecord;
6
7
use Yiisoft\ActiveRecord\MagicActiveRecord;
8
use Yiisoft\ActiveRecord\ActiveRecordInterface;
9
use Yiisoft\Db\Connection\ConnectionInterface;
10
11
/**
12
 * Class Animal.
13
 *
14
 * @property int $id
15
 * @property string $type
16
 */
17
class Animal extends MagicActiveRecord
18
{
19
    private string $does;
20
21
    public function getTableName(): string
22
    {
23
        return 'animal';
24
    }
25
26
    public function __construct(ConnectionInterface $db)
27
    {
28
        parent::__construct($db);
29
30
        $this->type = static::class;
31
    }
32
33
    public function getDoes()
34
    {
35
        return $this->does;
36
    }
37
38
    public function instantiate($row): ActiveRecordInterface
39
    {
40
        $class = $row['type'];
41
42
        return new $class($this->db());
43
    }
44
45
    public function setDoes(string $value): void
46
    {
47
        $this->does = $value;
48
    }
49
}
50