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.
Completed
Pull Request — 2.x (#61)
by
unknown
17:53 queued 15:58
created

Helpers::parseLoginData()   B

Complexity

Conditions 6
Paths 24

Size

Total Lines 20
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 6.1308

Importance

Changes 0
Metric Value
dl 0
loc 20
ccs 11
cts 13
cp 0.8462
rs 8.8571
c 0
b 0
f 0
cc 6
eloc 14
nc 24
nop 1
crap 6.1308
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
        } else {
41
            $loginData[User::LOGOUT_DATE] = null;
42
        }
43
44 1
        return $loginData;
45
    }
46
}
47