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

MiscUtility   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getSpamCheckChallenge() 0 9 1
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