• 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

88.89
/src/Utility/PathUtility.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\Utility;
15

16
use function strlen;
17

18
/**
19
 * PathUtility.
20
 *
21
 * @author Konrad Michalik <km@move-elevator.de>
22
 * @license GPL-3.0-or-later
23
 */
24
class PathUtility
25
{
26
    public static function normalizeFolderPath(string $path): string
29✔
27
    {
28
        $realPath = realpath($path);
29✔
29
        if (false === $realPath) {
29✔
30
            $normalizedPath = rtrim($path, \DIRECTORY_SEPARATOR);
18✔
31
            if (str_starts_with($normalizedPath, './')) {
18✔
32
                $normalizedPath = substr($normalizedPath, 2);
4✔
33
            }
34

35
            return $normalizedPath;
18✔
36
        }
37

38
        $normalizedPath = rtrim($realPath, \DIRECTORY_SEPARATOR);
11✔
39

40
        $cwd = getcwd();
11✔
41
        if (false === $cwd) {
11✔
UNCOV
42
            return $normalizedPath;
×
43
        }
44
        $realCwd = realpath($cwd);
11✔
45
        if (false === $realCwd) {
11✔
UNCOV
46
            return $normalizedPath;
×
47
        }
48
        $cwd = $realCwd.\DIRECTORY_SEPARATOR;
11✔
49

50
        if (str_starts_with($normalizedPath.\DIRECTORY_SEPARATOR, $cwd)) {
11✔
51
            return substr($normalizedPath, strlen($cwd));
9✔
52
        }
53

54
        return $normalizedPath;
2✔
55
    }
56
}
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