HoneypotSpamCheck::isFailed()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
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
namespace DERHANSEN\SfEventMgt\SpamChecks;
13
14
class HoneypotSpamCheck extends AbstractSpamCheck
15
{
16
    /**
17
     * Check is failed, if expected honeypot field is not present in arguments or if expected field
18
     * contains a value
19
     */
20
    public function isFailed(): bool
21
    {
22
        $honeypotField = 'hp' . ($this->arguments['event'] ?? 0);
23
24
        return !isset($this->arguments['registration'][$honeypotField]) ||
25
            ($this->arguments['registration'][$honeypotField] ?? 'spam') !== '';
26
    }
27
}
28