ValidateAction::run()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 0
cts 7
cp 0
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * HiSite Yii2 base project.
4
 *
5
 * @link      https://github.com/hiqdev/hisite
6
 * @package   hisite
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2016-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hisite\actions;
12
13
use Yii;
14
use yii\di\Instance;
15
use yii\web\Response;
16
use yii\widgets\ActiveForm;
17
18
/**
19
 * Action to validate form with.
20
 */
21
class ValidateAction extends \yii\base\Action
22
{
23
    public $format = Response::FORMAT_JSON;
24
25
    public $form;
26
27
    public function run()
28
    {
29
        Yii::$app->response->format = $this->format;
30
31
        $model = Instance::ensure($this->form);
32
        $model->load(Yii::$app->request->post());
33
34
        return ActiveForm::validate($model);
35
    }
36
}
37