-
Notifications
You must be signed in to change notification settings - Fork 45
/
Specifications.php
51 lines (40 loc) · 1.45 KB
/
Specifications.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
declare(strict_types=1);
namespace CfdiUtils\Development\ElementsMaker;
final class Specifications
{
/** @var Structure */
private $structure;
/** @var Dictionary */
private $dictionary;
public function __construct(Structure $structure, Dictionary $dictionary)
{
$this->structure = $structure;
$this->dictionary = $dictionary;
}
public static function makeFromFile(string $specFile): self
{
$specFileReader = SpecificationsReader::fromFile($specFile);
$structure = Structure::makeFromStdClass(
$specFileReader->keyAsString('root-element'),
$specFileReader->keyAsStdClass('structure')
);
$dictionary = new Dictionary([
'#php-namespace#' => $specFileReader->keyAsString('php-namespace'),
'#prefix#' => $specFileReader->keyAsString('prefix'),
'#xml-namespace#' => $specFileReader->keyAsString('xml-namespace'),
'#xml-schemalocation#' => $specFileReader->keyAsString('xml-schemalocation'),
'#version-attribute#' => $specFileReader->keyAsString('version-attribute'),
'#version-value#' => $specFileReader->keyAsString('version-value'),
]);
return new self($structure, $dictionary);
}
public function getStructure(): Structure
{
return $this->structure;
}
public function getDictionary(): Dictionary
{
return $this->dictionary;
}
}