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

eliashaeussler / typo3-warming / 18040892543

26 Sep 2025 02:36PM UTC coverage: 92.759% (+0.2%) from 92.569%
18040892543

push

github

web-flow
[TASK] Update stylelint-copyright to v3.9.1

| datasource | package             | from  | to    |
| ---------- | ------------------- | ----- | ----- |
| npm        | stylelint-copyright | 3.9.0 | 3.9.1 |

1691 of 1823 relevant lines covered (92.76%)

12.26 hits per line

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

98.63
/Classes/Result/CacheWarmupResult.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\Result;
25

26
use EliasHaeussler\CacheWarmup;
27
use EliasHaeussler\Typo3Warming\Domain;
28
use EliasHaeussler\Typo3Warming\Http;
29
use TYPO3\CMS\Core;
30

31
/**
32
 * CacheWarmupResult
33
 *
34
 * @author Elias Häußler <elias@haeussler.dev>
35
 * @license GPL-2.0-or-later
36
 */
37
final readonly class CacheWarmupResult
38
{
39
    /**
40
     * @param list<CacheWarmup\Sitemap\Sitemap> $excludedSitemaps
41
     * @param list<CacheWarmup\Sitemap\Url> $excludedUrls
42
     */
43
    public function __construct(
18✔
44
        private CacheWarmup\Result\CacheWarmupResult $result,
45
        private array $excludedSitemaps = [],
46
        private array $excludedUrls = [],
47
    ) {}
18✔
48

49
    public function getResult(): CacheWarmup\Result\CacheWarmupResult
10✔
50
    {
51
        return $this->result;
10✔
52
    }
53

54
    /**
55
     * @return array{
56
     *     successful: list<CacheWarmup\Result\CrawlingResult>,
57
     *     failed: list<CacheWarmup\Result\CrawlingResult>,
58
     * }
59
     */
60
    public function getCrawlingResultsBySite(
11✔
61
        Core\Site\Entity\Site $site,
62
        Core\Site\Entity\SiteLanguage $siteLanguage,
63
    ): array {
64
        return [
11✔
65
            'successful' => array_values(
11✔
66
                array_filter(
11✔
67
                    $this->result->getSuccessful(),
11✔
68
                    fn(CacheWarmup\Result\CrawlingResult $crawlingResult) => $this->filterBySite(
11✔
69
                        $crawlingResult,
11✔
70
                        $site,
11✔
71
                        $siteLanguage,
11✔
72
                    ),
11✔
73
                ),
11✔
74
            ),
11✔
75
            'failed' => array_values(
11✔
76
                array_filter(
11✔
77
                    $this->result->getFailed(),
11✔
78
                    fn(CacheWarmup\Result\CrawlingResult $crawlingResult) => $this->filterBySite(
11✔
79
                        $crawlingResult,
11✔
80
                        $site,
11✔
81
                        $siteLanguage,
11✔
82
                    ),
11✔
83
                ),
11✔
84
            ),
11✔
85
        ];
11✔
86
    }
87

88
    /**
89
     * @return array{
90
     *     successful: list<CacheWarmup\Result\CrawlingResult>,
91
     *     failed: list<CacheWarmup\Result\CrawlingResult>,
92
     * }
93
     */
94
    public function getCrawlingResultsByPage(int $pageId, ?string $pageType = null, ?int $languageId = null): array
4✔
95
    {
96
        return [
4✔
97
            'successful' => array_values(
4✔
98
                array_filter(
4✔
99
                    $this->result->getSuccessful(),
4✔
100
                    fn(CacheWarmup\Result\CrawlingResult $crawlingResult) => $this->filterByPage(
4✔
101
                        $crawlingResult,
4✔
102
                        $pageId,
4✔
103
                        $pageType,
4✔
104
                        $languageId,
4✔
105
                    ),
4✔
106
                ),
4✔
107
            ),
4✔
108
            'failed' => array_values(
4✔
109
                array_filter(
4✔
110
                    $this->result->getFailed(),
4✔
111
                    fn(CacheWarmup\Result\CrawlingResult $crawlingResult) => $this->filterByPage(
4✔
112
                        $crawlingResult,
4✔
113
                        $pageId,
4✔
114
                        $pageType,
4✔
115
                        $languageId,
4✔
116
                    ),
4✔
117
                ),
4✔
118
            ),
4✔
119
        ];
4✔
120
    }
121

122
    /**
123
     * @return list<CacheWarmup\Sitemap\Sitemap>
124
     */
125
    public function getExcludedSitemaps(): array
10✔
126
    {
127
        return $this->excludedSitemaps;
10✔
128
    }
129

130
    /**
131
     * @return list<CacheWarmup\Sitemap\Url>
132
     */
133
    public function getExcludedUrls(): array
10✔
134
    {
135
        return $this->excludedUrls;
10✔
136
    }
137

138
    private function filterBySite(
10✔
139
        CacheWarmup\Result\CrawlingResult $crawlingResult,
140
        Core\Site\Entity\Site $site,
141
        Core\Site\Entity\SiteLanguage $siteLanguage,
142
    ): bool {
143
        $url = $crawlingResult->getUri();
10✔
144

145
        if (!($url instanceof CacheWarmup\Sitemap\Url)) {
10✔
146
            return false;
1✔
147
        }
148

149
        $rootOrigin = $url->getRootOrigin();
10✔
150

151
        return $rootOrigin instanceof Domain\Model\SiteAwareSitemap
10✔
152
            && $rootOrigin->getSite() === $site
10✔
153
            && $rootOrigin->getSiteLanguage() === $siteLanguage
10✔
154
        ;
10✔
155
    }
156

157
    private function filterByPage(
3✔
158
        CacheWarmup\Result\CrawlingResult $crawlingResult,
159
        int $pageId,
160
        ?string $pageType = null,
161
        ?int $languageId = null,
162
    ): bool {
163
        $urlMetadata = $crawlingResult->getData()['urlMetadata'] ?? null;
3✔
164

165
        if (!($urlMetadata instanceof Http\Message\UrlMetadata)) {
3✔
166
            return false;
×
167
        }
168

169
        return $urlMetadata->pageId === $pageId
3✔
170
            && ($pageType === null || $urlMetadata->pageType === $pageType)
3✔
171
            && ($languageId === null || $urlMetadata->languageId === $languageId)
3✔
172
        ;
3✔
173
    }
174
}
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