• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

eliashaeussler / typo3-config-objects / 14489909490

16 Apr 2025 09:55AM UTC coverage: 62.195% (-37.8%) from 100.0%
14489909490

Pull #1

github

eliashaeussler
[FEATURE] Add configuration object for request middlewares
Pull Request #1: [FEATURE] Add configuration object for request middlewares

0 of 62 new or added lines in 3 files covered. (0.0%)

102 of 164 relevant lines covered (62.2%)

2.02 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Configuration/MiddlewareConfiguration.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the Composer package "eliashaeussler/typo3-config-objects".
7
 *
8
 * Copyright (C) 2025 Elias Häußler <elias@haeussler.dev>
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation, either version 2 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22
 */
23

24
namespace EliasHaeussler\Typo3ConfigObjects\Configuration;
25

26
use EliasHaeussler\Typo3ConfigObjects\ValueObject;
27

28
/**
29
 * MiddlewareConfiguration.
30
 *
31
 * @author Elias Häußler <elias@haeussler.dev>
32
 * @license GPL-2.0-or-later
33
 *
34
 * @phpstan-import-type MiddlewareOptions from ValueObject\RequestMiddleware
35
 *
36
 * @implements Configuration<array{
37
 *     backend: array<string, MiddlewareOptions>,
38
 *     frontend: array<string, MiddlewareOptions>,
39
 * }>
40
 */
41
final class MiddlewareConfiguration implements Configuration
42
{
43
    /**
44
     * @var list<ValueObject\RequestMiddleware>
45
     */
46
    private array $backendStack = [];
47

48
    /**
49
     * @var list<ValueObject\RequestMiddleware>
50
     */
51
    private array $frontendStack = [];
52

NEW
53
    private function __construct() {}
×
54

NEW
55
    public static function create(): self
×
56
    {
NEW
57
        return new self();
×
58
    }
59

NEW
60
    public function addToBackendStack(ValueObject\RequestMiddleware ...$requestMiddlewares): self
×
61
    {
NEW
62
        foreach ($requestMiddlewares as $requestMiddleware) {
×
NEW
63
            $this->backendStack[] = $requestMiddleware;
×
64
        }
65

NEW
66
        return $this;
×
67
    }
68

NEW
69
    public function addToFrontendStack(ValueObject\RequestMiddleware ...$requestMiddlewares): self
×
70
    {
NEW
71
        foreach ($requestMiddlewares as $requestMiddleware) {
×
NEW
72
            $this->frontendStack[] = $requestMiddleware;
×
73
        }
74

NEW
75
        return $this;
×
76
    }
77

NEW
78
    public function toArray(): array
×
79
    {
NEW
80
        $configuration = [
×
NEW
81
            'backend' => [],
×
NEW
82
            'frontend' => [],
×
NEW
83
        ];
×
84

NEW
85
        foreach ($this->backendStack as $requestMiddleware) {
×
NEW
86
            $configuration['backend'][$requestMiddleware->name] = $requestMiddleware->toArray();
×
87
        }
88

NEW
89
        foreach ($this->frontendStack as $requestMiddleware) {
×
NEW
90
            $configuration['frontend'][$requestMiddleware->name] = $requestMiddleware->toArray();
×
91
        }
92

NEW
93
        return $configuration;
×
94
    }
95
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc