aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/linters/src/Support/Paths.php
blob: 2e500570361987f76a7ba0945d16c435c7aef1d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php

declare(strict_types=1);

namespace Shirabe\Lint\Support;

final class Paths
{
    public static function relativeTo(string $rootDir, string $path): string
    {
        $root = rtrim($rootDir, '/') . '/';

        return str_starts_with($path, $root) ? substr($path, strlen($root)) : $path;
    }
}