Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
80.00% covered (success)
80.00%
4 / 5
CRAP
88.89% covered (success)
88.89%
16 / 18
CreateMeetingForm
0.00% covered (danger)
0.00%
0 / 1
80.00% covered (success)
80.00%
4 / 5
6.05
88.89% covered (success)
88.89%
16 / 18
 rules
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 attributeLabels
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getEvent_span_id
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 getEvent_span_time_on
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
2 / 2
 createMeeting
0.00% covered (danger)
0.00%
0 / 1
2.02
83.33% covered (success)
83.33%
10 / 12
<?php
namespace frontend\models;
use Yii;
use common\models\Meeting;
use yii\base\Model;
/**
 * Create meeting form
 */
class CreateMeetingForm extends Model
{
    public $isNewRecord = true;
    public $event_span_key;
    public $host_participant_id;
    public $guest_participant_id;
    public $table_id;
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            ['event_span_key', 'required'],
            ['event_span_key', 'match', 'pattern' => '/^[\d]+[:][\d]+$/i'],
        ];
    }
    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'event_span_key' => Yii::t('app', 'Choose date and time of meeting'),
        ];
    }
    public function getEvent_span_id()
    {
        list($id, $on) = explode(':', $this->event_span_key);
        return $id;
    }
    public function getEvent_span_time_on()
    {
        list($id, $on) = explode(':', $this->event_span_key);
        return $on;
    }
    public function createMeeting()
    {
        $model = new Meeting();
        $model->host_participant_id = $this->host_participant_id;
        $model->guest_participant_id = $this->guest_participant_id;
        $model->is_confirmed_host = !Yii::$app->params['meeting.confirm.isRequired'];
        $model->event_span_id = $this->event_span_id;
        $model->event_span_time_on = $this->event_span_time_on;
        $model->table_id = $this->table_id;
        $model->generateHostConfirmationToken();
        if($model->save()){
            return $model;
        }
        $this->addErrors($model->errors);
        return null;
    }
}