Skip to content

Commit

Permalink
Dev: Split up some long lines
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Mar 11, 2020
1 parent 7930eff commit 9cedd88
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions application/models/SurveyActivator.php
@@ -1,5 +1,9 @@
<?php

/**
* Service class to activate survey.
* @todo Move to models/services/survey/ folder.
*/
class SurveyActivator
{
/** @var Survey */
Expand All @@ -24,7 +28,7 @@ class SurveyActivator
protected $createSurveyDir = false;

/** @var boolean */
public $isSimulation;
public $isSimulation = false;

/**
* @param Survey $survey
Expand Down Expand Up @@ -57,7 +61,11 @@ public function activate()
$this->prepareResponsesTable();

if ($this->isSimulation) {
return array('dbengine'=>Yii::app()->db->getDriverName(), 'dbtype'=>Yii::app()->db->driverName, 'fields'=>$this->tableDefinition);
return array(
'dbengine'=>Yii::app()->db->getDriverName(),
'dbtype'=>Yii::app()->db->driverName,
'fields'=>$this->tableDefinition
);
}

if (!$this->createParticipantsTable()) {
Expand All @@ -74,8 +82,9 @@ public function activate()

Yii::app()->db->createCommand()->update(
Survey::model()->tableName(),
['active'=>'Y'], 'sid=:sid',
[':sid'=>$this->survey->primaryKey]
['active' => 'Y'],
'sid=:sid',
[':sid' => $this->survey->primaryKey]
);

$aResult = array(
Expand Down Expand Up @@ -226,10 +235,16 @@ protected function prepareTableDefinition()
*/
protected function prepareTimingsTable()
{
$timingsfieldmap = createTimingsFieldMap($this->survey->primaryKey, "full", false, false, $this->survey->language);
$timingsfieldmap = createTimingsFieldMap(
$this->survey->primaryKey,
"full",
false,
false,
$this->survey->language
);
$aTimingTableDefinition = array();
$aTimingTableDefinition['id'] = $this->tableDefinition['id'];
foreach ($timingsfieldmap as $field => $fielddata) {
foreach (array_keys($timingsfieldmap) as $field) {
$aTimingTableDefinition[$field] = 'FLOAT';
}
$this->timingsTableDefinition = $aTimingTableDefinition;
Expand All @@ -245,7 +260,9 @@ protected function prepareCollation()
if (Yii::app()->db->driverName == 'mysqli' || Yii::app()->db->driverName == 'mysql') {
$this->collation = " COLLATE 'utf8mb4_bin'";
}
if (Yii::app()->db->driverName == 'sqlsrv' || Yii::app()->db->driverName == 'dblib' || Yii::app()->db->driverName == 'mssql') {
if (Yii::app()->db->driverName == 'sqlsrv'
|| Yii::app()->db->driverName == 'dblib'
|| Yii::app()->db->driverName == 'mssql') {
$this->collation = " COLLATE SQL_Latin1_General_CP1_CS_AS";
}
}
Expand Down Expand Up @@ -305,7 +322,11 @@ protected function createParticipantsTable()
}
try {
if (isset($this->tableDefinition['token'])) {
Yii::app()->db->createCommand()->createIndex("idx_survey_token_{$this->survey->primaryKey}_".rand(1, 50000), $sTableName, 'token');
Yii::app()->db->createCommand()->createIndex(
"idx_survey_token_{$this->survey->primaryKey}_".rand(1, 50000),
$sTableName,
'token'
);
}
} catch (\Exception $e) {
}
Expand Down

0 comments on commit 9cedd88

Please sign in to comment.