Passed
Push — master ( bc8b6f...7a9b1f )
by Sergei
02:57
created

CustomerWithProperties::getTableName()   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 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\ActiveRecord\Tests\Stubs\MagicActiveRecord;
6
7
use Yiisoft\ActiveRecord\ActiveQuery;
8
use Yiisoft\ActiveRecord\Tests\Stubs\MagicActiveRecord;
9
10
/**
11
 * Class Customer with defined properties.
12
 */
13
class CustomerWithProperties extends MagicActiveRecord
14
{
15
    protected int $id;
16
    protected string $email;
17
    protected string|null $name = null;
18
    public string|null $address = null;
19
20
    public function getTableName(): string
21
    {
22
        return 'customer';
23
    }
24
25
    public function getId(): int
26
    {
27
        return $this->id;
28
    }
29
30
    public function getEmail(): string
31
    {
32
        return $this->email;
33
    }
34
35
    public function getName(): string|null
36
    {
37
        return $this->name;
38
    }
39
40
    public function getAddress(): string|null
41
    {
42
        return $this->address;
43
    }
44
45
    public function getStatus(): int|null
46
    {
47
        return $this->getAttribute('status');
48
    }
49
50
    public function getProfileQuery(): ActiveQuery
51
    {
52
        return $this->hasOne(Profile::class, ['id' => 'profile_id']);
53
    }
54
55
    public function getOrdersQuery(): ActiveQuery
56
    {
57
        return $this->hasMany(Order::class, ['customer_id' => 'id'])->orderBy('[[id]]');
58
    }
59
60
    public function setEmail(string $email): void
61
    {
62
        $this->email = $email;
63
    }
64
65
    public function setName(string|null $name): void
66
    {
67
        $this->name = $name;
68
    }
69
70
    public function setAddress(string|null $address): void
71
    {
72
        $this->address = $address;
73
    }
74
75
    public function setStatus(int|null $status): void
76
    {
77
        $this->setAttribute('status', $status);
78
    }
79
}
80