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

eliashaeussler / typo3-solver / 8562357037

04 Apr 2024 10:58PM UTC coverage: 87.107%. Remained the same
8562357037

Pull #221

github

web-flow
[TASK] Update css-loader to v7

| datasource | package    | from   | to    |
| ---------- | ---------- | ------ | ----- |
| npm        | css-loader | 6.11.0 | 7.0.0 |
Pull Request #221: [TASK] Update css-loader to v7

858 of 985 relevant lines covered (87.11%)

6.71 hits per line

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

96.15
/Classes/ProblemSolving/Solution/Prompt/DefaultPrompt.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the TYPO3 CMS extension "solver".
7
 *
8
 * Copyright (C) 2024 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\Typo3Solver\ProblemSolving\Solution\Prompt;
25

26
use EliasHaeussler\Typo3Solver\View;
27
use Spatie\Backtrace;
28
use Throwable;
29
use TYPO3\CMS\Core;
30

31
use function preg_replace;
32
use function trim;
33

34
/**
35
 * DefaultPrompt.
36
 *
37
 * @author Elias Häußler <elias@haeussler.dev>
38
 * @license GPL-2.0-or-later
39
 */
40
final class DefaultPrompt implements Prompt
41
{
42
    private readonly Core\Information\Typo3Version $typo3Version;
43

44
    public function __construct(
15✔
45
        private readonly View\TemplateRenderer $renderer,
46
    ) {
47
        $this->typo3Version = new Core\Information\Typo3Version();
15✔
48
    }
49

50
    public static function create(): static
14✔
51
    {
52
        return new self(new View\TemplateRenderer());
14✔
53
    }
54

55
    public function generate(Throwable $exception): string
10✔
56
    {
57
        $prompt = trim(
10✔
58
            $this->renderer->render('Prompt/Default', [
10✔
59
                'exception' => $exception,
10✔
60
                'exceptionClass' => $exception::class,
10✔
61
                'snippet' => $this->createCodeSnippet($exception),
10✔
62
                'mode' => Core\Core\Environment::isComposerMode() ? 'composer' : 'classic (symlink)',
10✔
63
                'typo3Version' => $this->typo3Version->getVersion(),
10✔
64
                'phpVersion' => PHP_VERSION,
10✔
65
            ]),
10✔
66
        );
10✔
67

68
        return preg_replace('/((?<!\n)\n(?!(\n|\d)))/', ' ', $prompt) ?? $prompt;
10✔
69
    }
70

71
    private function createCodeSnippet(Throwable $exception): string
10✔
72
    {
73
        $backtrace = Backtrace\Backtrace::createForThrowable($exception);
10✔
74
        $frames = $backtrace->frames();
10✔
75
        $applicationFrame = $frames[$backtrace->firstApplicationFrameIndex()] ?? null;
10✔
76
        $snippet = '';
10✔
77

78
        // Early return if application frame could not be determined
79
        if ($applicationFrame === null) {
10✔
80
            return $snippet;
×
81
        }
82

83
        foreach ($applicationFrame->getSnippet(9) as $number => $line) {
10✔
84
            $snippet .= $number . ' ' . $line . PHP_EOL;
8✔
85
        }
86

87
        return trim($snippet);
10✔
88
    }
89
}
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