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

eliashaeussler / typo3-warming / 17686100843

12 Sep 2025 09:09PM UTC coverage: 92.603%. Remained the same
17686100843

push

github

web-flow
Merge pull request #953 from eliashaeussler/feature/state

10 of 11 new or added lines in 2 files covered. (90.91%)

1640 of 1771 relevant lines covered (92.6%)

12.57 hits per line

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

94.44
/Classes/Enums/WarmupState.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the TYPO3 CMS extension "warming".
7
 *
8
 * Copyright (C) 2021-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\Typo3Warming\Enums;
25

26
use EliasHaeussler\CacheWarmup;
27
use EliasHaeussler\Typo3Warming\Result;
28
use Psr\Log;
29

30
/**
31
 * WarmupState
32
 *
33
 * @author Elias Häußler <elias@haeussler.dev>
34
 * @license GPL-2.0-or-later
35
 */
36
enum WarmupState: string
37
{
38
    case Failed = 'failed';
39
    case Success = 'success';
40
    case Unknown = 'unknown';
41
    case Warning = 'warning';
42

43
    /**
44
     * @phpstan-param Log\LogLevel::* $level
45
     */
46
    public static function fromLogLevel(string $level): self
8✔
47
    {
48
        if (CacheWarmup\Log\LogLevel::satisfies(Log\LogLevel::ERROR, $level)) {
8✔
49
            return self::Failed;
4✔
50
        }
51

52
        if (CacheWarmup\Log\LogLevel::satisfies(Log\LogLevel::WARNING, $level)) {
4✔
53
            return self::Warning;
1✔
54
        }
55

56
        if (CacheWarmup\Log\LogLevel::satisfies(Log\LogLevel::INFO, $level)) {
3✔
57
            return self::Success;
2✔
58
        }
59

60
        return self::Unknown;
1✔
61
    }
62

63
    public static function fromCacheWarmupResult(Result\CacheWarmupResult $result): self
13✔
64
    {
65
        $failed = \count($result->getResult()->getFailed());
13✔
66
        $successful = \count($result->getResult()->getSuccessful());
13✔
67

68
        if ($failed > 0 && $successful === 0) {
13✔
69
            return self::Failed;
10✔
70
        }
71

72
        if ($failed > 0 && $successful > 0) {
3✔
73
            return self::Warning;
1✔
74
        }
75

76
        if ($failed === 0) {
2✔
77
            return self::Success;
2✔
78
        }
79

NEW
80
        return self::Unknown;
×
81
    }
82
}
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