Completed
Push — master ( e41839...300c8f )
by Tõnis
02:40
created
src/migrations/m170302_104953_create_rejections.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/migrations/m170329_072118_remove_response_code_from_rejection.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,12 +6,12 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/migrations/m170327_130608_rename_rejection_type.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,11 +6,11 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/SurveyHasStatus.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -38,12 +38,12 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Rating.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     /**
Please login to merge, or discard this patch.
src/Survey.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,10 +30,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Respondent.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -185,7 +185,7 @@
 block discarded – undo
185 185
                 if ($i > static::MAX_ALTERNATIVE_CONTACTS) {
186 186
                     $this->addError($attribute, Yii::t('app', 'Maximum alternative phone numbers limit ({0}) reached for {1}', [static::MAX_ALTERNATIVE_CONTACTS, $this->phone_number]));
187 187
                 }
188
-               $this->validatePhoneNumber($attribute, $item);
188
+                $this->validatePhoneNumber($attribute, $item);
189 189
             }
190 190
         }
191 191
         $this->alternative_phone_numbers = yii\helpers\Json::encode($cleanItems);
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
                     $this->addError($attribute, Yii::t('app', 'Duplicate email in alternative email addresses'));
143 143
                 }
144 144
 
145
-                if ($i > static::MAX_ALTERNATIVE_CONTACTS) {
145
+                if ($i>static::MAX_ALTERNATIVE_CONTACTS) {
146 146
                     $this->addError($attribute, Yii::t('app', 'Maximum alternative addresses limit ({0}) reached for {1}', [static::MAX_ALTERNATIVE_CONTACTS, $this->email_address]));
147 147
                 }
148 148
                 $address = strtolower(trim($address));
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
                 $item = strtolower(trim($item));
183 183
                 $this->validateAlternativePhoneNumberInternalDuplicates($attribute, $item, $key);
184 184
 
185
-                if ($i > static::MAX_ALTERNATIVE_CONTACTS) {
185
+                if ($i>static::MAX_ALTERNATIVE_CONTACTS) {
186 186
                     $this->addError($attribute, Yii::t('app', 'Maximum alternative phone numbers limit ({0}) reached for {1}', [static::MAX_ALTERNATIVE_CONTACTS, $this->phone_number]));
187 187
                 }
188 188
                $this->validatePhoneNumber($attribute, $item);
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 
248 248
         $query->andWhere($condition, [':phone_number' => $phone_number, ':phone_number2' => '%\"' . $phone_number . '\"%']);
249 249
 
250
-        if ($query->count() > 0) {
250
+        if ($query->count()>0) {
251 251
             $this->addError($attribute,
252 252
                 Yii::t('app',
253 253
                     'Invalid phone number "{0}"', [$phone_number]
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 
281 281
         $query->andWhere($email_condition, [':email_address' => $email_address, ':email_address2' => '%\"' . $email_address . '\"%']);
282 282
 
283
-        if ($query->count() > 0) {
283
+        if ($query->count()>0) {
284 284
             $this->addError($attribute,
285 285
                 Yii::t('app',
286 286
                     'Invalid email address "{0}"', [$email_address]
@@ -387,14 +387,14 @@  discard block
 block discarded – undo
387 387
         return $query->createCommand()
388 388
             ->update(self::tableName(),
389 389
                 [$field=> $dateHelper->getDatetime6()],
390
-                ['in','token',$tokens]
390
+                ['in', 'token', $tokens]
391 391
             )->execute();
392 392
     }
393 393
 
394 394
     /**
395 395
      * @return array
396 396
      */
397
-    public function getParticipantData(){
397
+    public function getParticipantData() {
398 398
         return [];
399 399
     }
400 400
 
Please login to merge, or discard this patch.
src/Rejection.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     {
44 44
         return array_merge([
45 45
             [['survey_id', 'respondent_id'], 'integer'],
46
-            [['email_address','time_rejected'], 'required'],
46
+            [['email_address', 'time_rejected'], 'required'],
47 47
             [['bounce'], 'string'],
48 48
             [['time_rejected'], 'safe'],
49 49
             [['email_address'], 'string', 'max' => 255],
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
             [['type'], 'string', 'max' => 45],
52 52
             [['respondent_id'], 'exist', 'skipOnError' => true, 'targetClass' => Respondent::class, 'targetAttribute' => ['respondent_id' => 'respondent_id']],
53 53
             [['survey_id'], 'exist', 'skipOnError' => true, 'targetClass' => Survey::class, 'targetAttribute' => ['survey_id' => 'survey_id']],
54
-        ],  parent::rules());
54
+        ], parent::rules());
55 55
     }
56 56
 
57 57
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
      * @param string $email_address
60 60
      * @return bool
61 61
      */
62
-    public static function hasBouncedHard($email_address){
62
+    public static function hasBouncedHard($email_address) {
63 63
         return (!empty(self::findHardBounces($email_address)));
64 64
     }
65 65
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      * @param string $email_address
70 70
      * @return Rejection[]
71 71
      */
72
-    public static function findHardBounces($email_address){
72
+    public static function findHardBounces($email_address) {
73 73
         return Rejection::find()
74 74
             ->andWhere(['email_address'=>$email_address, 'type' => self::BOUNCE_TYPE_HARD])
75 75
             ->all();
@@ -81,13 +81,13 @@  discard block
 block discarded – undo
81 81
      * @param string $code
82 82
      * @return bool
83 83
      */
84
-    public static function rejectedByCode($code){
84
+    public static function rejectedByCode($code) {
85 85
         $respondent = Respondent::findByToken($code);
86
-        if($respondent){
86
+        if ($respondent) {
87 87
             $rejections = self::find()
88 88
                 ->andWhere(['respondent_id'=>$respondent->primaryKey])
89 89
                 ->all();
90
-            if($rejections){
90
+            if ($rejections) {
91 91
                 return true;
92 92
             }
93 93
         }
@@ -100,12 +100,12 @@  discard block
 block discarded – undo
100 100
      * @param string $type
101 101
      * @return bool
102 102
      */
103
-    public static function bouncedByEmailAddress($email_address,$type = self::BOUNCE_TYPE_HARD){
103
+    public static function bouncedByEmailAddress($email_address, $type = self::BOUNCE_TYPE_HARD) {
104 104
         $rejections = self::find()
105 105
             ->andWhere('email_address=:email_address', [':email_address' => $email_address])
106 106
             ->andWhere('type=:type', [':type' => $type])
107 107
             ->all();
108
-        if($rejections){
108
+        if ($rejections) {
109 109
             return true;
110 110
         }
111 111
         return false;
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
      * @param string $email_address
116 116
      * @return Rejection
117 117
      */
118
-    public static function findByEmail($email_address){
118
+    public static function findByEmail($email_address) {
119 119
         return Rejection::findOne(['email_address'=>$email_address]);
120 120
     }
121 121
 
@@ -135,13 +135,13 @@  discard block
 block discarded – undo
135 135
         return $this->hasOne(Respondent::class, ['respondent_id' => 'respondent_id']);
136 136
     }
137 137
 
138
-    public static function getBounceTypes(){
138
+    public static function getBounceTypes() {
139 139
         return [
140
-            self::BOUNCE_TYPE_COMPLAINT => Yii::t('app','Complaint'),
141
-            self::BOUNCE_TYPE_SOFT => Yii::t('app','Soft bounce'),
142
-            self::BOUNCE_TYPE_HARD => Yii::t('app','Hard bounce'),
143
-            self::BOUNCE_TYPE_ANSWERED => Yii::t('app','Respondent has answered already'),
144
-            self::BOUNCE_TYPE_OTHER => Yii::t('app','Other'),
140
+            self::BOUNCE_TYPE_COMPLAINT => Yii::t('app', 'Complaint'),
141
+            self::BOUNCE_TYPE_SOFT => Yii::t('app', 'Soft bounce'),
142
+            self::BOUNCE_TYPE_HARD => Yii::t('app', 'Hard bounce'),
143
+            self::BOUNCE_TYPE_ANSWERED => Yii::t('app', 'Respondent has answered already'),
144
+            self::BOUNCE_TYPE_OTHER => Yii::t('app', 'Other'),
145 145
         ];
146 146
     }
147 147
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
     public function getBounceReason()
158 158
     {
159 159
         if (!empty($this->bounceObject)) {
160
-            if(isset($this->bounceObject->diagnosticcode)) {
160
+            if (isset($this->bounceObject->diagnosticcode)) {
161 161
                 return $this->bounceObject->diagnosticcode;
162 162
             }
163 163
         }
Please login to merge, or discard this patch.