mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-07 03:40:50 +00:00
31ff77efb6
2ffad9317d
Inline Skipper (#2877)
23 lines
645 B
PHP
23 lines
645 B
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace Rector\Skipper;
|
|
|
|
final class Fnmatcher
|
|
{
|
|
public function match(string $matchingPath, string $filePath) : bool
|
|
{
|
|
$normalizedMatchingPath = $this->normalizePath($matchingPath);
|
|
$normalizedFilePath = $this->normalizePath($filePath);
|
|
if (\fnmatch($normalizedMatchingPath, $normalizedFilePath)) {
|
|
return \true;
|
|
}
|
|
// in case of relative compare
|
|
return \fnmatch('*/' . $normalizedMatchingPath, $normalizedFilePath);
|
|
}
|
|
private function normalizePath(string $path) : string
|
|
{
|
|
return \str_replace('\\', '/', $path);
|
|
}
|
|
}
|