|
4 | 4 |
|
5 | 5 | namespace Internal; |
6 | 6 |
|
| 7 | +/** |
| 8 | + * Immutable value object for working with file system paths. |
| 9 | + * |
| 10 | + * Handles path normalization and manipulation across different operating systems. |
| 11 | + * Paths are automatically normalized: `.` and `..` segments are resolved, duplicate |
| 12 | + * separators are removed, and both `/` and `\` are accepted. Windows drive letters |
| 13 | + * like `C:/Users` are properly recognized. |
| 14 | + * |
| 15 | + * This object is designed to be used as a DTO or value object throughout your application. |
| 16 | + * All methods return new instances, making it safe to pass between layers, store in properties, |
| 17 | + * or use as command/query parameters without worrying about unexpected mutations. |
| 18 | + * |
| 19 | + * ``` |
| 20 | + * $path = Path::create('/var/www/app'); |
| 21 | + * $full = $path->join('src', 'Controller.php'); |
| 22 | + * echo $full; // '/var/www/app/src/Controller.php' |
| 23 | + * |
| 24 | + * $file = Path::create('report.pdf'); |
| 25 | + * $file->name(); // 'report.pdf' |
| 26 | + * $file->stem(); // 'report' |
| 27 | + * $file->extension(); // 'pdf' |
| 28 | + * ``` |
| 29 | + */ |
7 | 30 | final class Path implements \Stringable |
8 | 31 | { |
| 32 | + /** |
| 33 | + * Directory separator used internally. |
| 34 | + * All paths are normalized to use forward slash regardless of OS. |
| 35 | + */ |
9 | 36 | private const DS = '/'; |
10 | 37 |
|
11 | 38 | /** |
@@ -203,8 +230,8 @@ public function absolute(): self |
203 | 230 | * |
204 | 231 | * @param non-empty-string|self $pattern The pattern to match against. Can be a string path or Path object. |
205 | 232 | * Will be converted to absolute path before matching. |
206 | | - * @param bool|null $caseSensitive Whether the match should be case-sensitive. If null, uses OS default: |
207 | | - * case-insensitive on Windows, case-sensitive on Unix/Linux. |
| 233 | + * @param bool|null $caseSensitive Whether the match should be case-sensitive. |
| 234 | + * If null, uses OS default: case-insensitive on Windows, case-sensitive on Unix/Linux. |
208 | 235 | * |
209 | 236 | * @return bool True if the path matches the pattern, false otherwise. |
210 | 237 | */ |
|
0 commit comments