Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
/*
6
 * This file is part of the league/config package.
7
 *
8
 * (c) Colin O'Dell <colinodell@gmail.com>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
 
14
namespace League\Config\Exception;
15
 
16
class InvalidConfigurationException extends \UnexpectedValueException implements ConfigurationExceptionInterface
17
{
18
    /**
19
     * @param string  $option      Name/path of the option
20
     * @param mixed   $valueGiven  The invalid option that was provided
21
     * @param ?string $description Additional text describing the issue (optional)
22
     */
23
    public static function forConfigOption(string $option, $valueGiven, ?string $description = null): self
24
    {
25
        $message = \sprintf('Invalid config option for "%s": %s', $option, self::getDebugValue($valueGiven));
26
        if ($description !== null) {
27
            $message .= \sprintf(' (%s)', $description);
28
        }
29
 
30
        return new self($message);
31
    }
32
 
33
    /**
34
     * @param mixed $value
35
     *
36
     * @psalm-pure
37
     */
38
    private static function getDebugValue($value): string
39
    {
40
        if (\is_object($value)) {
41
            return \get_class($value);
42
        }
43
 
44
        return \print_r($value, true);
45
    }
46
}