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

move-elevator / composer-translation-validator / 18559927341

16 Oct 2025 11:35AM UTC coverage: 95.519%. Remained the same
18559927341

Pull #73

github

jackd248
build: add php-cs-fixer-preset
Pull Request #73: build: add php-cs-fixer-preset

206 of 210 new or added lines in 16 files covered. (98.1%)

91 existing lines in 20 files now uncovered.

2345 of 2455 relevant lines covered (95.52%)

7.73 hits per line

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

78.57
/src/FileDetector/PrefixFileDetector.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the "composer-translation-validator" Composer plugin.
7
 *
8
 * (c) 2025 Konrad Michalik <km@move-elevator.de>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13

14
namespace MoveElevator\ComposerTranslationValidator\FileDetector;
15

16
/**
17
 * PrefixFileDetector.
18
 *
19
 * @author Konrad Michalik <km@move-elevator.de>
20
 * @license GPL-3.0-or-later
21
 */
22
class PrefixFileDetector implements DetectorInterface
23
{
24
    /**
25
     * @param array<int, string> $files
26
     *
27
     * @return array<string, array<int, string>>
28
     */
29
    public function mapTranslationSet(array $files): array
5✔
30
    {
31
        $groups = [];
5✔
32

33
        foreach ($files as $file) {
5✔
34
            $basename = basename($file);
4✔
35
            if (preg_match('/^([a-z]{2}(?:[-_][A-Z]{2})?)\.(.+)$/i', $basename, $matches)) {
4✔
36
                // Language prefix pattern (e.g., de.messages.xlf -> key: messages.xlf)
37
                $key = $matches[2];
2✔
38
                $groups[$key][] = $file;
2✔
39
            } elseif (preg_match('/^(locallang|messages|validation|errors|labels|translations?|test)\./', $basename)) {
4✔
40
                // Common translation file patterns (e.g., messages.xlf -> key: messages.xlf)
41
                $key = $basename;
4✔
42
                $groups[$key][] = $file;
4✔
UNCOV
43
            } elseif (preg_match('/^[^.]+\.(xlf|xliff|json|ya?ml|php)$/i', $basename) && !preg_match('/(config|validator|setting)/', $basename)) {
×
44
                // Generic translation files, but exclude config/validator files
UNCOV
45
                $key = $basename;
×
UNCOV
46
                $groups[$key][] = $file;
×
47
            }
48
        }
49

50
        return $groups;
5✔
51
    }
52
}
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