Cleanup code, improve typings

This commit is contained in:
ErickSkrauch
2019-12-13 22:27:13 +03:00
parent 830a17612b
commit d9ef27b745
28 changed files with 189 additions and 225 deletions

View File

@@ -1,12 +1,19 @@
<?php
declare(strict_types=1);
namespace common\models\confirmations;
use common\models\EmailActivation;
use common\models\EmailActivationQuery;
use yii\helpers\ArrayHelper;
class CurrentEmailConfirmation extends EmailActivation {
public function behaviors() {
public static function find(): EmailActivationQuery {
return parent::find()->withType(EmailActivation::TYPE_CURRENT_EMAIL_CONFIRMATION);
}
public function behaviors(): array {
return ArrayHelper::merge(parent::behaviors(), [
'expirationBehavior' => [
'repeatTimeout' => 6 * 60 * 60, // 6h
@@ -15,7 +22,7 @@ class CurrentEmailConfirmation extends EmailActivation {
]);
}
public function init() {
public function init(): void {
parent::init();
$this->type = EmailActivation::TYPE_CURRENT_EMAIL_CONFIRMATION;
}

View File

@@ -1,12 +1,19 @@
<?php
declare(strict_types=1);
namespace common\models\confirmations;
use common\models\EmailActivation;
use common\models\EmailActivationQuery;
use yii\helpers\ArrayHelper;
class ForgotPassword extends EmailActivation {
public function behaviors() {
public static function find(): EmailActivationQuery {
return parent::find()->withType(EmailActivation::TYPE_FORGOT_PASSWORD_KEY);
}
public function behaviors(): array {
return ArrayHelper::merge(parent::behaviors(), [
'expirationBehavior' => [
'repeatTimeout' => 30 * 60,
@@ -15,7 +22,7 @@ class ForgotPassword extends EmailActivation {
]);
}
public function init() {
public function init(): void {
parent::init();
$this->type = EmailActivation::TYPE_FORGOT_PASSWORD_KEY;
}

View File

@@ -1,7 +1,10 @@
<?php
declare(strict_types=1);
namespace common\models\confirmations;
use common\models\EmailActivation;
use common\models\EmailActivationQuery;
use yii\helpers\ArrayHelper;
/**
@@ -10,7 +13,11 @@ use yii\helpers\ArrayHelper;
*/
class NewEmailConfirmation extends EmailActivation {
public function behaviors() {
public static function find(): EmailActivationQuery {
return parent::find()->withType(EmailActivation::TYPE_NEW_EMAIL_CONFIRMATION);
}
public function behaviors(): array {
return ArrayHelper::merge(parent::behaviors(), [
'expirationBehavior' => [
'repeatTimeout' => 5 * 60,
@@ -21,7 +28,7 @@ class NewEmailConfirmation extends EmailActivation {
]);
}
public function init() {
public function init(): void {
parent::init();
$this->type = EmailActivation::TYPE_NEW_EMAIL_CONFIRMATION;
}

View File

@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace common\models\confirmations;
use common\behaviors\DataBehavior;

View File

@@ -1,11 +1,18 @@
<?php
declare(strict_types=1);
namespace common\models\confirmations;
use common\models\EmailActivation;
use common\models\EmailActivationQuery;
class RegistrationConfirmation extends EmailActivation {
public function init() {
public static function find(): EmailActivationQuery {
return parent::find()->withType(EmailActivation::TYPE_REGISTRATION_EMAIL_CONFIRMATION);
}
public function init(): void {
parent::init();
$this->type = EmailActivation::TYPE_REGISTRATION_EMAIL_CONFIRMATION;
}