@@ -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 | } |
@@ -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 | } |
@@ -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); |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $this->addError($attribute, |
99 | 99 | Yii::t('app', |
100 | 100 | 'Invalid email address "{0}"', [$address] |
101 | - ) . ' ' . Yii::t('app', 'Reason: {0}', [Yii::t('app', 'Invalid email format')]) |
|
101 | + ).' '.Yii::t('app', 'Reason: {0}', [Yii::t('app', 'Invalid email format')]) |
|
102 | 102 | ); |
103 | 103 | return false; |
104 | 104 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | private function isSameAsMainAddress($attribute, $address) |
113 | 113 | { |
114 | - if (empty($address) | $attribute == 'email_address' ) { |
|
114 | + if (empty($address) | $attribute == 'email_address') { |
|
115 | 115 | return false; |
116 | 116 | } |
117 | 117 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $this->addError($attribute, |
120 | 120 | Yii::t('app', |
121 | 121 | 'Email address same as main addrress "{0}"', [$address] |
122 | - ) . ' ' . Yii::t('app', 'Reason: {0}', [Yii::t('app', $attribute . ' duplicates main address')]) |
|
122 | + ).' '.Yii::t('app', 'Reason: {0}', [Yii::t('app', $attribute.' duplicates main address')]) |
|
123 | 123 | ); |
124 | 124 | return false; |
125 | 125 | } |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | $this->addError($attribute, |
218 | 218 | Yii::t('app', |
219 | 219 | 'Invalid phone number "{0}"', [$number] |
220 | - ) . ' ' . Yii::t('app', 'Reason: {0}', [Yii::t('app', $attribute . ' duplicates main phone number')]) |
|
220 | + ).' '.Yii::t('app', 'Reason: {0}', [Yii::t('app', $attribute.' duplicates main phone number')]) |
|
221 | 221 | ); |
222 | 222 | } |
223 | 223 | return null; |
@@ -244,13 +244,13 @@ discard block |
||
244 | 244 | '`alternative_phone_numbers` LIKE :phone_number2', |
245 | 245 | ]; |
246 | 246 | |
247 | - $query->andWhere($condition, [':phone_number' => $phone_number, ':phone_number2' => '%\"' . $phone_number . '\"%']); |
|
247 | + $query->andWhere($condition, [':phone_number' => $phone_number, ':phone_number2' => '%\"'.$phone_number.'\"%']); |
|
248 | 248 | |
249 | 249 | if ($query->count() > 0) { |
250 | 250 | $this->addError($attribute, |
251 | 251 | Yii::t('app', |
252 | 252 | 'Invalid phone number "{0}"', [$phone_number] |
253 | - ) . ' ' . Yii::t('app', 'Reason: {0}', [Yii::t('app', 'Duplicate phone number')]) |
|
253 | + ).' '.Yii::t('app', 'Reason: {0}', [Yii::t('app', 'Duplicate phone number')]) |
|
254 | 254 | ); |
255 | 255 | echo $phone_number; |
256 | 256 | die; |
@@ -279,13 +279,13 @@ discard block |
||
279 | 279 | '`alternative_email_addresses` LIKE :email_address2', |
280 | 280 | ]; |
281 | 281 | |
282 | - $query->andWhere($email_condition, [':email_address' => $email_address, ':email_address2' => '%\"' . $email_address . '\"%']); |
|
282 | + $query->andWhere($email_condition, [':email_address' => $email_address, ':email_address2' => '%\"'.$email_address.'\"%']); |
|
283 | 283 | |
284 | 284 | if ($query->count() > 0) { |
285 | 285 | $this->addError($attribute, |
286 | 286 | Yii::t('app', |
287 | 287 | 'Invalid email address "{0}"', [$email_address] |
288 | - ) . ' ' . Yii::t('app', 'Reason: {0}', [Yii::t('app', 'Duplicates some other address')]) |
|
288 | + ).' '.Yii::t('app', 'Reason: {0}', [Yii::t('app', 'Duplicates some other address')]) |
|
289 | 289 | ); |
290 | 290 | return true; |
291 | 291 | } |