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
/**
13
 * @internal This class is not covered by the backward compatibility promise for PHPUnit
14
 */
15
final class SchemaDetector
16
{
17
    /**
18
     * @throws Exception
19
     */
20
    public function detect(string $filename): SchemaDetectionResult
21
    {
22
        $document = (new Loader)->loadFile(
23
            $filename,
24
            false,
25
            true,
26
            true
27
        );
28
 
29
        foreach (['9.2', '8.5'] as $candidate) {
30
            $schema = (new SchemaFinder)->find($candidate);
31
 
32
            if (!(new Validator)->validate($document, $schema)->hasValidationErrors()) {
33
                return new SuccessfulSchemaDetectionResult($candidate);
34
            }
35
        }
36
 
37
        return new FailedSchemaDetectionResult;
38
    }
39
}