EventPlausability::addData()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 8
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 14
rs 10
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\Form\FormDataProvider;
13
14
use DERHANSEN\SfEventMgt\Service\EventPlausabilityService;
15
use TYPO3\CMS\Backend\Form\FormDataProviderInterface;
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Backend\Form\FormDataProviderInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
use TYPO3\CMS\Core\Utility\GeneralUtility;
17
18
/**
19
 * Uses EventPlausabilityService to check if event contains unplausible settings.
20
 */
21
class EventPlausability implements FormDataProviderInterface
22
{
23
    public function addData(array $result): array
24
    {
25
        if ($result['tableName'] !== 'tx_sfeventmgt_domain_model_event' || empty($result['databaseRow'])) {
26
            return $result;
27
        }
28
29
        $eventPlausabilityService = GeneralUtility::makeInstance(EventPlausabilityService::class);
30
        $eventPlausabilityService->verifyEventStartAndEnddate(
31
            (int)$result['databaseRow']['startdate'],
32
            (int)$result['databaseRow']['enddate']
33
        );
34
        $eventPlausabilityService->verifyOrganisatorConfiguration($result['databaseRow']);
35
36
        return $result;
37
    }
38
}
39