@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | class m170302_104953_create_rejections extends Migration |
6 | 6 | { |
7 | - private $tableName ='rejection'; |
|
7 | + private $tableName = 'rejection'; |
|
8 | 8 | |
9 | 9 | |
10 | 10 | public function safeUp() |
@@ -21,17 +21,17 @@ discard block |
||
21 | 21 | 'time_rejected' => $this->dateTime()->notNull()->comment('Rejection time'), |
22 | 22 | ]); |
23 | 23 | |
24 | - $this->addForeignKey('fk_rejection_survey_id',$this->tableName,'survey_id','survey','survey_id'); |
|
25 | - $this->addForeignKey('fk_rejection_respondent_id','rejection','respondent_id','respondent','respondent_id'); |
|
24 | + $this->addForeignKey('fk_rejection_survey_id', $this->tableName, 'survey_id', 'survey', 'survey_id'); |
|
25 | + $this->addForeignKey('fk_rejection_respondent_id', 'rejection', 'respondent_id', 'respondent', 'respondent_id'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | } |
29 | 29 | |
30 | 30 | public function safeDown() |
31 | 31 | { |
32 | - $this->dropForeignKey('fk_rejection_survey_id',$this->tableName); |
|
33 | - $this->dropForeignKey('fk_rejection_email_id',$this->tableName); |
|
34 | - $this->dropForeignKey('fk_rejection_respondent_id',$this->tableName); |
|
32 | + $this->dropForeignKey('fk_rejection_survey_id', $this->tableName); |
|
33 | + $this->dropForeignKey('fk_rejection_email_id', $this->tableName); |
|
34 | + $this->dropForeignKey('fk_rejection_respondent_id', $this->tableName); |
|
35 | 35 | $this->dropTable($this->tableName); |
36 | 36 | } |
37 | 37 | } |
@@ -6,12 +6,12 @@ |
||
6 | 6 | { |
7 | 7 | public function safeUp() |
8 | 8 | { |
9 | - $this->dropColumn('rejection','response_code'); |
|
9 | + $this->dropColumn('rejection', 'response_code'); |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | public function safeDown() |
13 | 13 | { |
14 | - $this->addColumn('rejection','response_code',$this->integer(4)->after('type') |
|
14 | + $this->addColumn('rejection', 'response_code', $this->integer(4)->after('type') |
|
15 | 15 | ->comment('Email response code in case of bounce')); |
16 | 16 | } |
17 | 17 | } |
@@ -6,11 +6,11 @@ |
||
6 | 6 | { |
7 | 7 | public function safeUp() |
8 | 8 | { |
9 | - $this->renameColumn('rejection','bounce_type','type'); |
|
9 | + $this->renameColumn('rejection', 'bounce_type', 'type'); |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | public function safeDown() |
13 | 13 | { |
14 | - $this->renameColumn('rejection','type','bounce_type'); |
|
14 | + $this->renameColumn('rejection', 'type', 'bounce_type'); |
|
15 | 15 | } |
16 | 16 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | { |
42 | 42 | return array_merge([ |
43 | 43 | [['survey_id', 'respondent_id'], 'integer'], |
44 | - [['email_address','time_rejected'], 'required'], |
|
44 | + [['email_address', 'time_rejected'], 'required'], |
|
45 | 45 | [['bounce'], 'string'], |
46 | 46 | [['time_rejected'], 'safe'], |
47 | 47 | [['email_address'], 'string', 'max' => 255], |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | [['type'], 'string', 'max' => 45], |
50 | 50 | [['respondent_id'], 'exist', 'skipOnError' => true, 'targetClass' => Respondent::class, 'targetAttribute' => ['respondent_id' => 'respondent_id']], |
51 | 51 | [['survey_id'], 'exist', 'skipOnError' => true, 'targetClass' => Survey::class, 'targetAttribute' => ['survey_id' => 'survey_id']], |
52 | - ], parent::rules()); |
|
52 | + ], parent::rules()); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | * @param string $email_address |
58 | 58 | * @return bool |
59 | 59 | */ |
60 | - public static function hasBouncedHard($email_address){ |
|
60 | + public static function hasBouncedHard($email_address) { |
|
61 | 61 | $rejection = Rejection::findByEmail($email_address); |
62 | - if($rejection){ |
|
62 | + if ($rejection) { |
|
63 | 63 | return true; |
64 | 64 | } |
65 | 65 | return false; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @param string $email_address |
72 | 72 | * @return Rejection[] |
73 | 73 | */ |
74 | - public static function findHardBounces($email_address){ |
|
74 | + public static function findHardBounces($email_address) { |
|
75 | 75 | return Rejection::find() |
76 | 76 | ->andWhere(['email_address'=>$email_address]) |
77 | 77 | |
@@ -84,13 +84,13 @@ discard block |
||
84 | 84 | * @param string $code |
85 | 85 | * @return bool |
86 | 86 | */ |
87 | - public static function rejectedByCode($code){ |
|
87 | + public static function rejectedByCode($code) { |
|
88 | 88 | $respondent = Respondent::findByToken($code); |
89 | - if($respondent){ |
|
89 | + if ($respondent) { |
|
90 | 90 | $rejections = self::find() |
91 | 91 | ->andWhere(['respondent_id'=>$respondent->primaryKey]) |
92 | 92 | ->all(); |
93 | - if($rejections){ |
|
93 | + if ($rejections) { |
|
94 | 94 | return true; |
95 | 95 | } |
96 | 96 | } |
@@ -103,12 +103,12 @@ discard block |
||
103 | 103 | * @param string $type |
104 | 104 | * @return bool |
105 | 105 | */ |
106 | - public static function bouncedByEmailAddress($email_address,$type = self::BOUNCE_TYPE_HARD){ |
|
106 | + public static function bouncedByEmailAddress($email_address, $type = self::BOUNCE_TYPE_HARD) { |
|
107 | 107 | $rejections = self::find() |
108 | 108 | ->andWhere('email_address=:email_address', [':email_address' => $email_address]) |
109 | 109 | ->andWhere('type=:type', [':type' => $type]) |
110 | 110 | ->all(); |
111 | - if($rejections){ |
|
111 | + if ($rejections) { |
|
112 | 112 | return true; |
113 | 113 | } |
114 | 114 | return false; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * @param string $email_address |
119 | 119 | * @return Rejection |
120 | 120 | */ |
121 | - public static function findByEmail($email_address){ |
|
121 | + public static function findByEmail($email_address) { |
|
122 | 122 | return Rejection::findOne(['email_address'=>$email_address]); |
123 | 123 | } |
124 | 124 | |
@@ -138,13 +138,13 @@ discard block |
||
138 | 138 | return $this->hasOne(Respondent::class, ['respondent_id' => 'respondent_id']); |
139 | 139 | } |
140 | 140 | |
141 | - public static function getBounceTypes(){ |
|
141 | + public static function getBounceTypes() { |
|
142 | 142 | return [ |
143 | - self::BOUNCE_TYPE_COMPLAINT => Yii::t('app','Complaint'), |
|
144 | - self::BOUNCE_TYPE_SOFT => Yii::t('app','Soft bounce'), |
|
145 | - self::BOUNCE_TYPE_HARD => Yii::t('app','Hard bounce'), |
|
146 | - self::BOUNCE_TYPE_ANSWERED => Yii::t('app','Respondent has answered already'), |
|
147 | - self::BOUNCE_TYPE_OTHER => Yii::t('app','Other'), |
|
143 | + self::BOUNCE_TYPE_COMPLAINT => Yii::t('app', 'Complaint'), |
|
144 | + self::BOUNCE_TYPE_SOFT => Yii::t('app', 'Soft bounce'), |
|
145 | + self::BOUNCE_TYPE_HARD => Yii::t('app', 'Hard bounce'), |
|
146 | + self::BOUNCE_TYPE_ANSWERED => Yii::t('app', 'Respondent has answered already'), |
|
147 | + self::BOUNCE_TYPE_OTHER => Yii::t('app', 'Other'), |
|
148 | 148 | ]; |
149 | 149 | } |
150 | 150 | } |
@@ -38,12 +38,12 @@ discard block |
||
38 | 38 | * @param string $status if not set Status will be taken from Email |
39 | 39 | * @return boolean |
40 | 40 | */ |
41 | - public static function create($survey,$status = null){ |
|
41 | + public static function create($survey, $status = null) { |
|
42 | 42 | $model = new static(); |
43 | 43 | $model->survey_id = $survey->primaryKey; |
44 | - $model->status =$survey->status; |
|
45 | - if($status){ |
|
46 | - $model->status =$status; |
|
44 | + $model->status = $survey->status; |
|
45 | + if ($status) { |
|
46 | + $model->status = $status; |
|
47 | 47 | } |
48 | 48 | return $model->save(); |
49 | 49 | } |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | public function rules() |
55 | 55 | { |
56 | 56 | return array_merge([ |
57 | - [['survey_id','status'], 'required'], |
|
57 | + [['survey_id', 'status'], 'required'], |
|
58 | 58 | [['status'], 'string', 'max' => 32], |
59 | 59 | [['survey_id'], 'integer'], |
60 | - ], parent::rules()); |
|
60 | + ], parent::rules()); |
|
61 | 61 | } |
62 | 62 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public static function modelName() |
36 | 36 | { |
37 | - return Yii::t('app','Rating'); |
|
37 | + return Yii::t('app', 'Rating'); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | [['respondent_id', 'survey_id', 'sample_id', 'value'], 'integer'], |
50 | 50 | [['comment'], 'string'], |
51 | 51 | [['respondent_id'], 'exist', 'skipOnError' => true, 'targetClass' => Respondent::class, 'targetAttribute' => ['respondent_id' => 'respondent_id']], |
52 | - ], parent::rules()); |
|
52 | + ], parent::rules()); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | public function rules() |
31 | 31 | { |
32 | 32 | return array_merge([ |
33 | - [['name','status'], 'required'], |
|
33 | + [['name', 'status'], 'required'], |
|
34 | 34 | [['name', 'status'], 'string', 'max' => 255], |
35 | - [['name'], 'string','max' => 500], |
|
36 | - [['options'], 'string','max' => 1024 * 10], |
|
35 | + [['name'], 'string', 'max' => 500], |
|
36 | + [['options'], 'string', 'max' => 1024 * 10], |
|
37 | 37 | ], parent::rules()); |
38 | 38 | } |
39 | 39 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | /** |
65 | 65 | * @return mixed |
66 | 66 | */ |
67 | - public function getOptionsDecoded(){ |
|
67 | + public function getOptionsDecoded() { |
|
68 | 68 | return json_decode($this->options); |
69 | 69 | } |
70 | 70 |
@@ -172,7 +172,7 @@ |
||
172 | 172 | if ($i >= static::MAX_ALTERNATIVE_CONTACTS) { |
173 | 173 | $this->addError($attribute, Yii::t('app', 'Maximum alternative phone numbers limit ({0}) reached for {1}', [static::MAX_ALTERNATIVE_CONTACTS, $this->phone_number])); |
174 | 174 | } |
175 | - $this->validatePhoneNumber($attribute, $item); |
|
175 | + $this->validatePhoneNumber($attribute, $item); |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | $this->alternative_phone_numbers = yii\helpers\Json::encode($cleanItems); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $this->addError($attribute, |
94 | 94 | Yii::t('app', |
95 | 95 | 'Invalid email address "{0}"', [$address] |
96 | - ) . ' ' . Yii::t('app', 'Reason: {0}', [Yii::t('app', 'Invalid email format')]) |
|
96 | + ).' '.Yii::t('app', 'Reason: {0}', [Yii::t('app', 'Invalid email format')]) |
|
97 | 97 | ); |
98 | 98 | return false; |
99 | 99 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | $this->addError($attribute, |
116 | 116 | Yii::t('app', |
117 | 117 | 'Invalid email address "{0}"', [$address] |
118 | - ) . ' ' . Yii::t('app', 'Reason: {0}', [Yii::t('app', $attribute . ' duplicates main address')]) |
|
118 | + ).' '.Yii::t('app', 'Reason: {0}', [Yii::t('app', $attribute.' duplicates main address')]) |
|
119 | 119 | ); |
120 | 120 | return false; |
121 | 121 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | $this->addError($attribute, |
209 | 209 | Yii::t('app', |
210 | 210 | 'Invalid phone number "{0}"', [$number] |
211 | - ) . ' ' . Yii::t('app', 'Reason: {0}', [Yii::t('app', $attribute . ' duplicates main phone number')]) |
|
211 | + ).' '.Yii::t('app', 'Reason: {0}', [Yii::t('app', $attribute.' duplicates main phone number')]) |
|
212 | 212 | ); |
213 | 213 | } |
214 | 214 | return null; |
@@ -235,13 +235,13 @@ discard block |
||
235 | 235 | '`alternative_phone_numbers` LIKE :phone_number2', |
236 | 236 | ]; |
237 | 237 | |
238 | - $query->andWhere($condition, [':phone_number' => $phone_number, ':phone_number2' => '%\"' . $phone_number . '\"%']); |
|
238 | + $query->andWhere($condition, [':phone_number' => $phone_number, ':phone_number2' => '%\"'.$phone_number.'\"%']); |
|
239 | 239 | |
240 | 240 | if ($query->count() > 0) { |
241 | 241 | $this->addError($attribute, |
242 | 242 | Yii::t('app', |
243 | 243 | 'Invalid phone number "{0}"', [$phone_number] |
244 | - ) . ' ' . Yii::t('app', 'Reason: {0}', [Yii::t('app', 'Duplicate phone number')]) |
|
244 | + ).' '.Yii::t('app', 'Reason: {0}', [Yii::t('app', 'Duplicate phone number')]) |
|
245 | 245 | ); |
246 | 246 | } |
247 | 247 | } |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | '`email_address`=:email_address', |
267 | 267 | '`alternative_email_addresses` LIKE :email_address2', |
268 | 268 | ]; |
269 | - $query->andWhere($email_condition, [':email_address' => $email_address, ':email_address2' => '%\"' . $email_address . '\"%']); |
|
269 | + $query->andWhere($email_condition, [':email_address' => $email_address, ':email_address2' => '%\"'.$email_address.'\"%']); |
|
270 | 270 | if ($query->count() > 0) { |
271 | 271 | return true; |
272 | 272 | } |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | $this->addError($attribute, |
275 | 275 | Yii::t('app', |
276 | 276 | 'Invalid email address "{0}"', [$email_address] |
277 | - ) . ' ' . Yii::t('app', 'Reason: {0}', [Yii::t('app', 'Duplicates some other address')]) |
|
277 | + ).' '.Yii::t('app', 'Reason: {0}', [Yii::t('app', 'Duplicates some other address')]) |
|
278 | 278 | ); |
279 | 279 | |
280 | 280 | return false; |