ValidateAction   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 4
dl 0
loc 16
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 9 1
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