DeviceHasScreen::tableName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace app\models;
4
5
use Yii;
6
7
/**
8
 * This is the model class for table "device_has_screen".
9
 *
10
 * @property int $device_id
11
 * @property int $screen_id
12
 * @property Device $device
13
 * @property Screen $screen
14
 */
15 View Code Duplication
class DeviceHasScreen extends \yii\db\ActiveRecord
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public static function tableName()
21
    {
22
        return 'device_has_screen';
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function rules()
29
    {
30
        return [
31
            [['device_id', 'screen_id'], 'required'],
32
            [['device_id', 'screen_id'], 'integer'],
33
            [['device_id'], 'exist', 'skipOnError' => true, 'targetClass' => Device::class, 'targetAttribute' => ['device_id' => 'id']],
34
            [['screen_id'], 'exist', 'skipOnError' => true, 'targetClass' => Screen::class, 'targetAttribute' => ['screen_id' => 'id']],
35
        ];
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function attributeLabels()
42
    {
43
        return [
44
            'device_id' => Yii::t('app', 'Device ID'),
45
            'screen_id' => Yii::t('app', 'Screen ID'),
46
        ];
47
    }
48
49
    /**
50
     * @return \yii\db\ActiveQuery
51
     */
52
    public function getDevice()
53
    {
54
        return $this->hasOne(Device::class, ['id' => 'device_id']);
55
    }
56
57
    /**
58
     * @return \yii\db\ActiveQuery
59
     */
60
    public function getScreen()
61
    {
62
        return $this->hasOne(Screen::class, ['id' => 'screen_id']);
63
    }
64
}
65