@@ -36,13 +36,13 @@ discard block |
||
| 36 | 36 | * @return \DateTime the parsed time or the default value |
| 37 | 37 | */ |
| 38 | 38 | public function parse($time, $default = false, string $format = 'Y-m-d') { |
| 39 | - if(is_string($time)) { |
|
| 39 | + if (is_string($time)) { |
|
| 40 | 40 | $dt = DateTime::createFromFormat($format, $time, new DateTimeZone($this->timezone)); |
| 41 | - if($dt) { |
|
| 41 | + if ($dt) { |
|
| 42 | 42 | // for some reason, using createFromFromat adds in the time. The regular DateTime constructor _does not_ do this. We manually zero out the time here to make the DateTime objects match. |
| 43 | 43 | $dt->setTime(0, 0, 0); |
| 44 | 44 | $formatted = $dt->format($format); |
| 45 | - if($formatted === $time && $this->inBounds($dt)) { |
|
| 45 | + if ($formatted === $time && $this->inBounds($dt)) { |
|
| 46 | 46 | return $dt; |
| 47 | 47 | } |
| 48 | 48 | } |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $test = strtotime($dt->format('Y-m-d')); |
| 63 | 63 | $now = strtotime($this->getLocalDate()); |
| 64 | 64 | |
| 65 | - if($first <= $test && $test <= $now) { |
|
| 65 | + if ($first <= $test && $test <= $now) { |
|
| 66 | 66 | return true; |
| 67 | 67 | } else { |
| 68 | 68 | return false; |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | public function getLocalTime($timezone = null) { |
| 89 | - if($timezone === null) |
|
| 89 | + if ($timezone === null) |
|
| 90 | 90 | $timezone = $this->timezone; |
| 91 | 91 | |
| 92 | 92 | $timestamp = new DateTime("now", new DateTimeZone($timezone)); |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | public function getLocalDate($timezone = null) { |
| 97 | - if($timezone === null) |
|
| 97 | + if ($timezone === null) |
|
| 98 | 98 | $timezone = $this->timezone; |
| 99 | 99 | |
| 100 | 100 | return (new DateTime("now", new DateTimeZone($timezone))) |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | public function getUTCBookends($local) { |
| 110 | 110 | $local = trim($local); |
| 111 | - if(strpos($local, " ")) { |
|
| 111 | + if (strpos($local, " ")) { |
|
| 112 | 112 | return false; |
| 113 | 113 | } |
| 114 | 114 | |
@@ -130,9 +130,9 @@ discard block |
||
| 130 | 130 | * @return string a date string |
| 131 | 131 | */ |
| 132 | 132 | public function validate($date = null) { |
| 133 | - if(is_null($date)) { |
|
| 133 | + if (is_null($date)) { |
|
| 134 | 134 | return $this->getLocalDate(); |
| 135 | - } else if($dt = $this->parse($date)) { |
|
| 135 | + } else if ($dt = $this->parse($date)) { |
|
| 136 | 136 | return $dt->format('Y-m-d'); |
| 137 | 137 | } else { |
| 138 | 138 | return $this->getLocalDate(); |
@@ -151,15 +151,15 @@ discard block |
||
| 151 | 151 | $start = new DateTime("now", new DateTimeZone($this->timezone)); |
| 152 | 152 | $end = new DateTime("now", new DateTimeZone($this->timezone)); |
| 153 | 153 | $oneday = new \DateInterval('P1D'); |
| 154 | - $end->add($oneday); // add a day, so the end date gets included in the intervals |
|
| 154 | + $end->add($oneday); // add a day, so the end date gets included in the intervals |
|
| 155 | 155 | |
| 156 | 156 | $start->add(new \DateInterval('PT2M')) // add two minutes, in case they just did a check-in |
| 157 | 157 | ->sub(new \DateInterval("P${period}D")); // subtract `$period` number of days |
| 158 | - $end->add(new \DateInterval('PT2M')); // add two minutes, in case they just did a check-in |
|
| 158 | + $end->add(new \DateInterval('PT2M')); // add two minutes, in case they just did a check-in |
|
| 159 | 159 | |
| 160 | 160 | $periods = new \DatePeriod($start, $oneday, $end, \DatePeriod::EXCLUDE_START_DATE); |
| 161 | 161 | $local_tz = new \DateTimeZone($this->timezone); |
| 162 | - foreach($periods as $period) { |
|
| 162 | + foreach ($periods as $period) { |
|
| 163 | 163 | $period->setTimezone($local_tz); |
| 164 | 164 | } |
| 165 | 165 | return $periods; |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | */ |
| 144 | 144 | public function findByPasswordResetToken($token) |
| 145 | 145 | { |
| 146 | - if(!$this->isTokenCurrent($token)) { |
|
| 146 | + if (!$this->isTokenCurrent($token)) { |
|
| 147 | 147 | return null; |
| 148 | 148 | } |
| 149 | 149 | |
@@ -161,15 +161,15 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | public function findByVerifyEmailToken($token) |
| 163 | 163 | { |
| 164 | - if($this->isTokenConfirmed($token)) return null; |
|
| 164 | + if ($this->isTokenConfirmed($token)) return null; |
|
| 165 | 165 | |
| 166 | 166 | $user = $this->findOne([ |
| 167 | 167 | 'verify_email_token' => [$token, $token . self::CONFIRMED_STRING], |
| 168 | 168 | 'status' => self::STATUS_ACTIVE, |
| 169 | 169 | ]); |
| 170 | 170 | |
| 171 | - if($user) { |
|
| 172 | - if(!$this->isTokenConfirmed($token) && |
|
| 171 | + if ($user) { |
|
| 172 | + if (!$this->isTokenConfirmed($token) && |
|
| 173 | 173 | !$this->isTokenCurrent($token, 'user.verifyAccountTokenExpire')) { |
| 174 | 174 | return null; |
| 175 | 175 | } |
@@ -191,8 +191,8 @@ discard block |
||
| 191 | 191 | 'status' => self::STATUS_ACTIVE, |
| 192 | 192 | ]); |
| 193 | 193 | |
| 194 | - if($user) { |
|
| 195 | - if(!$user->isTokenCurrent($token, 'user.verifyAccountTokenExpire')) { |
|
| 194 | + if ($user) { |
|
| 195 | + if (!$user->isTokenCurrent($token, 'user.verifyAccountTokenExpire')) { |
|
| 196 | 196 | return null; |
| 197 | 197 | } |
| 198 | 198 | } |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | public function isTokenCurrent($token, String $paramPath = 'user.passwordResetTokenExpire') { |
| 211 | 211 | $expire = \Yii::$app->params[$paramPath]; |
| 212 | 212 | $parts = explode('_', $token); |
| 213 | - $timestamp = (int) end($parts); |
|
| 213 | + $timestamp = (int)end($parts); |
|
| 214 | 214 | if ($timestamp + $expire < time()) { |
| 215 | 215 | // token expired |
| 216 | 216 | return false; |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | * @param string $match the needle to search for |
| 226 | 226 | */ |
| 227 | 227 | public function isTokenConfirmed($token = null, String $match = self::CONFIRMED_STRING) { |
| 228 | - if(is_null($token)) $token = $this->verify_email_token; |
|
| 228 | + if (is_null($token)) $token = $this->verify_email_token; |
|
| 229 | 229 | return substr($token, -strlen($match)) === $match; |
| 230 | 230 | } |
| 231 | 231 | |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | public function isVerified() { |
| 253 | - if(is_null($this->verify_email_token)) { |
|
| 253 | + if (is_null($this->verify_email_token)) { |
|
| 254 | 254 | // for old users who verified their accounts before the addition of |
| 255 | 255 | // '_confirmed' to the token |
| 256 | 256 | return true; |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | * partner email address the user has set. |
| 370 | 370 | */ |
| 371 | 371 | public function sendEmailReport($date) { |
| 372 | - if(!$this->send_email) return false; // no partner emails set |
|
| 372 | + if (!$this->send_email) return false; // no partner emails set |
|
| 373 | 373 | list($start, $end) = $this->time->getUTCBookends($date); |
| 374 | 374 | |
| 375 | 375 | $user_behavior = Yii::$container->get(UserBehaviorInterface::class); |
@@ -378,14 +378,14 @@ discard block |
||
| 378 | 378 | // we should only proceed with sending the email if the user |
| 379 | 379 | // scored above their set email threshold (User::email_category) |
| 380 | 380 | $this_checkin = $checkins_last_month[$date]; // gets the check-in |
| 381 | - if(!$this_checkin) return false; // sanity check |
|
| 382 | - $highest_cat_data = end($this_checkin); // gets the data for the highest category from the check-in |
|
| 383 | - if(!$highest_cat_data) return false; // another sanity check |
|
| 381 | + if (!$this_checkin) return false; // sanity check |
|
| 382 | + $highest_cat_data = end($this_checkin); // gets the data for the highest category from the check-in |
|
| 383 | + if (!$highest_cat_data) return false; // another sanity check |
|
| 384 | 384 | $highest_cat_idx = key($this_checkin); // gets the key of the highest category |
| 385 | 385 | |
| 386 | 386 | // if the highest category they reached today was less than |
| 387 | 387 | // the category threshold they have set, don't send the email |
| 388 | - if($highest_cat_idx < $this->email_category) return false; |
|
| 388 | + if ($highest_cat_idx < $this->email_category) return false; |
|
| 389 | 389 | |
| 390 | 390 | $graph = Yii::$container |
| 391 | 391 | ->get(\common\components\Graph::class) |
@@ -395,8 +395,8 @@ discard block |
||
| 395 | 395 | $user_questions = $this->getUserQuestions($date); |
| 396 | 396 | |
| 397 | 397 | $messages = []; |
| 398 | - foreach($this->getPartnerEmails() as $email) { |
|
| 399 | - if($email) { |
|
| 398 | + foreach ($this->getPartnerEmails() as $email) { |
|
| 399 | + if ($email) { |
|
| 400 | 400 | $messages[] = Yii::$app->mailer->compose('checkinReport', [ |
| 401 | 401 | 'user' => $this, |
| 402 | 402 | 'email' => $email, |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | 'behaviors_list' => \common\models\Behavior::$behaviors, |
| 409 | 409 | ])->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name]) |
| 410 | 410 | ->setReplyTo($this->email) |
| 411 | - ->setSubject($this->email." has completed a Faster Scale check-in") |
|
| 411 | + ->setSubject($this->email . " has completed a Faster Scale check-in") |
|
| 412 | 412 | ->setTo($email); |
| 413 | 413 | } |
| 414 | 414 | } |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | return \Yii::$app->mailer->compose('signupNotification') |
| 482 | 482 | ->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name]) |
| 483 | 483 | ->setTo(\Yii::$app->params['adminEmail']) |
| 484 | - ->setSubject('A new user has signed up for '.\Yii::$app->name) |
|
| 484 | + ->setSubject('A new user has signed up for ' . \Yii::$app->name) |
|
| 485 | 485 | ->send(); |
| 486 | 486 | } |
| 487 | 487 | |
@@ -489,20 +489,20 @@ discard block |
||
| 489 | 489 | return \Yii::$app->mailer->compose('verifyEmail', ['user' => $this]) |
| 490 | 490 | ->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name]) |
| 491 | 491 | ->setTo($this->email) |
| 492 | - ->setSubject('Please verify your '.\Yii::$app->name .' account') |
|
| 492 | + ->setSubject('Please verify your ' . \Yii::$app->name . ' account') |
|
| 493 | 493 | ->send(); |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | public function sendDeleteNotificationEmail() { |
| 497 | 497 | $messages = []; |
| 498 | - foreach(array_merge([$this->email], $this->getPartnerEmails()) as $email) { |
|
| 499 | - if($email) { |
|
| 498 | + foreach (array_merge([$this->email], $this->getPartnerEmails()) as $email) { |
|
| 499 | + if ($email) { |
|
| 500 | 500 | $messages[] = Yii::$app->mailer->compose('deleteNotification', [ |
| 501 | 501 | 'user' => $this, |
| 502 | 502 | 'email' => $email |
| 503 | 503 | ])->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name]) |
| 504 | 504 | ->setReplyTo($this->email) |
| 505 | - ->setSubject($this->email." has deleted their The Faster Scale App account") |
|
| 505 | + ->setSubject($this->email . " has deleted their The Faster Scale App account") |
|
| 506 | 506 | ->setTo($email); |
| 507 | 507 | } |
| 508 | 508 | } |
@@ -511,13 +511,13 @@ discard block |
||
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | public function getUserQuestions($local_date = null) { |
| 514 | - if(is_null($local_date)) $local_date = $this->time->getLocalDate(); |
|
| 514 | + if (is_null($local_date)) $local_date = $this->time->getLocalDate(); |
|
| 515 | 515 | $questions = $this->getQuestionData($local_date); |
| 516 | 516 | return $this->parseQuestionData($questions); |
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | public function getUserBehaviors($local_date = null) { |
| 520 | - if(is_null($local_date)) $local_date = $this->time->getLocalDate(); |
|
| 520 | + if (is_null($local_date)) $local_date = $this->time->getLocalDate(); |
|
| 521 | 521 | |
| 522 | 522 | $behaviors = $this->getBehaviorData($local_date); |
| 523 | 523 | $behaviors = \common\models\UserBehavior::decorateWithCategory($behaviors); |
@@ -525,10 +525,10 @@ discard block |
||
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | public function parseQuestionData($questions) { |
| 528 | - if(!$questions) return []; |
|
| 528 | + if (!$questions) return []; |
|
| 529 | 529 | |
| 530 | 530 | $question_answers = []; |
| 531 | - foreach($questions as $question) { |
|
| 531 | + foreach ($questions as $question) { |
|
| 532 | 532 | $behavior = $question['behavior']; |
| 533 | 533 | |
| 534 | 534 | $question_answers[$behavior['id']]['question'] = [ |
@@ -546,10 +546,10 @@ discard block |
||
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | public function parseBehaviorData($behaviors) { |
| 549 | - if(!$behaviors) return []; |
|
| 549 | + if (!$behaviors) return []; |
|
| 550 | 550 | |
| 551 | 551 | $opts_by_cat = []; |
| 552 | - foreach($behaviors as $behavior) { |
|
| 552 | + foreach ($behaviors as $behavior) { |
|
| 553 | 553 | $indx = $behavior['behavior']['category_id']; |
| 554 | 554 | |
| 555 | 555 | $opts_by_cat[$indx]['category_name'] = $behavior['behavior']['category']['name']; |
@@ -642,7 +642,7 @@ discard block |
||
| 642 | 642 | return rtrim( |
| 643 | 643 | strtr( |
| 644 | 644 | base64_encode( |
| 645 | - hash('sha256', $this->id."::".$this->created_at, true) |
|
| 645 | + hash('sha256', $this->id . "::" . $this->created_at, true) |
|
| 646 | 646 | ), |
| 647 | 647 | '+/', '-_'), |
| 648 | 648 | '='); |
@@ -161,7 +161,9 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | public function findByVerifyEmailToken($token) |
| 163 | 163 | { |
| 164 | - if($this->isTokenConfirmed($token)) return null; |
|
| 164 | + if($this->isTokenConfirmed($token)) { |
|
| 165 | + return null; |
|
| 166 | + } |
|
| 165 | 167 | |
| 166 | 168 | $user = $this->findOne([ |
| 167 | 169 | 'verify_email_token' => [$token, $token . self::CONFIRMED_STRING], |
@@ -225,7 +227,9 @@ discard block |
||
| 225 | 227 | * @param string $match the needle to search for |
| 226 | 228 | */ |
| 227 | 229 | public function isTokenConfirmed($token = null, String $match = self::CONFIRMED_STRING) { |
| 228 | - if(is_null($token)) $token = $this->verify_email_token; |
|
| 230 | + if(is_null($token)) { |
|
| 231 | + $token = $this->verify_email_token; |
|
| 232 | + } |
|
| 229 | 233 | return substr($token, -strlen($match)) === $match; |
| 230 | 234 | } |
| 231 | 235 | |
@@ -369,7 +373,10 @@ discard block |
||
| 369 | 373 | * partner email address the user has set. |
| 370 | 374 | */ |
| 371 | 375 | public function sendEmailReport($date) { |
| 372 | - if(!$this->send_email) return false; // no partner emails set |
|
| 376 | + if(!$this->send_email) { |
|
| 377 | + return false; |
|
| 378 | + } |
|
| 379 | + // no partner emails set |
|
| 373 | 380 | list($start, $end) = $this->time->getUTCBookends($date); |
| 374 | 381 | |
| 375 | 382 | $user_behavior = Yii::$container->get(UserBehaviorInterface::class); |
@@ -378,14 +385,22 @@ discard block |
||
| 378 | 385 | // we should only proceed with sending the email if the user |
| 379 | 386 | // scored above their set email threshold (User::email_category) |
| 380 | 387 | $this_checkin = $checkins_last_month[$date]; // gets the check-in |
| 381 | - if(!$this_checkin) return false; // sanity check |
|
| 388 | + if(!$this_checkin) { |
|
| 389 | + return false; |
|
| 390 | + } |
|
| 391 | + // sanity check |
|
| 382 | 392 | $highest_cat_data = end($this_checkin); // gets the data for the highest category from the check-in |
| 383 | - if(!$highest_cat_data) return false; // another sanity check |
|
| 393 | + if(!$highest_cat_data) { |
|
| 394 | + return false; |
|
| 395 | + } |
|
| 396 | + // another sanity check |
|
| 384 | 397 | $highest_cat_idx = key($this_checkin); // gets the key of the highest category |
| 385 | 398 | |
| 386 | 399 | // if the highest category they reached today was less than |
| 387 | 400 | // the category threshold they have set, don't send the email |
| 388 | - if($highest_cat_idx < $this->email_category) return false; |
|
| 401 | + if($highest_cat_idx < $this->email_category) { |
|
| 402 | + return false; |
|
| 403 | + } |
|
| 389 | 404 | |
| 390 | 405 | $graph = Yii::$container |
| 391 | 406 | ->get(\common\components\Graph::class) |
@@ -511,13 +526,17 @@ discard block |
||
| 511 | 526 | } |
| 512 | 527 | |
| 513 | 528 | public function getUserQuestions($local_date = null) { |
| 514 | - if(is_null($local_date)) $local_date = $this->time->getLocalDate(); |
|
| 529 | + if(is_null($local_date)) { |
|
| 530 | + $local_date = $this->time->getLocalDate(); |
|
| 531 | + } |
|
| 515 | 532 | $questions = $this->getQuestionData($local_date); |
| 516 | 533 | return $this->parseQuestionData($questions); |
| 517 | 534 | } |
| 518 | 535 | |
| 519 | 536 | public function getUserBehaviors($local_date = null) { |
| 520 | - if(is_null($local_date)) $local_date = $this->time->getLocalDate(); |
|
| 537 | + if(is_null($local_date)) { |
|
| 538 | + $local_date = $this->time->getLocalDate(); |
|
| 539 | + } |
|
| 521 | 540 | |
| 522 | 541 | $behaviors = $this->getBehaviorData($local_date); |
| 523 | 542 | $behaviors = \common\models\UserBehavior::decorateWithCategory($behaviors); |
@@ -525,7 +544,9 @@ discard block |
||
| 525 | 544 | } |
| 526 | 545 | |
| 527 | 546 | public function parseQuestionData($questions) { |
| 528 | - if(!$questions) return []; |
|
| 547 | + if(!$questions) { |
|
| 548 | + return []; |
|
| 549 | + } |
|
| 529 | 550 | |
| 530 | 551 | $question_answers = []; |
| 531 | 552 | foreach($questions as $question) { |
@@ -546,7 +567,9 @@ discard block |
||
| 546 | 567 | } |
| 547 | 568 | |
| 548 | 569 | public function parseBehaviorData($behaviors) { |
| 549 | - if(!$behaviors) return []; |
|
| 570 | + if(!$behaviors) { |
|
| 571 | + return []; |
|
| 572 | + } |
|
| 550 | 573 | |
| 551 | 574 | $opts_by_cat = []; |
| 552 | 575 | foreach($behaviors as $behavior) { |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | ->groupBy('date, user_id') |
| 85 | 85 | ->having('user_id = :user_id'); |
| 86 | 86 | $temp_dates = $query->all(); |
| 87 | - foreach($temp_dates as $temp_date) { |
|
| 87 | + foreach ($temp_dates as $temp_date) { |
|
| 88 | 88 | $past_checkin_dates[] = $this->time->convertUTCToLocal($temp_date['date']); |
| 89 | 89 | } |
| 90 | 90 | |
@@ -127,12 +127,12 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | public function getCheckinBreakdown(int $period = 30) { |
| 129 | 129 | $datetimes = $this->time->getDateTimesInPeriod($period); |
| 130 | - $key = "checkins_".Yii::$app->user->id."_{$period}_".$this->time->getLocalDate(); |
|
| 130 | + $key = "checkins_" . Yii::$app->user->id . "_{$period}_" . $this->time->getLocalDate(); |
|
| 131 | 131 | $checkins = Yii::$app->cache->get($key); |
| 132 | 132 | |
| 133 | - if($checkins === false) { |
|
| 133 | + if ($checkins === false) { |
|
| 134 | 134 | $checkins = []; |
| 135 | - foreach($datetimes as $datetime) { |
|
| 135 | + foreach ($datetimes as $datetime) { |
|
| 136 | 136 | $behaviors = self::decorateWithCategory($this->getBehaviorsWithCounts($datetime)); |
| 137 | 137 | $checkins[$datetime->format('Y-m-d')] = $this->getBehaviorsByCategory($behaviors); |
| 138 | 138 | } |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | public function getBehaviorsByCategory(array $decorated_behaviors) { |
| 159 | 159 | $arr = array_reduce($decorated_behaviors, function($acc, $row) { |
| 160 | 160 | $cat_id = $row['behavior']['category']['id']; |
| 161 | - if(array_key_exists($cat_id, $acc)) { |
|
| 161 | + if (array_key_exists($cat_id, $acc)) { |
|
| 162 | 162 | $acc[$cat_id]['count'] += $row['count']; |
| 163 | 163 | } else { |
| 164 | 164 | $acc[$cat_id] = [ |
@@ -175,10 +175,10 @@ discard block |
||
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | public static function decorate(array $uo, $with_category = false) { |
| 178 | - foreach($uo as &$o) { |
|
| 179 | - if($behavior = \common\models\Behavior::getBehavior('id', $o['behavior_id'])) { |
|
| 178 | + foreach ($uo as &$o) { |
|
| 179 | + if ($behavior = \common\models\Behavior::getBehavior('id', $o['behavior_id'])) { |
|
| 180 | 180 | $o['behavior'] = $behavior; |
| 181 | - if($with_category) { |
|
| 181 | + if ($with_category) { |
|
| 182 | 182 | $o['behavior']['category'] = \common\models\Category::getCategory('id', $o['behavior']['category_id']); |
| 183 | 183 | } |
| 184 | 184 | } |
@@ -204,11 +204,11 @@ discard block |
||
| 204 | 204 | ->having('user_id = :user_id') |
| 205 | 205 | ->orderBy('count DESC'); |
| 206 | 206 | |
| 207 | - if($limit instanceof \DateTime) { |
|
| 207 | + if ($limit instanceof \DateTime) { |
|
| 208 | 208 | list($start, $end) = $this->time->getUTCBookends($limit->format('Y-m-d')); |
| 209 | 209 | $query->params += [':start_date' => $start, ':end_date' => $end]; |
| 210 | 210 | $query->where('user_id=:user_id AND date > :start_date AND date <= :end_date'); |
| 211 | - } else if(is_int($limit)) { |
|
| 211 | + } else if (is_int($limit)) { |
|
| 212 | 212 | $query->limit($limit); |
| 213 | 213 | } |
| 214 | 214 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | $this->container->set('common\interfaces\UserBehaviorInterface', '\site\tests\_support\MockUserBehavior'); |
| 25 | 25 | $this->container->set('common\interfaces\QuestionInterface', '\site\tests\_support\MockQuestion'); |
| 26 | 26 | |
| 27 | - $this->container->set('common\interfaces\TimeInterface', function () { |
|
| 27 | + $this->container->set('common\interfaces\TimeInterface', function() { |
|
| 28 | 28 | return new \common\components\Time('America/Los_Angeles'); |
| 29 | 29 | }); |
| 30 | 30 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | public function testGetLocalTime() |
| 49 | 49 | { |
| 50 | - $this->specify('getLocalTime should function correctly', function () { |
|
| 50 | + $this->specify('getLocalTime should function correctly', function() { |
|
| 51 | 51 | expect("getLocalTime should work with user's set time", $this->assertEquals($this->time->getLocalTime(), (new DateTime("now", new DateTimeZone("America/Los_Angeles")))->format("Y-m-d H:i:s"))); |
| 52 | 52 | expect('getLocalTime should work with a custom timezone', $this->assertEquals($this->time->getLocalTime("UTC"), (new DateTime("now"))->format("Y-m-d H:i:s"))); |
| 53 | 53 | }); |
@@ -55,13 +55,13 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | public function testConvertLocalToUTC() |
| 57 | 57 | { |
| 58 | - $this->specify('convertLocalToUTC should function correctly', function () { |
|
| 58 | + $this->specify('convertLocalToUTC should function correctly', function() { |
|
| 59 | 59 | $la_tz = (new DateTime("now", new DateTimeZone("America/Los_Angeles")))->format("Y-m-d H:i:s"); |
| 60 | 60 | |
| 61 | 61 | expect('convertLocalToUTC should convert a Los Angeles tz to UTC with the included time', $this->assertEquals($this->time->convertLocalToUTC($la_tz), (new DateTime("now"))->format("Y-m-d H:i:s"))); |
| 62 | 62 | expect('convertLocalToUTC should convert a Los Angeles tz to UTC without the included time', $this->assertEquals($this->time->convertLocalToUTC($la_tz, false), (new DateTime("now"))->format("Y-m-d"))); |
| 63 | 63 | // with UTC |
| 64 | - $this->container->set('common\interfaces\TimeInterface', function () { |
|
| 64 | + $this->container->set('common\interfaces\TimeInterface', function() { |
|
| 65 | 65 | return new \common\components\Time('UTC'); |
| 66 | 66 | }); |
| 67 | 67 | $time = $this->container->get('common\interfaces\TimeInterface'); |
@@ -74,14 +74,14 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | public function testConvertUTCToLocal() |
| 76 | 76 | { |
| 77 | - $this->specify('convertUTCToLocal should function correctly', function () { |
|
| 77 | + $this->specify('convertUTCToLocal should function correctly', function() { |
|
| 78 | 78 | $utc_tz = (new DateTime("now"))->format("Y-m-d H:i:s"); |
| 79 | 79 | |
| 80 | 80 | expect('convertUTCToLocal should convert a UTC tz to Los Angeles with the included timezone', $this->assertEquals((new DateTime("now", new DateTimeZone("America/Los_Angeles")))->format(DateTime::ATOM), $this->time->convertUTCToLocal($utc_tz))); |
| 81 | 81 | expect('convertUTCToLocal should convert a UTC tz to Los Angeles without the included timezone', $this->assertEquals($this->time->convertUTCToLocal($utc_tz, false), (new DateTime("now", new DateTimeZone("America/Los_Angeles")))->format("Y-m-d H:i:s"))); |
| 82 | 82 | |
| 83 | 83 | // with UTC |
| 84 | - $this->container->set('common\interfaces\TimeInterface', function () { |
|
| 84 | + $this->container->set('common\interfaces\TimeInterface', function() { |
|
| 85 | 85 | return new \common\components\Time('UTC'); |
| 86 | 86 | }); |
| 87 | 87 | $time = $this->container->get('common\interfaces\TimeInterface'); |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | public function testGetLocalDate() |
| 96 | 96 | { |
| 97 | - $this->specify('getLocalDate should function correctly', function () { |
|
| 97 | + $this->specify('getLocalDate should function correctly', function() { |
|
| 98 | 98 | expect("getLocalDate should correctly get the user's local date", $this->assertEquals($this->time->getLocalDate(), (new DateTime("now", new DateTimeZone("America/Los_Angeles")))->format("Y-m-d"))); |
| 99 | 99 | expect("getLocalDate should correctly get the local date of a specified timezone", $this->assertEquals($this->time->getLocalDate("UTC"), (new DateTime("now", new DateTimeZone("UTC")))->format("Y-m-d"))); |
| 100 | 100 | }); |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | expect('getUTCBookends should return false if there is a space at the end of the time string', $this->assertFalse($this->time->getUTCBookends('2016-05-30 00:00:00 '))); |
| 117 | 117 | expect('getUTCBookends should return UTC bookend times from the Los_Angeles tz', $this->assertEquals($this->time->getUTCBookends('2016-05-30'), ['2016-05-30 07:00:00', '2016-05-31 06:59:59'])); |
| 118 | 118 | // with UTC |
| 119 | - $this->container->set('common\interfaces\TimeInterface', function () { |
|
| 119 | + $this->container->set('common\interfaces\TimeInterface', function() { |
|
| 120 | 120 | return new \common\components\Time('UTC'); |
| 121 | 121 | }); |
| 122 | 122 | $time = $this->container->get('common\interfaces\TimeInterface'); |
@@ -203,11 +203,11 @@ discard block |
||
| 203 | 203 | $tz = 'America/Los_Angeles'; |
| 204 | 204 | $this->time->timezone = 'America/Los_Angeles'; |
| 205 | 205 | |
| 206 | - $today = new \DateTime("now + 1 day", new \DateTimeZone($tz)); // we do an extra day to include today as the last day |
|
| 206 | + $today = new \DateTime("now + 1 day", new \DateTimeZone($tz)); // we do an extra day to include today as the last day |
|
| 207 | 207 | $should_be_today = $this->time->getDateTimesInPeriod()->getEndDate(); |
| 208 | 208 | expect('getDateTimesInPeriod should return a list of \DatePeriods, the last being for today', $this->assertEquals($today->format('Y-m-d H'), $should_be_today->format('Y-m-d H'))); |
| 209 | 209 | |
| 210 | - $start = new \DateTime("30 days ago", new \DateTimeZone($tz)); |
|
| 210 | + $start = new \DateTime("30 days ago", new \DateTimeZone($tz)); |
|
| 211 | 211 | $should_be_start = $this->time->getDateTimesInPeriod()->getStartDate(); |
| 212 | 212 | expect('getDateTimesInPeriod should return a list of \DatePeriods, the first being for 30 days ago (by default)', $this->assertEquals($start->format('Y-m-d H'), $should_be_start->format('Y-m-d H'))); |
| 213 | 213 | } |
@@ -19,640 +19,640 @@ |
||
| 19 | 19 | private $time; |
| 20 | 20 | private $question; |
| 21 | 21 | |
| 22 | - public $questionData = [ |
|
| 23 | - [ |
|
| 24 | - 'id' => 641, |
|
| 25 | - 'user_id' => 2, |
|
| 26 | - 'behavior_id' => 13, |
|
| 27 | - 'user_behavior_id' => 821, |
|
| 28 | - 'question' => 1, |
|
| 29 | - 'answer' => 'alsgn', |
|
| 30 | - 'date' => '2016-09-10 19:27:43', |
|
| 31 | - 'behavior' => |
|
| 32 | - [ |
|
| 33 | - 'id' => 13, |
|
| 34 | - 'name' => 'less time/energy for God, meetings, and church', |
|
| 35 | - 'category_id' => 2, |
|
| 36 | - ], |
|
| 37 | - ], |
|
| 38 | - [ |
|
| 39 | - 'id' => 642, |
|
| 40 | - 'user_id' => 2, |
|
| 41 | - 'behavior_id' => 13, |
|
| 42 | - 'user_behavior_id' => 821, |
|
| 43 | - 'question' => 2, |
|
| 44 | - 'answer' => 'loiun', |
|
| 45 | - 'date' => '2016-09-10 19:27:43', |
|
| 46 | - 'behavior' => |
|
| 47 | - [ |
|
| 48 | - 'id' => 13, |
|
| 49 | - 'name' => 'less time/energy for God, meetings, and church', |
|
| 50 | - 'category_id' => 2, |
|
| 51 | - ], |
|
| 52 | - ], |
|
| 53 | - [ |
|
| 54 | - 'id' => 643, |
|
| 55 | - 'user_id' => 2, |
|
| 56 | - 'behavior_id' => 13, |
|
| 57 | - 'user_behavior_id' => 821, |
|
| 58 | - 'question' => 3, |
|
| 59 | - 'answer' => 'liun', |
|
| 60 | - 'date' => '2016-09-10 19:27:43', |
|
| 61 | - 'behavior' => |
|
| 62 | - [ |
|
| 63 | - 'id' => 13, |
|
| 64 | - 'name' => 'less time/energy for God, meetings, and church', |
|
| 65 | - 'category_id' => 2, |
|
| 66 | - ], |
|
| 67 | - ], |
|
| 68 | - [ |
|
| 69 | - 'id' => 644, |
|
| 70 | - 'user_id' => 2, |
|
| 71 | - 'behavior_id' => 29, |
|
| 72 | - 'user_behavior_id' => 823, |
|
| 73 | - 'question' => 1, |
|
| 74 | - 'answer' => 'ljnb', |
|
| 75 | - 'date' => '2016-09-10 19:27:43', |
|
| 76 | - 'behavior' => |
|
| 77 | - [ |
|
| 78 | - 'id' => 29, |
|
| 79 | - 'name' => 'using profanity', |
|
| 80 | - 'category_id' => 3, |
|
| 81 | - ], |
|
| 82 | - ], |
|
| 83 | - [ |
|
| 84 | - 'id' => 645, |
|
| 85 | - 'user_id' => 2, |
|
| 86 | - 'behavior_id' => 29, |
|
| 87 | - 'user_behavior_id' => 823, |
|
| 88 | - 'question' => 2, |
|
| 89 | - 'answer' => 'liunb', |
|
| 90 | - 'date' => '2016-09-10 19:27:43', |
|
| 91 | - 'behavior' => |
|
| 92 | - [ |
|
| 93 | - 'id' => 29, |
|
| 94 | - 'name' => 'using profanity', |
|
| 95 | - 'category_id' => 3, |
|
| 96 | - ], |
|
| 97 | - ], |
|
| 98 | - [ |
|
| 99 | - 'id' => 646, |
|
| 100 | - 'user_id' => 2, |
|
| 101 | - 'behavior_id' => 29, |
|
| 102 | - 'user_behavior_id' => 823, |
|
| 103 | - 'question' => 3, |
|
| 104 | - 'answer' => 'ilub ', |
|
| 105 | - 'date' => '2016-09-10 19:27:43', |
|
| 106 | - 'behavior' => |
|
| 107 | - [ |
|
| 108 | - 'id' => 29, |
|
| 109 | - 'name' => 'using profanity', |
|
| 110 | - 'category_id' => 3, |
|
| 111 | - ], |
|
| 112 | - ], |
|
| 113 | - [ |
|
| 114 | - 'id' => 647, |
|
| 115 | - 'user_id' => 2, |
|
| 116 | - 'behavior_id' => 48, |
|
| 117 | - 'user_behavior_id' => 825, |
|
| 118 | - 'question' => 1, |
|
| 119 | - 'answer' => 'liub', |
|
| 120 | - 'date' => '2016-09-10 19:27:43', |
|
| 121 | - 'behavior' => |
|
| 122 | - [ |
|
| 123 | - 'id' => 48, |
|
| 124 | - 'name' => 'workaholic', |
|
| 125 | - 'category_id' => 4, |
|
| 126 | - ], |
|
| 127 | - ], |
|
| 128 | - [ |
|
| 129 | - 'id' => 648, |
|
| 130 | - 'user_id' => 2, |
|
| 131 | - 'behavior_id' => 48, |
|
| 132 | - 'user_behavior_id' => 825, |
|
| 133 | - 'question' => 2, |
|
| 134 | - 'answer' => 'liub', |
|
| 135 | - 'date' => '2016-09-10 19:27:43', |
|
| 136 | - 'behavior' => |
|
| 137 | - [ |
|
| 138 | - 'id' => 48, |
|
| 139 | - 'name' => 'workaholic', |
|
| 140 | - 'category_id' => 4, |
|
| 141 | - ], |
|
| 142 | - ], |
|
| 143 | - [ |
|
| 144 | - 'id' => 649, |
|
| 145 | - 'user_id' => 2, |
|
| 146 | - 'behavior_id' => 48, |
|
| 147 | - 'user_behavior_id' => 825, |
|
| 148 | - 'question' => 3, |
|
| 149 | - 'answer' => 'liub ', |
|
| 150 | - 'date' => '2016-09-10 19:27:43', |
|
| 151 | - 'behavior' => |
|
| 152 | - [ |
|
| 153 | - 'id' => 48, |
|
| 154 | - 'name' => 'workaholic', |
|
| 155 | - 'category_id' => 4, |
|
| 156 | - ], |
|
| 157 | - ], |
|
| 158 | - [ |
|
| 159 | - 'id' => 650, |
|
| 160 | - 'user_id' => 2, |
|
| 161 | - 'behavior_id' => 89, |
|
| 162 | - 'user_behavior_id' => 828, |
|
| 163 | - 'question' => 1, |
|
| 164 | - 'answer' => 'liub', |
|
| 165 | - 'date' => '2016-09-10 19:27:43', |
|
| 166 | - 'behavior' => |
|
| 167 | - [ |
|
| 168 | - 'id' => 89, |
|
| 169 | - 'name' => 'obsessive (stuck) thoughts', |
|
| 170 | - 'category_id' => 5, |
|
| 171 | - ], |
|
| 172 | - ], |
|
| 173 | - [ |
|
| 174 | - 'id' => 651, |
|
| 175 | - 'user_id' => 2, |
|
| 176 | - 'behavior_id' => 89, |
|
| 177 | - 'user_behavior_id' => 828, |
|
| 178 | - 'question' => 2, |
|
| 179 | - 'answer' => 'liuby', |
|
| 180 | - 'date' => '2016-09-10 19:27:43', |
|
| 181 | - 'behavior' => |
|
| 182 | - [ |
|
| 183 | - 'id' => 89, |
|
| 184 | - 'name' => 'obsessive (stuck) thoughts', |
|
| 185 | - 'category_id' => 5, |
|
| 186 | - ], |
|
| 187 | - ], |
|
| 188 | - [ |
|
| 189 | - 'id' => 652, |
|
| 190 | - 'user_id' => 2, |
|
| 191 | - 'behavior_id' => 89, |
|
| 192 | - 'user_behavior_id' => 828, |
|
| 193 | - 'question' => 3, |
|
| 194 | - 'answer' => 'uiylb', |
|
| 195 | - 'date' => '2016-09-10 19:27:43', |
|
| 196 | - 'behavior' => |
|
| 197 | - [ |
|
| 198 | - 'id' => 89, |
|
| 199 | - 'name' => 'obsessive (stuck) thoughts', |
|
| 200 | - 'category_id' => 5, |
|
| 201 | - ], |
|
| 202 | - ], |
|
| 203 | - [ |
|
| 204 | - 'id' => 653, |
|
| 205 | - 'user_id' => 2, |
|
| 206 | - 'behavior_id' => 111, |
|
| 207 | - 'user_behavior_id' => 829, |
|
| 208 | - 'question' => 1, |
|
| 209 | - 'answer' => 'liub', |
|
| 210 | - 'date' => '2016-09-10 19:27:43', |
|
| 211 | - 'behavior' => |
|
| 212 | - [ |
|
| 213 | - 'id' => 111, |
|
| 214 | - 'name' => 'seeking out old unhealthy people and places', |
|
| 215 | - 'category_id' => 6, |
|
| 216 | - ], |
|
| 217 | - ], |
|
| 218 | - [ |
|
| 219 | - 'id' => 654, |
|
| 220 | - 'user_id' => 2, |
|
| 221 | - 'behavior_id' => 111, |
|
| 222 | - 'user_behavior_id' => 829, |
|
| 223 | - 'question' => 2, |
|
| 224 | - 'answer' => 'liuyb', |
|
| 225 | - 'date' => '2016-09-10 19:27:43', |
|
| 226 | - 'behavior' => |
|
| 227 | - [ |
|
| 228 | - 'id' => 111, |
|
| 229 | - 'name' => 'seeking out old unhealthy people and places', |
|
| 230 | - 'category_id' => 6, |
|
| 231 | - ], |
|
| 232 | - ], |
|
| 233 | - [ |
|
| 234 | - 'id' => 655, |
|
| 235 | - 'user_id' => 2, |
|
| 236 | - 'behavior_id' => 111, |
|
| 237 | - 'user_behavior_id' => 829, |
|
| 238 | - 'question' => 3, |
|
| 239 | - 'answer' => 'iuyb', |
|
| 240 | - 'date' => '2016-09-10 19:27:43', |
|
| 241 | - 'behavior' => |
|
| 242 | - [ |
|
| 243 | - 'id' => 111, |
|
| 244 | - 'name' => 'seeking out old unhealthy people and places', |
|
| 245 | - 'category_id' => 6, |
|
| 246 | - ], |
|
| 247 | - ], |
|
| 248 | - [ |
|
| 249 | - 'id' => 656, |
|
| 250 | - 'user_id' => 2, |
|
| 251 | - 'behavior_id' => 122, |
|
| 252 | - 'user_behavior_id' => 831, |
|
| 253 | - 'question' => 1, |
|
| 254 | - 'answer' => 'iuyb', |
|
| 255 | - 'date' => '2016-09-10 19:27:43', |
|
| 256 | - 'behavior' => |
|
| 257 | - [ |
|
| 258 | - 'id' => 122, |
|
| 259 | - 'name' => 'returning to the place you swore you would never go again', |
|
| 260 | - 'category_id' => 7, |
|
| 261 | - ], |
|
| 262 | - ], |
|
| 263 | - [ |
|
| 264 | - 'id' => 657, |
|
| 265 | - 'user_id' => 2, |
|
| 266 | - 'behavior_id' => 122, |
|
| 267 | - 'user_behavior_id' => 831, |
|
| 268 | - 'question' => 2, |
|
| 269 | - 'answer' => 'iuyb', |
|
| 270 | - 'date' => '2016-09-10 19:27:43', |
|
| 271 | - 'behavior' => |
|
| 272 | - [ |
|
| 273 | - 'id' => 122, |
|
| 274 | - 'name' => 'returning to the place you swore you would never go again', |
|
| 275 | - 'category_id' => 7, |
|
| 276 | - ], |
|
| 277 | - ], |
|
| 278 | - [ |
|
| 279 | - 'id' => 658, |
|
| 280 | - 'user_id' => 2, |
|
| 281 | - 'behavior_id' => 122, |
|
| 282 | - 'user_behavior_id' => 831, |
|
| 283 | - 'question' => 3, |
|
| 284 | - 'answer' => 'liuyb', |
|
| 285 | - 'date' => '2016-09-10 19:27:43', |
|
| 286 | - 'behavior' => |
|
| 287 | - [ |
|
| 288 | - 'id' => 122, |
|
| 289 | - 'name' => 'returning to the place you swore you would never go again', |
|
| 290 | - 'category_id' => 7, |
|
| 291 | - ], |
|
| 292 | - ], |
|
| 22 | + public $questionData = [ |
|
| 23 | + [ |
|
| 24 | + 'id' => 641, |
|
| 25 | + 'user_id' => 2, |
|
| 26 | + 'behavior_id' => 13, |
|
| 27 | + 'user_behavior_id' => 821, |
|
| 28 | + 'question' => 1, |
|
| 29 | + 'answer' => 'alsgn', |
|
| 30 | + 'date' => '2016-09-10 19:27:43', |
|
| 31 | + 'behavior' => |
|
| 32 | + [ |
|
| 33 | + 'id' => 13, |
|
| 34 | + 'name' => 'less time/energy for God, meetings, and church', |
|
| 35 | + 'category_id' => 2, |
|
| 36 | + ], |
|
| 37 | + ], |
|
| 38 | + [ |
|
| 39 | + 'id' => 642, |
|
| 40 | + 'user_id' => 2, |
|
| 41 | + 'behavior_id' => 13, |
|
| 42 | + 'user_behavior_id' => 821, |
|
| 43 | + 'question' => 2, |
|
| 44 | + 'answer' => 'loiun', |
|
| 45 | + 'date' => '2016-09-10 19:27:43', |
|
| 46 | + 'behavior' => |
|
| 47 | + [ |
|
| 48 | + 'id' => 13, |
|
| 49 | + 'name' => 'less time/energy for God, meetings, and church', |
|
| 50 | + 'category_id' => 2, |
|
| 51 | + ], |
|
| 52 | + ], |
|
| 53 | + [ |
|
| 54 | + 'id' => 643, |
|
| 55 | + 'user_id' => 2, |
|
| 56 | + 'behavior_id' => 13, |
|
| 57 | + 'user_behavior_id' => 821, |
|
| 58 | + 'question' => 3, |
|
| 59 | + 'answer' => 'liun', |
|
| 60 | + 'date' => '2016-09-10 19:27:43', |
|
| 61 | + 'behavior' => |
|
| 62 | + [ |
|
| 63 | + 'id' => 13, |
|
| 64 | + 'name' => 'less time/energy for God, meetings, and church', |
|
| 65 | + 'category_id' => 2, |
|
| 66 | + ], |
|
| 67 | + ], |
|
| 68 | + [ |
|
| 69 | + 'id' => 644, |
|
| 70 | + 'user_id' => 2, |
|
| 71 | + 'behavior_id' => 29, |
|
| 72 | + 'user_behavior_id' => 823, |
|
| 73 | + 'question' => 1, |
|
| 74 | + 'answer' => 'ljnb', |
|
| 75 | + 'date' => '2016-09-10 19:27:43', |
|
| 76 | + 'behavior' => |
|
| 77 | + [ |
|
| 78 | + 'id' => 29, |
|
| 79 | + 'name' => 'using profanity', |
|
| 80 | + 'category_id' => 3, |
|
| 81 | + ], |
|
| 82 | + ], |
|
| 83 | + [ |
|
| 84 | + 'id' => 645, |
|
| 85 | + 'user_id' => 2, |
|
| 86 | + 'behavior_id' => 29, |
|
| 87 | + 'user_behavior_id' => 823, |
|
| 88 | + 'question' => 2, |
|
| 89 | + 'answer' => 'liunb', |
|
| 90 | + 'date' => '2016-09-10 19:27:43', |
|
| 91 | + 'behavior' => |
|
| 92 | + [ |
|
| 93 | + 'id' => 29, |
|
| 94 | + 'name' => 'using profanity', |
|
| 95 | + 'category_id' => 3, |
|
| 96 | + ], |
|
| 97 | + ], |
|
| 98 | + [ |
|
| 99 | + 'id' => 646, |
|
| 100 | + 'user_id' => 2, |
|
| 101 | + 'behavior_id' => 29, |
|
| 102 | + 'user_behavior_id' => 823, |
|
| 103 | + 'question' => 3, |
|
| 104 | + 'answer' => 'ilub ', |
|
| 105 | + 'date' => '2016-09-10 19:27:43', |
|
| 106 | + 'behavior' => |
|
| 107 | + [ |
|
| 108 | + 'id' => 29, |
|
| 109 | + 'name' => 'using profanity', |
|
| 110 | + 'category_id' => 3, |
|
| 111 | + ], |
|
| 112 | + ], |
|
| 113 | + [ |
|
| 114 | + 'id' => 647, |
|
| 115 | + 'user_id' => 2, |
|
| 116 | + 'behavior_id' => 48, |
|
| 117 | + 'user_behavior_id' => 825, |
|
| 118 | + 'question' => 1, |
|
| 119 | + 'answer' => 'liub', |
|
| 120 | + 'date' => '2016-09-10 19:27:43', |
|
| 121 | + 'behavior' => |
|
| 122 | + [ |
|
| 123 | + 'id' => 48, |
|
| 124 | + 'name' => 'workaholic', |
|
| 125 | + 'category_id' => 4, |
|
| 126 | + ], |
|
| 127 | + ], |
|
| 128 | + [ |
|
| 129 | + 'id' => 648, |
|
| 130 | + 'user_id' => 2, |
|
| 131 | + 'behavior_id' => 48, |
|
| 132 | + 'user_behavior_id' => 825, |
|
| 133 | + 'question' => 2, |
|
| 134 | + 'answer' => 'liub', |
|
| 135 | + 'date' => '2016-09-10 19:27:43', |
|
| 136 | + 'behavior' => |
|
| 137 | + [ |
|
| 138 | + 'id' => 48, |
|
| 139 | + 'name' => 'workaholic', |
|
| 140 | + 'category_id' => 4, |
|
| 141 | + ], |
|
| 142 | + ], |
|
| 143 | + [ |
|
| 144 | + 'id' => 649, |
|
| 145 | + 'user_id' => 2, |
|
| 146 | + 'behavior_id' => 48, |
|
| 147 | + 'user_behavior_id' => 825, |
|
| 148 | + 'question' => 3, |
|
| 149 | + 'answer' => 'liub ', |
|
| 150 | + 'date' => '2016-09-10 19:27:43', |
|
| 151 | + 'behavior' => |
|
| 152 | + [ |
|
| 153 | + 'id' => 48, |
|
| 154 | + 'name' => 'workaholic', |
|
| 155 | + 'category_id' => 4, |
|
| 156 | + ], |
|
| 157 | + ], |
|
| 158 | + [ |
|
| 159 | + 'id' => 650, |
|
| 160 | + 'user_id' => 2, |
|
| 161 | + 'behavior_id' => 89, |
|
| 162 | + 'user_behavior_id' => 828, |
|
| 163 | + 'question' => 1, |
|
| 164 | + 'answer' => 'liub', |
|
| 165 | + 'date' => '2016-09-10 19:27:43', |
|
| 166 | + 'behavior' => |
|
| 167 | + [ |
|
| 168 | + 'id' => 89, |
|
| 169 | + 'name' => 'obsessive (stuck) thoughts', |
|
| 170 | + 'category_id' => 5, |
|
| 171 | + ], |
|
| 172 | + ], |
|
| 173 | + [ |
|
| 174 | + 'id' => 651, |
|
| 175 | + 'user_id' => 2, |
|
| 176 | + 'behavior_id' => 89, |
|
| 177 | + 'user_behavior_id' => 828, |
|
| 178 | + 'question' => 2, |
|
| 179 | + 'answer' => 'liuby', |
|
| 180 | + 'date' => '2016-09-10 19:27:43', |
|
| 181 | + 'behavior' => |
|
| 182 | + [ |
|
| 183 | + 'id' => 89, |
|
| 184 | + 'name' => 'obsessive (stuck) thoughts', |
|
| 185 | + 'category_id' => 5, |
|
| 186 | + ], |
|
| 187 | + ], |
|
| 188 | + [ |
|
| 189 | + 'id' => 652, |
|
| 190 | + 'user_id' => 2, |
|
| 191 | + 'behavior_id' => 89, |
|
| 192 | + 'user_behavior_id' => 828, |
|
| 193 | + 'question' => 3, |
|
| 194 | + 'answer' => 'uiylb', |
|
| 195 | + 'date' => '2016-09-10 19:27:43', |
|
| 196 | + 'behavior' => |
|
| 197 | + [ |
|
| 198 | + 'id' => 89, |
|
| 199 | + 'name' => 'obsessive (stuck) thoughts', |
|
| 200 | + 'category_id' => 5, |
|
| 201 | + ], |
|
| 202 | + ], |
|
| 203 | + [ |
|
| 204 | + 'id' => 653, |
|
| 205 | + 'user_id' => 2, |
|
| 206 | + 'behavior_id' => 111, |
|
| 207 | + 'user_behavior_id' => 829, |
|
| 208 | + 'question' => 1, |
|
| 209 | + 'answer' => 'liub', |
|
| 210 | + 'date' => '2016-09-10 19:27:43', |
|
| 211 | + 'behavior' => |
|
| 212 | + [ |
|
| 213 | + 'id' => 111, |
|
| 214 | + 'name' => 'seeking out old unhealthy people and places', |
|
| 215 | + 'category_id' => 6, |
|
| 216 | + ], |
|
| 217 | + ], |
|
| 218 | + [ |
|
| 219 | + 'id' => 654, |
|
| 220 | + 'user_id' => 2, |
|
| 221 | + 'behavior_id' => 111, |
|
| 222 | + 'user_behavior_id' => 829, |
|
| 223 | + 'question' => 2, |
|
| 224 | + 'answer' => 'liuyb', |
|
| 225 | + 'date' => '2016-09-10 19:27:43', |
|
| 226 | + 'behavior' => |
|
| 227 | + [ |
|
| 228 | + 'id' => 111, |
|
| 229 | + 'name' => 'seeking out old unhealthy people and places', |
|
| 230 | + 'category_id' => 6, |
|
| 231 | + ], |
|
| 232 | + ], |
|
| 233 | + [ |
|
| 234 | + 'id' => 655, |
|
| 235 | + 'user_id' => 2, |
|
| 236 | + 'behavior_id' => 111, |
|
| 237 | + 'user_behavior_id' => 829, |
|
| 238 | + 'question' => 3, |
|
| 239 | + 'answer' => 'iuyb', |
|
| 240 | + 'date' => '2016-09-10 19:27:43', |
|
| 241 | + 'behavior' => |
|
| 242 | + [ |
|
| 243 | + 'id' => 111, |
|
| 244 | + 'name' => 'seeking out old unhealthy people and places', |
|
| 245 | + 'category_id' => 6, |
|
| 246 | + ], |
|
| 247 | + ], |
|
| 248 | + [ |
|
| 249 | + 'id' => 656, |
|
| 250 | + 'user_id' => 2, |
|
| 251 | + 'behavior_id' => 122, |
|
| 252 | + 'user_behavior_id' => 831, |
|
| 253 | + 'question' => 1, |
|
| 254 | + 'answer' => 'iuyb', |
|
| 255 | + 'date' => '2016-09-10 19:27:43', |
|
| 256 | + 'behavior' => |
|
| 257 | + [ |
|
| 258 | + 'id' => 122, |
|
| 259 | + 'name' => 'returning to the place you swore you would never go again', |
|
| 260 | + 'category_id' => 7, |
|
| 261 | + ], |
|
| 262 | + ], |
|
| 263 | + [ |
|
| 264 | + 'id' => 657, |
|
| 265 | + 'user_id' => 2, |
|
| 266 | + 'behavior_id' => 122, |
|
| 267 | + 'user_behavior_id' => 831, |
|
| 268 | + 'question' => 2, |
|
| 269 | + 'answer' => 'iuyb', |
|
| 270 | + 'date' => '2016-09-10 19:27:43', |
|
| 271 | + 'behavior' => |
|
| 272 | + [ |
|
| 273 | + 'id' => 122, |
|
| 274 | + 'name' => 'returning to the place you swore you would never go again', |
|
| 275 | + 'category_id' => 7, |
|
| 276 | + ], |
|
| 277 | + ], |
|
| 278 | + [ |
|
| 279 | + 'id' => 658, |
|
| 280 | + 'user_id' => 2, |
|
| 281 | + 'behavior_id' => 122, |
|
| 282 | + 'user_behavior_id' => 831, |
|
| 283 | + 'question' => 3, |
|
| 284 | + 'answer' => 'liuyb', |
|
| 285 | + 'date' => '2016-09-10 19:27:43', |
|
| 286 | + 'behavior' => |
|
| 287 | + [ |
|
| 288 | + 'id' => 122, |
|
| 289 | + 'name' => 'returning to the place you swore you would never go again', |
|
| 290 | + 'category_id' => 7, |
|
| 291 | + ], |
|
| 292 | + ], |
|
| 293 | 293 | ]; |
| 294 | 294 | public $userQuestions = [ |
| 295 | - 13 => [ |
|
| 296 | - 'question' => [ |
|
| 297 | - 'id' => 13, |
|
| 298 | - 'title' => 'less time/energy for God, meetings, and church', |
|
| 299 | - ], |
|
| 300 | - 'answers' => [ |
|
| 301 | - [ |
|
| 302 | - 'title' => 'How does it affect me? How do I act and feel?', |
|
| 303 | - 'answer' => 'alsgn', |
|
| 304 | - ], [ |
|
| 305 | - 'title' => 'How does it affect the important people in my life?', |
|
| 306 | - 'answer' => 'loiun', |
|
| 307 | - ], [ |
|
| 308 | - 'title' => 'Why do I do this? What is the benefit for me?', |
|
| 309 | - 'answer' => 'liun', |
|
| 310 | - ], |
|
| 311 | - ], |
|
| 312 | - ], |
|
| 313 | - 29 => [ |
|
| 314 | - 'question' => [ |
|
| 315 | - 'id' => 29, |
|
| 316 | - 'title' => 'using profanity', |
|
| 317 | - ], |
|
| 318 | - 'answers' => [ |
|
| 319 | - [ |
|
| 320 | - 'title' => 'How does it affect me? How do I act and feel?', |
|
| 321 | - 'answer' => 'ljnb', |
|
| 322 | - ], [ |
|
| 323 | - 'title' => 'How does it affect the important people in my life?', |
|
| 324 | - 'answer' => 'liunb', |
|
| 325 | - ], [ |
|
| 326 | - 'title' => 'Why do I do this? What is the benefit for me?', |
|
| 327 | - 'answer' => 'ilub ', |
|
| 328 | - ], |
|
| 329 | - ], |
|
| 330 | - ], |
|
| 331 | - 48 => [ |
|
| 332 | - 'question' => [ |
|
| 333 | - 'id' => 48, |
|
| 334 | - 'title' => 'workaholic', |
|
| 335 | - ], |
|
| 336 | - 'answers' => [ |
|
| 337 | - [ |
|
| 338 | - 'title' => 'How does it affect me? How do I act and feel?', |
|
| 339 | - 'answer' => 'liub', |
|
| 340 | - ], [ |
|
| 341 | - 'title' => 'How does it affect the important people in my life?', |
|
| 342 | - 'answer' => 'liub', |
|
| 343 | - ], [ |
|
| 344 | - 'title' => 'Why do I do this? What is the benefit for me?', |
|
| 345 | - 'answer' => 'liub ', |
|
| 346 | - ], |
|
| 347 | - ], |
|
| 348 | - ], |
|
| 349 | - 89 => [ |
|
| 350 | - 'question' => [ |
|
| 351 | - 'id' => 89, |
|
| 352 | - 'title' => 'obsessive (stuck) thoughts', |
|
| 353 | - ], |
|
| 354 | - 'answers' => [ |
|
| 355 | - [ |
|
| 356 | - 'title' => 'How does it affect me? How do I act and feel?', |
|
| 357 | - 'answer' => 'liub', |
|
| 358 | - ], [ |
|
| 359 | - 'title' => 'How does it affect the important people in my life?', |
|
| 360 | - 'answer' => 'liuby', |
|
| 361 | - ], [ |
|
| 362 | - 'title' => 'Why do I do this? What is the benefit for me?', |
|
| 363 | - 'answer' => 'uiylb', |
|
| 364 | - ], |
|
| 365 | - ], |
|
| 366 | - ], |
|
| 367 | - 111 => [ |
|
| 368 | - 'question' => [ |
|
| 369 | - 'id' => 111, |
|
| 370 | - 'title' => 'seeking out old unhealthy people and places', |
|
| 371 | - ], |
|
| 372 | - 'answers' => [ |
|
| 373 | - [ |
|
| 374 | - 'title' => 'How does it affect me? How do I act and feel?', |
|
| 375 | - 'answer' => 'liub', |
|
| 376 | - ], [ |
|
| 377 | - 'title' => 'How does it affect the important people in my life?', |
|
| 378 | - 'answer' => 'liuyb', |
|
| 379 | - ], [ |
|
| 380 | - 'title' => 'Why do I do this? What is the benefit for me?', |
|
| 381 | - 'answer' => 'iuyb', |
|
| 382 | - ], |
|
| 383 | - ], |
|
| 384 | - ], |
|
| 385 | - 122 => [ |
|
| 386 | - 'question' => [ |
|
| 387 | - 'id' => 122, |
|
| 388 | - 'title' => 'returning to the place you swore you would never go again', |
|
| 389 | - ], |
|
| 390 | - 'answers' => [ |
|
| 391 | - [ |
|
| 392 | - 'title' => 'How does it affect me? How do I act and feel?', |
|
| 393 | - 'answer' => 'iuyb', |
|
| 394 | - ], [ |
|
| 395 | - 'title' => 'How does it affect the important people in my life?', |
|
| 396 | - 'answer' => 'iuyb', |
|
| 397 | - ], [ |
|
| 398 | - 'title' => 'Why do I do this? What is the benefit for me?', |
|
| 399 | - 'answer' => 'liuyb', |
|
| 400 | - ], |
|
| 401 | - ], |
|
| 402 | - ], |
|
| 295 | + 13 => [ |
|
| 296 | + 'question' => [ |
|
| 297 | + 'id' => 13, |
|
| 298 | + 'title' => 'less time/energy for God, meetings, and church', |
|
| 299 | + ], |
|
| 300 | + 'answers' => [ |
|
| 301 | + [ |
|
| 302 | + 'title' => 'How does it affect me? How do I act and feel?', |
|
| 303 | + 'answer' => 'alsgn', |
|
| 304 | + ], [ |
|
| 305 | + 'title' => 'How does it affect the important people in my life?', |
|
| 306 | + 'answer' => 'loiun', |
|
| 307 | + ], [ |
|
| 308 | + 'title' => 'Why do I do this? What is the benefit for me?', |
|
| 309 | + 'answer' => 'liun', |
|
| 310 | + ], |
|
| 311 | + ], |
|
| 312 | + ], |
|
| 313 | + 29 => [ |
|
| 314 | + 'question' => [ |
|
| 315 | + 'id' => 29, |
|
| 316 | + 'title' => 'using profanity', |
|
| 317 | + ], |
|
| 318 | + 'answers' => [ |
|
| 319 | + [ |
|
| 320 | + 'title' => 'How does it affect me? How do I act and feel?', |
|
| 321 | + 'answer' => 'ljnb', |
|
| 322 | + ], [ |
|
| 323 | + 'title' => 'How does it affect the important people in my life?', |
|
| 324 | + 'answer' => 'liunb', |
|
| 325 | + ], [ |
|
| 326 | + 'title' => 'Why do I do this? What is the benefit for me?', |
|
| 327 | + 'answer' => 'ilub ', |
|
| 328 | + ], |
|
| 329 | + ], |
|
| 330 | + ], |
|
| 331 | + 48 => [ |
|
| 332 | + 'question' => [ |
|
| 333 | + 'id' => 48, |
|
| 334 | + 'title' => 'workaholic', |
|
| 335 | + ], |
|
| 336 | + 'answers' => [ |
|
| 337 | + [ |
|
| 338 | + 'title' => 'How does it affect me? How do I act and feel?', |
|
| 339 | + 'answer' => 'liub', |
|
| 340 | + ], [ |
|
| 341 | + 'title' => 'How does it affect the important people in my life?', |
|
| 342 | + 'answer' => 'liub', |
|
| 343 | + ], [ |
|
| 344 | + 'title' => 'Why do I do this? What is the benefit for me?', |
|
| 345 | + 'answer' => 'liub ', |
|
| 346 | + ], |
|
| 347 | + ], |
|
| 348 | + ], |
|
| 349 | + 89 => [ |
|
| 350 | + 'question' => [ |
|
| 351 | + 'id' => 89, |
|
| 352 | + 'title' => 'obsessive (stuck) thoughts', |
|
| 353 | + ], |
|
| 354 | + 'answers' => [ |
|
| 355 | + [ |
|
| 356 | + 'title' => 'How does it affect me? How do I act and feel?', |
|
| 357 | + 'answer' => 'liub', |
|
| 358 | + ], [ |
|
| 359 | + 'title' => 'How does it affect the important people in my life?', |
|
| 360 | + 'answer' => 'liuby', |
|
| 361 | + ], [ |
|
| 362 | + 'title' => 'Why do I do this? What is the benefit for me?', |
|
| 363 | + 'answer' => 'uiylb', |
|
| 364 | + ], |
|
| 365 | + ], |
|
| 366 | + ], |
|
| 367 | + 111 => [ |
|
| 368 | + 'question' => [ |
|
| 369 | + 'id' => 111, |
|
| 370 | + 'title' => 'seeking out old unhealthy people and places', |
|
| 371 | + ], |
|
| 372 | + 'answers' => [ |
|
| 373 | + [ |
|
| 374 | + 'title' => 'How does it affect me? How do I act and feel?', |
|
| 375 | + 'answer' => 'liub', |
|
| 376 | + ], [ |
|
| 377 | + 'title' => 'How does it affect the important people in my life?', |
|
| 378 | + 'answer' => 'liuyb', |
|
| 379 | + ], [ |
|
| 380 | + 'title' => 'Why do I do this? What is the benefit for me?', |
|
| 381 | + 'answer' => 'iuyb', |
|
| 382 | + ], |
|
| 383 | + ], |
|
| 384 | + ], |
|
| 385 | + 122 => [ |
|
| 386 | + 'question' => [ |
|
| 387 | + 'id' => 122, |
|
| 388 | + 'title' => 'returning to the place you swore you would never go again', |
|
| 389 | + ], |
|
| 390 | + 'answers' => [ |
|
| 391 | + [ |
|
| 392 | + 'title' => 'How does it affect me? How do I act and feel?', |
|
| 393 | + 'answer' => 'iuyb', |
|
| 394 | + ], [ |
|
| 395 | + 'title' => 'How does it affect the important people in my life?', |
|
| 396 | + 'answer' => 'iuyb', |
|
| 397 | + ], [ |
|
| 398 | + 'title' => 'Why do I do this? What is the benefit for me?', |
|
| 399 | + 'answer' => 'liuyb', |
|
| 400 | + ], |
|
| 401 | + ], |
|
| 402 | + ], |
|
| 403 | 403 | ]; |
| 404 | 404 | |
| 405 | 405 | public $behaviorData = [ |
| 406 | - [ |
|
| 407 | - 'id' => 820, |
|
| 408 | - 'user_id' => 2, |
|
| 409 | - 'behavior_id' => 7, |
|
| 410 | - 'date' => '2016-09-10 19:26:04', |
|
| 411 | - 'behavior' => [ |
|
| 412 | - 'id' => 7, |
|
| 413 | - 'name' => 'making eye contact', |
|
| 414 | - 'category_id' => 1, |
|
| 415 | - 'category' => [ |
|
| 416 | - 'id' => 1, |
|
| 417 | - 'name' => 'Restoration', |
|
| 418 | - ], |
|
| 419 | - ], |
|
| 420 | - ], [ |
|
| 421 | - 'id' => 821, |
|
| 422 | - 'user_id' => 2, |
|
| 423 | - 'behavior_id' => 13, |
|
| 424 | - 'date' => '2016-09-10 19:26:04', |
|
| 425 | - 'behavior' => [ |
|
| 426 | - 'id' => 13, |
|
| 427 | - 'name' => 'less time/energy for God, meetings, and church', |
|
| 428 | - 'category_id' => 2, |
|
| 429 | - 'category' => [ |
|
| 430 | - 'id' => 2, |
|
| 431 | - 'name' => 'Forgetting Priorities', |
|
| 432 | - ], |
|
| 433 | - ], |
|
| 434 | - ], [ |
|
| 435 | - 'id' => 822, |
|
| 436 | - 'user_id' => 2, |
|
| 437 | - 'behavior_id' => 18, |
|
| 438 | - 'date' => '2016-09-10 19:26:04', |
|
| 439 | - 'behavior' => [ |
|
| 440 | - 'id' => 18, |
|
| 441 | - 'name' => 'changes in goals', |
|
| 442 | - 'category_id' => 2, |
|
| 443 | - 'category' => [ |
|
| 444 | - 'id' => 2, |
|
| 445 | - 'name' => 'Forgetting Priorities', |
|
| 446 | - ], |
|
| 447 | - ], |
|
| 448 | - ], [ |
|
| 449 | - 'id' => 823, |
|
| 450 | - 'user_id' => 2, |
|
| 451 | - 'behavior_id' => 29, |
|
| 452 | - 'date' => '2016-09-10 19:26:04', |
|
| 453 | - 'behavior' => [ |
|
| 454 | - 'id' => 29, |
|
| 455 | - 'name' => 'using profanity', |
|
| 456 | - 'category_id' => 3, |
|
| 457 | - 'category' => [ |
|
| 458 | - 'id' => 3, |
|
| 459 | - 'name' => 'Anxiety', |
|
| 460 | - ], |
|
| 461 | - ], |
|
| 462 | - ], [ |
|
| 463 | - 'id' => 824, |
|
| 464 | - 'user_id' => 2, |
|
| 465 | - 'behavior_id' => 41, |
|
| 466 | - 'date' => '2016-09-10 19:26:04', |
|
| 467 | - 'behavior' => [ |
|
| 468 | - 'id' => 41, |
|
| 469 | - 'name' => 'co-dependent rescuing', |
|
| 470 | - 'category_id' => 3, |
|
| 471 | - 'category' => [ |
|
| 472 | - 'id' => 3, |
|
| 473 | - 'name' => 'Anxiety', |
|
| 474 | - ], |
|
| 475 | - ], |
|
| 476 | - ], [ |
|
| 477 | - 'id' => 825, |
|
| 478 | - 'user_id' => 2, |
|
| 479 | - 'behavior_id' => 48, |
|
| 480 | - 'date' => '2016-09-10 19:26:04', |
|
| 481 | - 'behavior' => [ |
|
| 482 | - 'id' => 48, |
|
| 483 | - 'name' => 'workaholic', |
|
| 484 | - 'category_id' => 4, |
|
| 485 | - 'category' => [ |
|
| 486 | - 'id' => 4, |
|
| 487 | - 'name' => 'Speeding Up', |
|
| 488 | - ], |
|
| 489 | - ], |
|
| 490 | - ], [ |
|
| 491 | - 'id' => 826, |
|
| 492 | - 'user_id' => 2, |
|
| 493 | - 'behavior_id' => 72, |
|
| 494 | - 'date' => '2016-09-10 19:26:04', |
|
| 495 | - 'behavior' => [ |
|
| 496 | - 'id' => 72, |
|
| 497 | - 'name' => 'black and white, all or nothing thinking', |
|
| 498 | - 'category_id' => 5, |
|
| 499 | - 'category' => [ |
|
| 500 | - 'id' => 5, |
|
| 501 | - 'name' => 'Ticked Off', |
|
| 502 | - ], |
|
| 503 | - ], |
|
| 504 | - ], [ |
|
| 505 | - 'id' => 827, |
|
| 506 | - 'user_id' => 2, |
|
| 507 | - 'behavior_id' => 79, |
|
| 508 | - 'date' => '2016-09-10 19:26:04', |
|
| 509 | - 'behavior' => [ |
|
| 510 | - 'id' => 79, |
|
| 511 | - 'name' => 'blaming', |
|
| 512 | - 'category_id' => 5, |
|
| 513 | - 'category' => [ |
|
| 514 | - 'id' => 5, |
|
| 515 | - 'name' => 'Ticked Off', |
|
| 516 | - ], |
|
| 517 | - ], |
|
| 518 | - ], [ |
|
| 519 | - 'id' => 828, |
|
| 520 | - 'user_id' => 2, |
|
| 521 | - 'behavior_id' => 89, |
|
| 522 | - 'date' => '2016-09-10 19:26:04', |
|
| 523 | - 'behavior' => [ |
|
| 524 | - 'id' => 89, |
|
| 525 | - 'name' => 'obsessive (stuck) thoughts', |
|
| 526 | - 'category_id' => 5, |
|
| 527 | - 'category' => [ |
|
| 528 | - 'id' => 5, |
|
| 529 | - 'name' => 'Ticked Off', |
|
| 530 | - ], |
|
| 531 | - ], |
|
| 532 | - ], [ |
|
| 533 | - 'id' => 829, |
|
| 534 | - 'user_id' => 2, |
|
| 535 | - 'behavior_id' => 111, |
|
| 536 | - 'date' => '2016-09-10 19:26:04', |
|
| 537 | - 'behavior' => [ |
|
| 538 | - 'id' => 111, |
|
| 539 | - 'name' => 'seeking out old unhealthy people and places', |
|
| 540 | - 'category_id' => 6, |
|
| 541 | - 'category' => [ |
|
| 542 | - 'id' => 6, |
|
| 543 | - 'name' => 'Exhausted', |
|
| 544 | - ], |
|
| 545 | - ], |
|
| 546 | - ], [ |
|
| 547 | - 'id' => 830, |
|
| 548 | - 'user_id' => 2, |
|
| 549 | - 'behavior_id' => 118, |
|
| 550 | - 'date' => '2016-09-10 19:26:04', |
|
| 551 | - 'behavior' => [ |
|
| 552 | - 'id' => 118, |
|
| 553 | - 'name' => 'not returning phone calls', |
|
| 554 | - 'category_id' => 6, |
|
| 555 | - 'category' => [ |
|
| 556 | - 'id' => 6, |
|
| 557 | - 'name' => 'Exhausted', |
|
| 558 | - ], |
|
| 559 | - ], |
|
| 560 | - ], [ |
|
| 561 | - 'id' => 831, |
|
| 562 | - 'user_id' => 2, |
|
| 563 | - 'behavior_id' => 122, |
|
| 564 | - 'date' => '2016-09-10 19:26:04', |
|
| 565 | - 'behavior' => [ |
|
| 566 | - 'id' => 122, |
|
| 567 | - 'name' => 'returning to the place you swore you would never go again', |
|
| 568 | - 'category_id' => 7, |
|
| 569 | - 'category' => [ |
|
| 570 | - 'id' => 7, |
|
| 571 | - 'name' => 'Relapse/Moral Failure', |
|
| 572 | - ], |
|
| 573 | - ], |
|
| 574 | - ], |
|
| 406 | + [ |
|
| 407 | + 'id' => 820, |
|
| 408 | + 'user_id' => 2, |
|
| 409 | + 'behavior_id' => 7, |
|
| 410 | + 'date' => '2016-09-10 19:26:04', |
|
| 411 | + 'behavior' => [ |
|
| 412 | + 'id' => 7, |
|
| 413 | + 'name' => 'making eye contact', |
|
| 414 | + 'category_id' => 1, |
|
| 415 | + 'category' => [ |
|
| 416 | + 'id' => 1, |
|
| 417 | + 'name' => 'Restoration', |
|
| 418 | + ], |
|
| 419 | + ], |
|
| 420 | + ], [ |
|
| 421 | + 'id' => 821, |
|
| 422 | + 'user_id' => 2, |
|
| 423 | + 'behavior_id' => 13, |
|
| 424 | + 'date' => '2016-09-10 19:26:04', |
|
| 425 | + 'behavior' => [ |
|
| 426 | + 'id' => 13, |
|
| 427 | + 'name' => 'less time/energy for God, meetings, and church', |
|
| 428 | + 'category_id' => 2, |
|
| 429 | + 'category' => [ |
|
| 430 | + 'id' => 2, |
|
| 431 | + 'name' => 'Forgetting Priorities', |
|
| 432 | + ], |
|
| 433 | + ], |
|
| 434 | + ], [ |
|
| 435 | + 'id' => 822, |
|
| 436 | + 'user_id' => 2, |
|
| 437 | + 'behavior_id' => 18, |
|
| 438 | + 'date' => '2016-09-10 19:26:04', |
|
| 439 | + 'behavior' => [ |
|
| 440 | + 'id' => 18, |
|
| 441 | + 'name' => 'changes in goals', |
|
| 442 | + 'category_id' => 2, |
|
| 443 | + 'category' => [ |
|
| 444 | + 'id' => 2, |
|
| 445 | + 'name' => 'Forgetting Priorities', |
|
| 446 | + ], |
|
| 447 | + ], |
|
| 448 | + ], [ |
|
| 449 | + 'id' => 823, |
|
| 450 | + 'user_id' => 2, |
|
| 451 | + 'behavior_id' => 29, |
|
| 452 | + 'date' => '2016-09-10 19:26:04', |
|
| 453 | + 'behavior' => [ |
|
| 454 | + 'id' => 29, |
|
| 455 | + 'name' => 'using profanity', |
|
| 456 | + 'category_id' => 3, |
|
| 457 | + 'category' => [ |
|
| 458 | + 'id' => 3, |
|
| 459 | + 'name' => 'Anxiety', |
|
| 460 | + ], |
|
| 461 | + ], |
|
| 462 | + ], [ |
|
| 463 | + 'id' => 824, |
|
| 464 | + 'user_id' => 2, |
|
| 465 | + 'behavior_id' => 41, |
|
| 466 | + 'date' => '2016-09-10 19:26:04', |
|
| 467 | + 'behavior' => [ |
|
| 468 | + 'id' => 41, |
|
| 469 | + 'name' => 'co-dependent rescuing', |
|
| 470 | + 'category_id' => 3, |
|
| 471 | + 'category' => [ |
|
| 472 | + 'id' => 3, |
|
| 473 | + 'name' => 'Anxiety', |
|
| 474 | + ], |
|
| 475 | + ], |
|
| 476 | + ], [ |
|
| 477 | + 'id' => 825, |
|
| 478 | + 'user_id' => 2, |
|
| 479 | + 'behavior_id' => 48, |
|
| 480 | + 'date' => '2016-09-10 19:26:04', |
|
| 481 | + 'behavior' => [ |
|
| 482 | + 'id' => 48, |
|
| 483 | + 'name' => 'workaholic', |
|
| 484 | + 'category_id' => 4, |
|
| 485 | + 'category' => [ |
|
| 486 | + 'id' => 4, |
|
| 487 | + 'name' => 'Speeding Up', |
|
| 488 | + ], |
|
| 489 | + ], |
|
| 490 | + ], [ |
|
| 491 | + 'id' => 826, |
|
| 492 | + 'user_id' => 2, |
|
| 493 | + 'behavior_id' => 72, |
|
| 494 | + 'date' => '2016-09-10 19:26:04', |
|
| 495 | + 'behavior' => [ |
|
| 496 | + 'id' => 72, |
|
| 497 | + 'name' => 'black and white, all or nothing thinking', |
|
| 498 | + 'category_id' => 5, |
|
| 499 | + 'category' => [ |
|
| 500 | + 'id' => 5, |
|
| 501 | + 'name' => 'Ticked Off', |
|
| 502 | + ], |
|
| 503 | + ], |
|
| 504 | + ], [ |
|
| 505 | + 'id' => 827, |
|
| 506 | + 'user_id' => 2, |
|
| 507 | + 'behavior_id' => 79, |
|
| 508 | + 'date' => '2016-09-10 19:26:04', |
|
| 509 | + 'behavior' => [ |
|
| 510 | + 'id' => 79, |
|
| 511 | + 'name' => 'blaming', |
|
| 512 | + 'category_id' => 5, |
|
| 513 | + 'category' => [ |
|
| 514 | + 'id' => 5, |
|
| 515 | + 'name' => 'Ticked Off', |
|
| 516 | + ], |
|
| 517 | + ], |
|
| 518 | + ], [ |
|
| 519 | + 'id' => 828, |
|
| 520 | + 'user_id' => 2, |
|
| 521 | + 'behavior_id' => 89, |
|
| 522 | + 'date' => '2016-09-10 19:26:04', |
|
| 523 | + 'behavior' => [ |
|
| 524 | + 'id' => 89, |
|
| 525 | + 'name' => 'obsessive (stuck) thoughts', |
|
| 526 | + 'category_id' => 5, |
|
| 527 | + 'category' => [ |
|
| 528 | + 'id' => 5, |
|
| 529 | + 'name' => 'Ticked Off', |
|
| 530 | + ], |
|
| 531 | + ], |
|
| 532 | + ], [ |
|
| 533 | + 'id' => 829, |
|
| 534 | + 'user_id' => 2, |
|
| 535 | + 'behavior_id' => 111, |
|
| 536 | + 'date' => '2016-09-10 19:26:04', |
|
| 537 | + 'behavior' => [ |
|
| 538 | + 'id' => 111, |
|
| 539 | + 'name' => 'seeking out old unhealthy people and places', |
|
| 540 | + 'category_id' => 6, |
|
| 541 | + 'category' => [ |
|
| 542 | + 'id' => 6, |
|
| 543 | + 'name' => 'Exhausted', |
|
| 544 | + ], |
|
| 545 | + ], |
|
| 546 | + ], [ |
|
| 547 | + 'id' => 830, |
|
| 548 | + 'user_id' => 2, |
|
| 549 | + 'behavior_id' => 118, |
|
| 550 | + 'date' => '2016-09-10 19:26:04', |
|
| 551 | + 'behavior' => [ |
|
| 552 | + 'id' => 118, |
|
| 553 | + 'name' => 'not returning phone calls', |
|
| 554 | + 'category_id' => 6, |
|
| 555 | + 'category' => [ |
|
| 556 | + 'id' => 6, |
|
| 557 | + 'name' => 'Exhausted', |
|
| 558 | + ], |
|
| 559 | + ], |
|
| 560 | + ], [ |
|
| 561 | + 'id' => 831, |
|
| 562 | + 'user_id' => 2, |
|
| 563 | + 'behavior_id' => 122, |
|
| 564 | + 'date' => '2016-09-10 19:26:04', |
|
| 565 | + 'behavior' => [ |
|
| 566 | + 'id' => 122, |
|
| 567 | + 'name' => 'returning to the place you swore you would never go again', |
|
| 568 | + 'category_id' => 7, |
|
| 569 | + 'category' => [ |
|
| 570 | + 'id' => 7, |
|
| 571 | + 'name' => 'Relapse/Moral Failure', |
|
| 572 | + ], |
|
| 573 | + ], |
|
| 574 | + ], |
|
| 575 | 575 | ]; |
| 576 | 576 | |
| 577 | 577 | public $userBehaviors = [ |
| 578 | - 1 => [ |
|
| 579 | - 'category_name' => 'Restoration', |
|
| 580 | - 'behaviors' => [ |
|
| 581 | - [ |
|
| 582 | - 'id' => 7, |
|
| 583 | - 'name' => 'making eye contact', |
|
| 584 | - ], |
|
| 585 | - ], |
|
| 586 | - ], |
|
| 587 | - 2 => [ |
|
| 588 | - 'category_name' => 'Forgetting Priorities', |
|
| 589 | - 'behaviors' => [ |
|
| 590 | - [ |
|
| 591 | - 'id' => 13, |
|
| 592 | - 'name' => 'less time/energy for God, meetings, and church', |
|
| 593 | - ], [ |
|
| 594 | - 'id' => 18, |
|
| 595 | - 'name' => 'changes in goals', |
|
| 596 | - ], |
|
| 597 | - ], |
|
| 578 | + 1 => [ |
|
| 579 | + 'category_name' => 'Restoration', |
|
| 580 | + 'behaviors' => [ |
|
| 581 | + [ |
|
| 582 | + 'id' => 7, |
|
| 583 | + 'name' => 'making eye contact', |
|
| 584 | + ], |
|
| 585 | + ], |
|
| 586 | + ], |
|
| 587 | + 2 => [ |
|
| 588 | + 'category_name' => 'Forgetting Priorities', |
|
| 589 | + 'behaviors' => [ |
|
| 590 | + [ |
|
| 591 | + 'id' => 13, |
|
| 592 | + 'name' => 'less time/energy for God, meetings, and church', |
|
| 593 | + ], [ |
|
| 594 | + 'id' => 18, |
|
| 595 | + 'name' => 'changes in goals', |
|
| 596 | + ], |
|
| 597 | + ], |
|
| 598 | 598 | ], |
| 599 | 599 | 3 => [ |
| 600 | - 'category_name' => 'Anxiety', |
|
| 601 | - 'behaviors' => [ |
|
| 602 | - [ |
|
| 603 | - 'id' => 29, |
|
| 604 | - 'name' => 'using profanity', |
|
| 605 | - ], [ |
|
| 606 | - 'id' => 41, |
|
| 607 | - 'name' => 'co-dependent rescuing', |
|
| 608 | - ], |
|
| 609 | - ], |
|
| 610 | - ], |
|
| 611 | - 4 => [ |
|
| 612 | - 'category_name' => 'Speeding Up', |
|
| 613 | - 'behaviors' => [ |
|
| 614 | - [ |
|
| 615 | - 'id' => 48, |
|
| 616 | - 'name' => 'workaholic', |
|
| 617 | - ], |
|
| 618 | - ], |
|
| 619 | - ], |
|
| 620 | - 5 => [ |
|
| 621 | - 'category_name' => 'Ticked Off', |
|
| 622 | - 'behaviors' => [ |
|
| 623 | - [ |
|
| 624 | - 'id' => 72, |
|
| 625 | - 'name' => 'black and white, all or nothing thinking', |
|
| 626 | - ], [ |
|
| 627 | - 'id' => 79, |
|
| 628 | - 'name' => 'blaming', |
|
| 629 | - ], [ |
|
| 630 | - 'id' => 89, |
|
| 631 | - 'name' => 'obsessive (stuck) thoughts', |
|
| 632 | - ], |
|
| 633 | - ], |
|
| 634 | - ], |
|
| 635 | - 6 => [ |
|
| 636 | - 'category_name' => 'Exhausted', |
|
| 637 | - 'behaviors' => [ |
|
| 638 | - [ |
|
| 639 | - 'id' => 111, |
|
| 640 | - 'name' => 'seeking out old unhealthy people and places', |
|
| 641 | - ], [ |
|
| 642 | - 'id' => 118, |
|
| 643 | - 'name' => 'not returning phone calls', |
|
| 644 | - ], |
|
| 645 | - ], |
|
| 646 | - ], |
|
| 647 | - 7 => [ |
|
| 648 | - 'category_name' => 'Relapse/Moral Failure', |
|
| 649 | - 'behaviors' => [ |
|
| 650 | - [ |
|
| 651 | - 'id' => 122, |
|
| 652 | - 'name' => 'returning to the place you swore you would never go again', |
|
| 653 | - ], |
|
| 654 | - ], |
|
| 655 | - ], |
|
| 600 | + 'category_name' => 'Anxiety', |
|
| 601 | + 'behaviors' => [ |
|
| 602 | + [ |
|
| 603 | + 'id' => 29, |
|
| 604 | + 'name' => 'using profanity', |
|
| 605 | + ], [ |
|
| 606 | + 'id' => 41, |
|
| 607 | + 'name' => 'co-dependent rescuing', |
|
| 608 | + ], |
|
| 609 | + ], |
|
| 610 | + ], |
|
| 611 | + 4 => [ |
|
| 612 | + 'category_name' => 'Speeding Up', |
|
| 613 | + 'behaviors' => [ |
|
| 614 | + [ |
|
| 615 | + 'id' => 48, |
|
| 616 | + 'name' => 'workaholic', |
|
| 617 | + ], |
|
| 618 | + ], |
|
| 619 | + ], |
|
| 620 | + 5 => [ |
|
| 621 | + 'category_name' => 'Ticked Off', |
|
| 622 | + 'behaviors' => [ |
|
| 623 | + [ |
|
| 624 | + 'id' => 72, |
|
| 625 | + 'name' => 'black and white, all or nothing thinking', |
|
| 626 | + ], [ |
|
| 627 | + 'id' => 79, |
|
| 628 | + 'name' => 'blaming', |
|
| 629 | + ], [ |
|
| 630 | + 'id' => 89, |
|
| 631 | + 'name' => 'obsessive (stuck) thoughts', |
|
| 632 | + ], |
|
| 633 | + ], |
|
| 634 | + ], |
|
| 635 | + 6 => [ |
|
| 636 | + 'category_name' => 'Exhausted', |
|
| 637 | + 'behaviors' => [ |
|
| 638 | + [ |
|
| 639 | + 'id' => 111, |
|
| 640 | + 'name' => 'seeking out old unhealthy people and places', |
|
| 641 | + ], [ |
|
| 642 | + 'id' => 118, |
|
| 643 | + 'name' => 'not returning phone calls', |
|
| 644 | + ], |
|
| 645 | + ], |
|
| 646 | + ], |
|
| 647 | + 7 => [ |
|
| 648 | + 'category_name' => 'Relapse/Moral Failure', |
|
| 649 | + 'behaviors' => [ |
|
| 650 | + [ |
|
| 651 | + 'id' => 122, |
|
| 652 | + 'name' => 'returning to the place you swore you would never go again', |
|
| 653 | + ], |
|
| 654 | + ], |
|
| 655 | + ], |
|
| 656 | 656 | ]; |
| 657 | 657 | |
| 658 | 658 | public $exportData = [ |
@@ -727,7 +727,7 @@ discard block |
||
| 727 | 727 | $this->container = new \yii\di\Container; |
| 728 | 728 | $this->container->set('common\interfaces\UserInterface', '\site\tests\_support\MockUser'); |
| 729 | 729 | $this->container->set('common\interfaces\UserBehaviorInterface', '\site\tests\_support\MockUserBehavior'); |
| 730 | - $this->container->set('common\interfaces\TimeInterface', function () { |
|
| 730 | + $this->container->set('common\interfaces\TimeInterface', function() { |
|
| 731 | 731 | return new \common\components\Time('America/Los_Angeles'); |
| 732 | 732 | }); |
| 733 | 733 | |
@@ -773,21 +773,21 @@ discard block |
||
| 773 | 773 | } |
| 774 | 774 | |
| 775 | 775 | public function testParseQuestionData() { |
| 776 | - $this->specify('parseQuestionData should function correctly', function () { |
|
| 776 | + $this->specify('parseQuestionData should function correctly', function() { |
|
| 777 | 777 | expect('parseQuestionData should return the correct structure with expected data', $this->assertEquals($this->user->parseQuestionData($this->questionData), $this->userQuestions)); |
| 778 | 778 | expect('parseQuestionData should return empty with the empty set', $this->assertEmpty($this->user->parseQuestionData([]))); |
| 779 | 779 | }); |
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | public function testParseBehaviorData() { |
| 783 | - $this->specify('parseBehaviorData should function correctly', function () { |
|
| 783 | + $this->specify('parseBehaviorData should function correctly', function() { |
|
| 784 | 784 | expect('parseBehaviorData should return the correct structure with expected data', $this->assertEquals($this->user->parseBehaviorData($this->behaviorData), $this->userBehaviors)); |
| 785 | 785 | expect('parseBehaviorData should return empty with the empty set', $this->assertEmpty($this->user->parseBehaviorData([]))); |
| 786 | 786 | }); |
| 787 | 787 | } |
| 788 | 788 | |
| 789 | 789 | public function testIsTokenCurrent() { |
| 790 | - $this->specify('isTokenCurrent should function correctly', function () { |
|
| 790 | + $this->specify('isTokenCurrent should function correctly', function() { |
|
| 791 | 791 | $good_token = \Yii::$app |
| 792 | 792 | ->getSecurity() |
| 793 | 793 | ->generateRandomString() . '_' . time(); |
@@ -821,7 +821,7 @@ discard block |
||
| 821 | 821 | public function testConfirmVerifyEmailToken() { |
| 822 | 822 | $this->user->verify_email_token = 'hello_world'; |
| 823 | 823 | $this->user->confirmVerifyEmailToken(); |
| 824 | - expect('confirmVerifyEmailToken should append User::CONFIRMED_STRING to the end of the verify_email_token property', $this->assertEquals($this->user->verify_email_token, 'hello_world'.$this->user::CONFIRMED_STRING)); |
|
| 824 | + expect('confirmVerifyEmailToken should append User::CONFIRMED_STRING to the end of the verify_email_token property', $this->assertEquals($this->user->verify_email_token, 'hello_world' . $this->user::CONFIRMED_STRING)); |
|
| 825 | 825 | } |
| 826 | 826 | |
| 827 | 827 | public function testIsVerified() { |
@@ -915,7 +915,7 @@ discard block |
||
| 915 | 915 | ->disableOriginalConstructor() |
| 916 | 916 | ->setMethods(['save', 'attributes', 'getCheckinBreakdown']) |
| 917 | 917 | ->getMock(); |
| 918 | - $expected = require(__DIR__.'/../data/expected_getCheckinBreakdown.php'); |
|
| 918 | + $expected = require(__DIR__ . '/../data/expected_getCheckinBreakdown.php'); |
|
| 919 | 919 | $user_behavior->method('getCheckinBreakdown')->willReturn($expected); |
| 920 | 920 | |
| 921 | 921 | $user = $this->getMockBuilder('\common\models\User') |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | 'id' => 'form-signup', |
| 27 | 27 | 'enableClientValidation' => true, |
| 28 | 28 | 'enableAjaxValidation' => false, |
| 29 | - 'options' => [ 'validateOnSubmit' => true ] |
|
| 29 | + 'options' => ['validateOnSubmit' => true] |
|
| 30 | 30 | ]); ?> |
| 31 | 31 | <?= $form->field($model, 'email', ['inputTemplate' => '<div class="input-group"><span class="input-group-addon">@</span>{input}</div>'])->input('email') ?> |
| 32 | 32 | <?= $form->field($model, 'password', ['inputTemplate' => '<div class="input-group">{input}<span class="input-group-btn"><button id="password-toggle" class="btn btn-default" type="button">Show</button></span></div>'])->passwordInput() ?> |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | 'template' => '<div class="row"><div class="col-md-5">{image}</div><div class="col-md-6 col-md-offset-1">{input}</div></div>', |
| 36 | 36 | ]) ?> |
| 37 | 37 | <?= $form->field($model, 'send_email')->checkbox(['disabled'=>true]) ?> |
| 38 | - <div id='send_email_fields' <?php if(!$model->send_email) { ?>style="display: none;"<?php } ?>> |
|
| 38 | + <div id='send_email_fields' <?php if (!$model->send_email) { ?>style="display: none;"<?php } ?>> |
|
| 39 | 39 | <?= $form->field($model, 'email_category')->dropdownList(Category::getCategories(), ['data-toggle' => 'tooltip', 'data-placement' => 'left', 'data-trigger' => 'hover', 'data-delay' => '{"show": 500, "hide": 100}', 'title' => 'Want to send an email with every check-in? Try setting this to "Restoration"']) ?> |
| 40 | 40 | <?= $form->field($model, 'partner_email1')->input('email') ?> |
| 41 | 41 | <?= $form->field($model, 'partner_email2')->input('email') ?> |
@@ -71,11 +71,11 @@ |
||
| 71 | 71 | ]); ?> |
| 72 | 72 | <?= $form->field($profile, 'timezone')->dropDownList(array_combine($timezones, $timezones)); ?> |
| 73 | 73 | <?= $form->field($profile, 'expose_graph')->checkbox() ?> |
| 74 | - <?php if($profile->expose_graph): ?> |
|
| 74 | + <?php if ($profile->expose_graph): ?> |
|
| 75 | 75 | <div class='alert alert-success behaviors-graph-info'>Your behaviors graph can be found at:<br /> <a id="behaviors-graph-link" target="_blank" href="<?=$graph_url?>"><?=$graph_url?></a></div> |
| 76 | 76 | <?php endif; ?> |
| 77 | 77 | <?= $form->field($profile, 'send_email')->checkbox() ?> |
| 78 | - <div id='send_email_fields' <?php if(!$profile->send_email) { ?>style="display: none;"<?php } ?>> |
|
| 78 | + <div id='send_email_fields' <?php if (!$profile->send_email) { ?>style="display: none;"<?php } ?>> |
|
| 79 | 79 | <?= $form->field($profile, 'email_category')->dropdownList(Category::getCategories(), ['data-toggle' => 'tooltip', 'data-placement' => 'left', 'data-trigger' => 'hover', 'data-delay' => '{"show": 500, "hide": 100}', 'title' => 'Want to send an email with every check-in? Try setting this to "Restoration"']) ?> |
| 80 | 80 | <?= $form->field($profile, 'partner_email1')->input('email'); ?> |
| 81 | 81 | <?= $form->field($profile, 'partner_email2')->input('email'); ?> |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | - * @codeCoverageIgnore |
|
| 64 | - */ |
|
| 63 | + * @codeCoverageIgnore |
|
| 64 | + */ |
|
| 65 | 65 | public function attributeLabels() { |
| 66 | 66 | return [ |
| 67 | 67 | 'partner_email1' => "Partner Email #1", |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | // generate behaviors graph image |
| 95 | 95 | $checkins_last_month = (Yii::$container->get(\common\interfaces\UserBehaviorInterface::class)) |
| 96 | - ->getCheckInBreakdown(); |
|
| 96 | + ->getCheckInBreakdown(); |
|
| 97 | 97 | |
| 98 | 98 | // if they haven't done a check-in in the last month this will explode |
| 99 | 99 | // because $checkins_last_month is an empty array |
@@ -85,10 +85,10 @@ discard block |
||
| 85 | 85 | $graph = Yii::$container |
| 86 | 86 | ->get(\common\components\Graph::class, [$this->user]); |
| 87 | 87 | |
| 88 | - if($this->timezone) { |
|
| 88 | + if ($this->timezone) { |
|
| 89 | 89 | $user->timezone = $this->timezone; |
| 90 | 90 | } |
| 91 | - if($this->expose_graph) { |
|
| 91 | + if ($this->expose_graph) { |
|
| 92 | 92 | $user->expose_graph = true; |
| 93 | 93 | |
| 94 | 94 | // generate behaviors graph image |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | // if they haven't done a check-in in the last month this will explode |
| 99 | 99 | // because $checkins_last_month is an empty array |
| 100 | - if($checkins_last_month) { |
|
| 100 | + if ($checkins_last_month) { |
|
| 101 | 101 | $graph->create($checkins_last_month, true); |
| 102 | 102 | } |
| 103 | 103 | } else { |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | $graph->destroy(); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - if($this->send_email) { |
|
| 109 | + if ($this->send_email) { |
|
| 110 | 110 | $user->send_email = true; |
| 111 | 111 | $user->email_category = $this->email_category; |
| 112 | 112 | $user->partner_email1 = $this->partner_email1; |
@@ -53,10 +53,10 @@ discard block |
||
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | public function setBehaviors($behaviors) { |
| 56 | - foreach($behaviors as $category_id => $category_data) { |
|
| 56 | + foreach ($behaviors as $category_id => $category_data) { |
|
| 57 | 57 | $attribute = "behaviors$category_id"; |
| 58 | 58 | $this->$attribute = []; |
| 59 | - foreach($category_data['behaviors'] as $behavior) { |
|
| 59 | + foreach ($category_data['behaviors'] as $behavior) { |
|
| 60 | 60 | $this->{$attribute}[] = $behavior['id']; |
| 61 | 61 | } |
| 62 | 62 | } |
@@ -64,8 +64,8 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | public function validateBehaviors($attribute, $params) { |
| 66 | 66 | if (!$this->hasErrors()) { |
| 67 | - foreach($this->$attribute as $behavior) { |
|
| 68 | - if(!is_numeric($behavior)) { |
|
| 67 | + foreach ($this->$attribute as $behavior) { |
|
| 68 | + if (!is_numeric($behavior)) { |
|
| 69 | 69 | $this->addError($attribute, 'One of your behaviors is not an integer!'); |
| 70 | 70 | } |
| 71 | 71 | } |
@@ -103,20 +103,20 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | // delete cached behaviors |
| 105 | 105 | array_map(function($period) use ($time) { |
| 106 | - $key = "checkins_".Yii::$app->user->id."_{$period}_".$time->getLocalDate(); |
|
| 106 | + $key = "checkins_" . Yii::$app->user->id . "_{$period}_" . $time->getLocalDate(); |
|
| 107 | 107 | Yii::$app->cache->delete($key); |
| 108 | 108 | }, [30, 90, 180]); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | public function save() { |
| 112 | - if(empty($this->compiled_behaviors)) { |
|
| 112 | + if (empty($this->compiled_behaviors)) { |
|
| 113 | 113 | $this->commpiled_behaviors = $this->compileBehaviors(); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | $user_behavior = Yii::$container->get(\common\interfaces\UserBehaviorInterface::class); |
| 117 | 117 | |
| 118 | 118 | $rows = []; |
| 119 | - foreach($this->compiled_behaviors as $behavior_id) { |
|
| 119 | + foreach ($this->compiled_behaviors as $behavior_id) { |
|
| 120 | 120 | $temp = [ |
| 121 | 121 | Yii::$app->user->id, |
| 122 | 122 | (int)$behavior_id, |
@@ -135,10 +135,10 @@ discard block |
||
| 135 | 135 | )->execute(); |
| 136 | 136 | |
| 137 | 137 | // if the user has publicised their check-in graph, create the image |
| 138 | - if(Yii::$app->user->identity->expose_graph) { |
|
| 138 | + if (Yii::$app->user->identity->expose_graph) { |
|
| 139 | 139 | $checkins_last_month = $user_behavior->getCheckInBreakdown(); |
| 140 | 140 | |
| 141 | - if($checkins_last_month) { |
|
| 141 | + if ($checkins_last_month) { |
|
| 142 | 142 | Yii::$container |
| 143 | 143 | ->get(\common\components\Graph::class, [Yii::$app->user->identity]) |
| 144 | 144 | ->create($checkins_last_month, true); |