Completed
Push — master ( 63529e...72f812 )
by Tõnis
03:16
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   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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,7 +57,7 @@  discard block
 block discarded – undo
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
         return (!empty(self::findHardBounces($email_address)));
62 62
     }
63 63
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      * @param string $email_address
68 68
      * @return Rejection[]
69 69
      */
70
-    public static function findHardBounces($email_address){
70
+    public static function findHardBounces($email_address) {
71 71
         return Rejection::find()
72 72
             ->andWhere(['email_address'=>$email_address, 'type' => self::BOUNCE_TYPE_HARD])
73 73
             ->all();
@@ -79,13 +79,13 @@  discard block
 block discarded – undo
79 79
      * @param string $code
80 80
      * @return bool
81 81
      */
82
-    public static function rejectedByCode($code){
82
+    public static function rejectedByCode($code) {
83 83
         $respondent = Respondent::findByToken($code);
84
-        if($respondent){
84
+        if ($respondent) {
85 85
             $rejections = self::find()
86 86
                 ->andWhere(['respondent_id'=>$respondent->primaryKey])
87 87
                 ->all();
88
-            if($rejections){
88
+            if ($rejections) {
89 89
                 return true;
90 90
             }
91 91
         }
@@ -98,12 +98,12 @@  discard block
 block discarded – undo
98 98
      * @param string $type
99 99
      * @return bool
100 100
      */
101
-    public static function bouncedByEmailAddress($email_address,$type = self::BOUNCE_TYPE_HARD){
101
+    public static function bouncedByEmailAddress($email_address, $type = self::BOUNCE_TYPE_HARD) {
102 102
         $rejections = self::find()
103 103
             ->andWhere('email_address=:email_address', [':email_address' => $email_address])
104 104
             ->andWhere('type=:type', [':type' => $type])
105 105
             ->all();
106
-        if($rejections){
106
+        if ($rejections) {
107 107
             return true;
108 108
         }
109 109
         return false;
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
      * @param string $email_address
114 114
      * @return Rejection
115 115
      */
116
-    public static function findByEmail($email_address){
116
+    public static function findByEmail($email_address) {
117 117
         return Rejection::findOne(['email_address'=>$email_address]);
118 118
     }
119 119
 
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
         return $this->hasOne(Respondent::class, ['respondent_id' => 'respondent_id']);
134 134
     }
135 135
 
136
-    public static function getBounceTypes(){
136
+    public static function getBounceTypes() {
137 137
         return [
138
-            self::BOUNCE_TYPE_COMPLAINT => Yii::t('app','Complaint'),
139
-            self::BOUNCE_TYPE_SOFT => Yii::t('app','Soft bounce'),
140
-            self::BOUNCE_TYPE_HARD => Yii::t('app','Hard bounce'),
141
-            self::BOUNCE_TYPE_ANSWERED => Yii::t('app','Respondent has answered already'),
142
-            self::BOUNCE_TYPE_OTHER => Yii::t('app','Other'),
138
+            self::BOUNCE_TYPE_COMPLAINT => Yii::t('app', 'Complaint'),
139
+            self::BOUNCE_TYPE_SOFT => Yii::t('app', 'Soft bounce'),
140
+            self::BOUNCE_TYPE_HARD => Yii::t('app', 'Hard bounce'),
141
+            self::BOUNCE_TYPE_ANSWERED => Yii::t('app', 'Respondent has answered already'),
142
+            self::BOUNCE_TYPE_OTHER => Yii::t('app', 'Other'),
143 143
         ];
144 144
     }
145 145
 }
Please login to merge, or discard this patch.