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 PharIo\Manifest.
4
 *
5
 * (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, 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 PharIo\Manifest;
11
 
12
class ManifestLoader {
13
    public static function fromFile(string $filename): Manifest {
14
        try {
15
            return (new ManifestDocumentMapper())->map(
16
                ManifestDocument::fromFile($filename)
17
            );
18
        } catch (Exception $e) {
19
            throw new ManifestLoaderException(
20
                \sprintf('Loading %s failed.', $filename),
21
                (int)$e->getCode(),
22
                $e
23
            );
24
        }
25
    }
26
 
27
    public static function fromPhar(string $filename): Manifest {
28
        return self::fromFile('phar://' . $filename . '/manifest.xml');
29
    }
30
 
31
    public static function fromString(string $manifest): Manifest {
32
        try {
33
            return (new ManifestDocumentMapper())->map(
34
                ManifestDocument::fromString($manifest)
35
            );
36
        } catch (Exception $e) {
37
            throw new ManifestLoaderException(
38
                'Processing string failed',
39
                (int)$e->getCode(),
40
                $e
41
            );
42
        }
43
    }
44
}