Server   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A checkCsrfForm() 0 5 3
A checkCsrf() 0 2 2
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