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

Animal::setDoes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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