GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Setup Failed
Push — email_fix ( a1c2be )
by
unknown
09:01
created

Form::attributeHints()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4286
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace app\models;
4
5
use app\properties\AbstractModel;
6
use app\properties\HasProperties;
7
use Yii;
8
use yii\caching\TagDependency;
9
use yii\data\ActiveDataProvider;
10
use devgroup\TagDependencyHelper\ActiveRecordHelper;
11
12
/**
13
 * This is the model class for table "form".
14
 *
15
 * @property integer $id
16
 * @property string $name
17
 * @property string $form_view
18
 * @property string $form_success_view
19
 * @property string $email_notification_addresses
20
 * @property string $email_notification_view
21
 * @property string $form_open_analytics_action_id
22
 * @property string $form_submit_analytics_action_id
23
 * @property string $subject_template
24
 * @property AbstractModel $abstractModel
25
 */
26
class Form extends \yii\db\ActiveRecord
27
{
28
    private static $identity_map = [];
29
30
    public function behaviors()
31
    {
32
        return [
33
            [
34
                'class' => HasProperties::className(),
35
            ],
36
            [
37
                'class' => \devgroup\TagDependencyHelper\ActiveRecordHelper::className(),
38
            ],
39
        ];
40
    }
41
42
    /**
43
     * @inheritdoc
44
     */
45
    public static function tableName()
46
    {
47
        return '{{%form}}';
48
    }
49
50
    /**
51
     * @inheritdoc
52
     */
53
    public function rules()
54
    {
55
        return [
56
            [['name', 'email_notification_addresses', 'subject_template'], 'required'],
57
            [
58
                [
59
                    'name',
60
                    'form_view',
61
                    'form_success_view',
62
                    'email_notification_addresses',
63
                    'email_notification_view',
64
                    'subject_template'
65
                ],
66
                'string'
67
            ],
68
            [['form_open_analytics_action_id', 'form_submit_analytics_action_id'], 'integer']
69
        ];
70
    }
71
72
    /**
73
     * @inheritdoc
74
     */
75
    public function attributeLabels()
76
    {
77
        return [
78
            'id' => Yii::t('app', 'ID'),
79
            'name' => Yii::t('app', 'Name'),
80
            'form_view' => Yii::t('app', 'Form View'),
81
            'form_success_view' => Yii::t('app', 'Form Success View'),
82
            'email_notification_addresses' => Yii::t('app', 'Email Notification Addresses'),
83
            'email_notification_view' => Yii::t('app', 'Email Notification View'),
84
            'form_open_analytics_action_id' => Yii::t('app', 'Form Open Analytics Action ID'),
85
            'form_submit_analytics_action_id' => Yii::t('app', 'Form Submit Analytics Action ID'),
86
            'properties' => Yii::t('app', 'Properties'),
87
            'subject_template' => Yii::t('app', 'Subject Template'),
88
        ];
89
    }
90
91
    public function attributeHints()
92
    {
93
        return [
94
            'subject_template' => Yii::t('app',
95
                'You can use properties {keys}, submission id as {id}, form name as {form_name}'),
96
        ];
97
    }
98
99
    /**
100
     * @param array $params
101
     * @return ActiveDataProvider
102
     */
103
    public function search($params)
104
    {
105
        /* @var $query \yii\db\ActiveQuery */
106
        $query = self::find();
107
108
        $dataProvider = new ActiveDataProvider(
109
            [
110
                'query' => $query,
111
                'pagination' => [
112
                    'pageSize' => 10,
113
                ],
114
            ]
115
        );
116
117
        if (!($this->load($params))) {
118
            return $dataProvider;
119
        }
120
121
        $query->andFilterWhere(['id' => $this->id]);
122
        $query->andFilterWhere(['like', 'name', $this->name]);
123
        $query->andFilterWhere(['like', 'form_view', $this->form_view]);
124
        $query->andFilterWhere(['like', 'form_success_view', $this->form_success_view]);
125
        $query->andFilterWhere(['like', 'email_notification_addresses', $this->email_notification_addresses]);
126
        $query->andFilterWhere(['like', 'email_notification_view', $this->email_notification_view]);
127
        $query->andFilterWhere(['form_open_analytics_action_id', $this->form_open_analytics_action_id]);
128
        $query->andFilterWhere(['form_submit_analytics_action_id', $this->form_submit_analytics_action_id]);
129
130
        return $dataProvider;
131
    }
132
133
    /**
134
     * @return Submission[]|array
135
     */
136
    public function getSubmissions()
137
    {
138
        return $this->hasMany(Submission::className(), ['form_id' => 'id'])->inverseOf('form');
139
    }
140
141
    /**
142
     * @param int $id
0 ignored issues
show
Documentation introduced by
Should the type for parameter $id not be integer|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
143
     * @return Form|null
144
     */
145
    public static function findById($id = null)
146
    {
147
        if (null === $id) {
148
            return null;
149
        }
150
        $id = intval($id);
151
        if (!isset(static::$identity_map[$id])) {
152
            $cacheKey = "Form:$id";
153
            if (false === $cache = Yii::$app->cache->get($cacheKey)) {
154
                if (null === $cache = static::findOne(['id' => $id])) {
155
                    return null;
156
                }
157
                Yii::$app->cache->set(
158
                    $cacheKey,
159
                    $cache,
160
                    0,
161
                    new TagDependency([
162
                        'tags' => [
163
                            ActiveRecordHelper::getObjectTag(static::className(), $id),
164
                            ActiveRecordHelper::getCommonTag(static::className()),
165
                        ]
166
                    ])
167
                );
168
            }
169
            static::$identity_map[$id] = $cache;
170
        }
171
        return static::$identity_map[$id];
172
    }
173
}