<?php

declare(strict_types=1);

/*
 * This file is part of the league/config package.
 *
 * (c) Colin O'Dell <colinodell@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace League\Config\Exception;

class InvalidConfigurationException extends \UnexpectedValueException implements ConfigurationExceptionInterface
{
    /**
     * @param string  $option      Name/path of the option
     * @param mixed   $valueGiven  The invalid option that was provided
     * @param ?string $description Additional text describing the issue (optional)
     */
    public static function forConfigOption(string $option, $valueGiven, ?string $description = null): self
    {
        $message = \sprintf('Invalid config option for "%s": %s', $option, self::getDebugValue($valueGiven));
        if ($description !== null) {
            $message .= \sprintf(' (%s)', $description);
        }

        return new self($message);
    }

    /**
     * @param mixed $value
     *
     * @psalm-pure
     */
    private static function getDebugValue($value): string
    {
        if (\is_object($value)) {
            return \get_class($value);
        }

        return \print_r($value, true);
    }
}
                                                                                                                                                                                                                                                             {
    "name": "league/config",
    "type": "library",
    "description": "Define configuration arrays with strict schemas and access values with dot notation",
    "keywords": ["configuration","config","schema","array","nested","dot","dot-access"],
    "homepage": "https://config.thephpleague.com",
    "license": "BSD-3-Clause",
    "authors": [
        {
            "name": "Colin O'Dell",
            "email": "colinodell@gmail.com",
            "homepage": "https://www.colinodell.com",
            "role": "Lead Developer"
        }
    ],
    "support": {
        "docs": "https://config.thephpleague.com/",
        "issues": "https://github.com/thephpleague/config/issues",
        "rss": "https://github.com/thephpleague/config/releases.atom",
        "source": "https://github.com/thephpleague/config"
    },
    "require": {
        "php": "^7.4 || ^8.0",
        "dflydev/dot-access-data": "^3.0.1",
        "nette/schema": "^1.2"
    },
    "require-dev": {
        "phpstan/phpstan": "^1.8.2",
        "phpunit/phpunit": "^9.5.5",
        "scrutinizer/ocular": "^1.8.1",
        "unleashedtech/php-coding-standard": "^3.1",
        "vimeo/psalm": "^4.7.3"
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "autoload": {
        "psr-4": {
            "League\\Config\\": "src"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "League\\Config\\Tests\\": "tests"
        }
    },
    "scripts": {
        "phpcs": "phpcs",
        "phpstan": "phpstan analyse",
        "phpunit": "phpunit --no-coverage",
        "psalm": "psalm",
        "test": [
            "@phpcs",
            "@phpstan",
            "@psalm",
            "@phpunit"
        ]
    },
    "extra": {
        "branch-alias": {
            "dev-main": "1.2-dev"
        }
    },
    "config": {
        "sort-packages": true,
        "allow-plugins": {
            "dealerdirect/phpcodesniffer-composer-installer": true
        }
    }
}
