Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
InvalidArgumentException
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 forNonStringKeyWithValue
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 forUnreadableDirectory
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 php-fast-forward/config.
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) 2025-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/config
15 * @see       https://github.com/php-fast-forward
16 * @see       https://datatracker.ietf.org/doc/html/rfc2119
17 */
18
19namespace FastForward\Config\Exception;
20
21/**
22 * Class InvalidArgumentException.
23 *
24 * Specialized exception for handling invalid arguments within the configuration context.
25 * This class SHALL be used to provide meaningful errors when invalid data is passed
26 * to configuration components.
27 */
28 class InvalidArgumentException extends \InvalidArgumentException
29{
30    /**
31     * Thrown when the key is not a string but a value is provided.
32     *
33     * @return self the exception indicating the key must be a string
34     */
35    public static function forNonStringKeyWithValue(): self
36    {
37        return new self('The key must be a string when a value is provided.');
38    }
39
40    /**
41     * Thrown when a given directory does not exist or is not readable.
42     *
43     * @param string $directory the path to the invalid directory
44     *
45     * @return self the exception indicating an invalid or unreadable directory
46     */
47    public static function forUnreadableDirectory(string $directory): self
48    {
49        return new self(\sprintf('The directory "%s" does not exist or is not readable.', $directory));
50    }
51}