Completed
Branch master (742edb)
by Tõnis
03:25
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
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
                         $this->addError($attribute, Yii::t('app', 'Duplicate email in alternative email addresses'));
144 144
                     }
145 145
 
146
-                    if ($i > static::MAX_ALTERNATIVE_CONTACTS) {
146
+                    if ($i>static::MAX_ALTERNATIVE_CONTACTS) {
147 147
                         $this->addError($attribute, Yii::t('app', 'Maximum alternative addresses limit ({0}) reached for {1}', [static::MAX_ALTERNATIVE_CONTACTS, $this->email_address]));
148 148
                     }
149 149
                     $address = strtolower(trim($address));
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
                 $item = strtolower(trim($item));
185 185
                 $this->validateAlternativePhoneNumberInternalDuplicates($attribute, $item, $key);
186 186
 
187
-                if ($i > static::MAX_ALTERNATIVE_CONTACTS) {
187
+                if ($i>static::MAX_ALTERNATIVE_CONTACTS) {
188 188
                     $this->addError($attribute, Yii::t('app', 'Maximum alternative phone numbers limit ({0}) reached for {1}', [static::MAX_ALTERNATIVE_CONTACTS, $this->phone_number]));
189 189
                 }
190 190
                $this->validatePhoneNumber($attribute, $item);
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 
250 250
         $query->andWhere($condition, [':phone_number' => $phone_number, ':phone_number2' => '%\"' . $phone_number . '\"%']);
251 251
 
252
-        if ($query->count() > 0) {
252
+        if ($query->count()>0) {
253 253
             $this->addError($attribute,
254 254
                 Yii::t('app',
255 255
                     'Invalid phone number "{0}"', [$phone_number]
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 
283 283
         $query->andWhere($email_condition, [':email_address' => $email_address, ':email_address2' => '%\"' . $email_address . '\"%']);
284 284
 
285
-        if ($query->count() > 0) {
285
+        if ($query->count()>0) {
286 286
             $this->addError($attribute,
287 287
                 Yii::t('app',
288 288
                     'Invalid email address "{0}"', [$email_address]
@@ -389,14 +389,14 @@  discard block
 block discarded – undo
389 389
         return $query->createCommand()
390 390
             ->update(self::tableName(),
391 391
                 [$field=> $dateHelper->getDatetime6()],
392
-                ['in','token',$tokens]
392
+                ['in', 'token', $tokens]
393 393
             )->execute();
394 394
     }
395 395
 
396 396
     /**
397 397
      * @return array
398 398
      */
399
-    public function getParticipantData(){
399
+    public function getParticipantData() {
400 400
         return [];
401 401
     }
402 402
 
Please login to merge, or discard this patch.
src/Rejection.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
             [['type'], 'string', 'max' => 45],
57 57
             [['respondent_id'], 'exist', 'skipOnError' => true, 'targetClass' => Respondent::class, 'targetAttribute' => ['respondent_id' => 'respondent_id']],
58 58
             [['survey_id'], 'exist', 'skipOnError' => true, 'targetClass' => Survey::class, 'targetAttribute' => ['survey_id' => 'survey_id']],
59
-        ],  parent::rules());
59
+        ], parent::rules());
60 60
     }
61 61
 
62 62
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
      * @param string $email_address
65 65
      * @return bool
66 66
      */
67
-    public static function hasBouncedHard($email_address){
67
+    public static function hasBouncedHard($email_address) {
68 68
         return (!empty(self::findHardBounces($email_address)));
69 69
     }
70 70
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      * @param string $email_address
75 75
      * @return Rejection[]
76 76
      */
77
-    public static function findHardBounces($email_address){
77
+    public static function findHardBounces($email_address) {
78 78
         return Rejection::find()
79 79
             ->andWhere(['email_address'=>$email_address, 'type' => self::BOUNCE_TYPE_HARD])
80 80
             ->all();
@@ -86,13 +86,13 @@  discard block
 block discarded – undo
86 86
      * @param string $code
87 87
      * @return bool
88 88
      */
89
-    public static function rejectedByCode($code){
89
+    public static function rejectedByCode($code) {
90 90
         $respondent = Respondent::findByToken($code);
91
-        if($respondent){
91
+        if ($respondent) {
92 92
             $rejections = self::find()
93 93
                 ->andWhere(['respondent_id'=>$respondent->primaryKey])
94 94
                 ->all();
95
-            if($rejections){
95
+            if ($rejections) {
96 96
                 return true;
97 97
             }
98 98
         }
@@ -105,12 +105,12 @@  discard block
 block discarded – undo
105 105
      * @param string $type
106 106
      * @return bool
107 107
      */
108
-    public static function bouncedByEmailAddress($email_address,$type = self::BOUNCE_TYPE_HARD){
108
+    public static function bouncedByEmailAddress($email_address, $type = self::BOUNCE_TYPE_HARD) {
109 109
         $rejections = self::find()
110 110
             ->andWhere('email_address=:email_address', [':email_address' => $email_address])
111 111
             ->andWhere('type=:type', [':type' => $type])
112 112
             ->all();
113
-        if($rejections){
113
+        if ($rejections) {
114 114
             return true;
115 115
         }
116 116
         return false;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
      * @param string $email_address
121 121
      * @return Rejection
122 122
      */
123
-    public static function findByEmail($email_address){
123
+    public static function findByEmail($email_address) {
124 124
         return Rejection::findOne(['email_address'=>$email_address]);
125 125
     }
126 126
 
@@ -140,13 +140,13 @@  discard block
 block discarded – undo
140 140
         return $this->hasOne($this->respondentClass, ['respondent_id' => 'respondent_id']);
141 141
     }
142 142
 
143
-    public static function getBounceTypes(){
143
+    public static function getBounceTypes() {
144 144
         return [
145
-            self::BOUNCE_TYPE_COMPLAINT => Yii::t('app','Complaint'),
146
-            self::BOUNCE_TYPE_SOFT => Yii::t('app','Soft bounce'),
147
-            self::BOUNCE_TYPE_HARD => Yii::t('app','Hard bounce'),
148
-            self::BOUNCE_TYPE_ANSWERED => Yii::t('app','Respondent has answered already'),
149
-            self::BOUNCE_TYPE_OTHER => Yii::t('app','Other'),
145
+            self::BOUNCE_TYPE_COMPLAINT => Yii::t('app', 'Complaint'),
146
+            self::BOUNCE_TYPE_SOFT => Yii::t('app', 'Soft bounce'),
147
+            self::BOUNCE_TYPE_HARD => Yii::t('app', 'Hard bounce'),
148
+            self::BOUNCE_TYPE_ANSWERED => Yii::t('app', 'Respondent has answered already'),
149
+            self::BOUNCE_TYPE_OTHER => Yii::t('app', 'Other'),
150 150
         ];
151 151
     }
152 152
 
@@ -165,10 +165,10 @@  discard block
 block discarded – undo
165 165
     public function getBounceReason()
166 166
     {
167 167
         if (!empty($this->bounceObject)) {
168
-            if(isset($this->bounceObject->diagnosticcode)) {
168
+            if (isset($this->bounceObject->diagnosticcode)) {
169 169
                 return $this->bounceObject->diagnosticcode;
170 170
             }
171
-            if(isset($this->bounceObject->reason)) {
171
+            if (isset($this->bounceObject->reason)) {
172 172
                 return $this->bounceObject->reason;
173 173
             }
174 174
         }
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
     public function getBounceReplyCode()
182 182
     {
183 183
         if (!empty($this->bounceObject)) {
184
-            if(isset($this->bounceObject->deliverystatus)) {
184
+            if (isset($this->bounceObject->deliverystatus)) {
185 185
                 return $this->bounceObject->deliverystatus;
186 186
             }
187 187
         }
Please login to merge, or discard this patch.