Completed
Push — typo3-10-compatibility ( 43fd28...634dd5 )
by Torben
42:08
created

MiscUtility::isV9Lts()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
declare(strict_types=1);
3
namespace DERHANSEN\SfEventMgt\Utility;
4
5
/*
6
 * This file is part of the Extension "sf_event_mgt" for TYPO3 CMS.
7
 *
8
 * For the full copyright and license information, please read the
9
 * LICENSE.txt file that was distributed with this source code.
10
 */
11
12
use TYPO3\CMS\Core\Utility\GeneralUtility;
13
14
/**
15
 * Class MiscUtility
16
 */
17
class MiscUtility
18
{
19
    /**
20
     * Returns chars extracted from a hmac for the challenge/response spam check
21
     *
22
     * @param int $eventUid
23
     * @return string
24
     */
25
    public static function getSpamCheckChallenge(int $eventUid): string
26
    {
27
        $hmac = GeneralUtility::hmac('event-' . $eventUid, 'sf_event_mgt');
28
        $chars = preg_replace('/[0-9]+/', '', $hmac);
29
30
        return preg_replace_callback('/\w.?/', function ($m) {
31
            return ucfirst($m[0]);
32
        }, $chars);
33
    }
34
}
35