GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Helpers::parseLoginData()   B
last analyzed

Complexity

Conditions 6
Paths 24

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 6.105

Importance

Changes 0
Metric Value
dl 0
loc 20
ccs 12
cts 14
cp 0.8571
rs 8.9777
c 0
b 0
f 0
cc 6
nc 24
nop 1
crap 6.105
1
<?php
2
3
namespace Skautis;
4
5
/**
6
 * @author Petr Morávek <[email protected]>
7
 */
8
final class Helpers
9
{
10
11
    /**
12
     * @throws StaticClassException
13
     */
14
    final public function __construct()
15
    {
16
        throw new StaticClassException;
17
    }
18
19
    /**
20
     * Parsuje pole dat zaslaných skautISem (například $_SESSION)
21
     *
22
     * @param array $data
23
     * @return array
24
     * @throws UnexpectedValueException pokud se nepodaří naparsovat datum
25
     */
26 1
    public static function parseLoginData(array $data)
27
    {
28 1
        $loginData = [];
29 1
        $loginData[User::ID_LOGIN] = isset($data['skautIS_Token']) ? $data['skautIS_Token'] : null;
30 1
        $loginData[User::ID_ROLE] = isset($data['skautIS_IDRole']) ? (int) $data['skautIS_IDRole'] : null;
31 1
        $loginData[User::ID_UNIT] = isset($data['skautIS_IDUnit']) ? (int) $data['skautIS_IDUnit'] : null;
32
33 1
        if (isset($data['skautIS_DateLogout'])) {
34 1
            $tz = new \DateTimeZone('Europe/Prague');
35 1
            $logoutDate = \DateTime::createFromFormat('j. n. Y H:i:s', $data['skautIS_DateLogout'], $tz);
36 1
            if ($logoutDate === false) {
37
                throw new UnexpectedValueException("Could not parse logout date '{$data['skautIS_DateLogout']}'.");
38
            }
39 1
            $loginData[User::LOGOUT_DATE] = $logoutDate;
40 1
        } else {
41
            $loginData[User::LOGOUT_DATE] = null;
42
        }
43
44 1
        return $loginData;
45
    }
46
}
47