Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of PHPUnit.
4
 *
5
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace PHPUnit\Util\Xml;
11
 
12
use function defined;
13
use function is_file;
14
use function sprintf;
15
use PHPUnit\Runner\Version;
16
 
17
/**
18
 * @internal This class is not covered by the backward compatibility promise for PHPUnit
19
 */
20
final class SchemaFinder
21
{
22
    /**
23
     * @throws Exception
24
     */
25
    public function find(string $version): string
26
    {
27
        if ($version === Version::series()) {
28
            $filename = $this->path() . 'phpunit.xsd';
29
        } else {
30
            $filename = $this->path() . 'schema/' . $version . '.xsd';
31
        }
32
 
33
        if (!is_file($filename)) {
34
            throw new Exception(
35
                sprintf(
36
                    'Schema for PHPUnit %s is not available',
37
                    $version
38
                )
39
            );
40
        }
41
 
42
        return $filename;
43
    }
44
 
45
    private function path(): string
46
    {
47
        if (defined('__PHPUNIT_PHAR_ROOT__')) {
48
            return __PHPUNIT_PHAR_ROOT__ . '/';
49
        }
50
 
51
        return __DIR__ . '/../../../';
52
    }
53
}