Passed
Push — refactor/backendModule-ValueOb... ( 355cec...0f77d0 )
by Tomas Norre
13:40
created

RequestFormFactory::create()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 11
c 1
b 0
f 0
nc 4
nop 2
dl 0
loc 16
ccs 0
cts 14
cp 0
crap 20
rs 9.9
1
<?php
2
declare(strict_types=1);
3
4
namespace AOE\Crawler\Backend\RequestForm;
5
6
/*
7
 * (c) 2020 AOE GmbH <[email protected]>
8
 *
9
 * This file is part of the TYPO3 Crawler Extension.
10
 *
11
 * It is free software; you can redistribute it and/or modify it under
12
 * the terms of the GNU General Public License, either version 2
13
 * of the License, or any later version.
14
 *
15
 * For the full copyright and license information, please read the
16
 * LICENSE.txt file that was distributed with this source code.
17
 *
18
 * The TYPO3 project - inspiring people to share!
19
 */
20
21
use AOE\Crawler\Value\CrawlAction;
22
use TYPO3\CMS\Core\Utility\GeneralUtility;
23
use TYPO3\CMS\Fluid\View\StandaloneView;
24
25
final class RequestFormFactory
26
{
27
    public function __construct()
28
    {
29
        // Perhaps this can be removed, will need to check.
30
    }
31
32
    public static function create(CrawlAction $selectedAction, StandaloneView $view): RequestForm
33
    {
34
        switch ($selectedAction->__toString()) {
35
            case 'log':
36
                /** @var RequestForm $requestForm */
37
                $requestForm = GeneralUtility::makeInstance(LogRequestForm::class, $view);
38
                break;
39
            case 'multiprocess':
40
                $requestForm = GeneralUtility::makeInstance(MultiProcessRequestForm::class, $view);
41
                break;
42
            case 'start':
43
            default:
44
                $requestForm = GeneralUtility::makeInstance(StartRequestForm::class, $view);
45
        }
46
47
        return $requestForm;
48
    }
49
}
50