Test Failed
Push — master ( 320d62...b1d181 )
by Alexey
05:17
created

ServerController::csrfAction()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 9
nc 2
nop 1
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * INJI
5
 *
6
 * @author Alexey Krupskiy <[email protected]>
7
 * @link http://inji.ru/
8
 * @copyright 2017 Alexey Krupskiy
9
 * @license https://github.com/injitools/Inji/blob/master/LICENSE
10
 */
11
class ServerController extends Controller {
12
    function csrfAction($key = '') {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
13
        $result = new \Server\Result();
14
        $key = (string)$key;
15
        if (!$key) {
16
            $result->success = false;
17
            return $result->send();
18
        }
19
        $_SESSION['csrf'][$key] = Tools::randomString();
20
        $result->content = $_SESSION['csrf'][$key];
21
        $result->send();
22
    }
23
}