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

RequestFormFactory   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 23
ccs 0
cts 17
cp 0
rs 10
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 16 4
A __construct() 0 2 1
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