Server::checkCsrf()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 2
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Inji;
4
/**
5
 * Server module
6
 *
7
 * @author Alexey Krupskiy <[email protected]>
8
 * @link http://inji.ru/
9
 * @copyright 2015 Alexey Krupskiy
10
 * @license https://github.com/injitools/cms-Inji/blob/master/LICENSE
11
 */
12
class Server extends Module {
13
    public $name = 'Server';
14
15
    function checkCsrf($key, $token) {
16
        return !empty($_SESSION['csrf'][$key]) && $_SESSION['csrf'][$key] == $token;
17
    }
18
19
    function checkCsrfForm($formData) {
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...
20
        if (empty($formData['csrfKey']) || empty($formData['csrfToken'])) {
21
            return false;
22
        }
23
        return $this->checkCsrf($formData['csrfKey'], $formData['csrfToken']);
24
    }
25
}
26