Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
Reader
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 read
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5/**
6 * This file is part of fast-forward/dev-tools.
7 *
8 * This source file is subject to the license bundled
9 * with this source code in the file LICENSE.
10 *
11 * @copyright Copyright (c) 2026 Felipe SayĆ£o Lobato Abreu <github@mentordosnerds.com>
12 * @license   https://opensource.org/licenses/MIT MIT License
13 *
14 * @see       https://github.com/php-fast-forward/dev-tools
15 * @see       https://github.com/php-fast-forward
16 * @see       https://datatracker.ietf.org/doc/html/rfc2119
17 */
18
19namespace FastForward\DevTools\GitIgnore;
20
21/**
22 * Reads .gitignore files and returns domain representations for them.
23 *
24 * This reader SHALL provide a minimal abstraction for loading a .gitignore file
25 * from a filesystem path. The implementation MUST delegate file parsing to the
26 * GitIgnore value object and MUST return a GitIgnoreInterface-compatible result.
27 */
28 class Reader implements ReaderInterface
29{
30    /**
31     * Reads a .gitignore file from the specified filesystem path.
32     *
33     * The provided path MUST reference a readable .gitignore file. This method
34     * SHALL delegate object creation to GitIgnore::fromFile() and MUST return
35     * the resulting GitIgnoreInterface implementation.
36     *
37     * @param string $gitignorePath The filesystem path to the .gitignore file.
38     *
39     * @return GitIgnoreInterface The loaded .gitignore representation.
40     */
41    public function read(string $gitignorePath): GitIgnoreInterface
42    {
43        return GitIgnore::fromFile($gitignorePath);
44    }
45}