1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace LTDBeget\sphinx\configurator; |
6
|
|
|
|
7
|
|
|
use LTDBeget\sphinx\configurator\deserializers\ArrayDeserializer; |
8
|
|
|
use LTDBeget\sphinx\configurator\deserializers\JsonDeserializer; |
9
|
|
|
use LTDBeget\sphinx\configurator\deserializers\PlainDeserializer; |
10
|
|
|
use LTDBeget\sphinx\enums\eVersion; |
11
|
|
|
|
12
|
|
|
class ConfigurationFactory |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @param string $plainData |
16
|
|
|
* @param eVersion $version |
17
|
|
|
* |
18
|
|
|
* @return Configuration |
19
|
|
|
* @throws \Hoa\Ustring\Exception |
20
|
|
|
* @throws \LTDBeget\sphinx\configurator\exceptions\SectionException |
21
|
|
|
* @throws \LogicException |
22
|
|
|
* @throws \InvalidArgumentException |
23
|
|
|
* @throws \LTDBeget\sphinx\configurator\exceptions\ConfigurationException |
24
|
|
|
* @throws \LTDBeget\sphinx\configurator\exceptions\DeserializeException |
25
|
|
|
* @throws \LTDBeget\sphinx\SyntaxErrorException |
26
|
|
|
* @throws \BadMethodCallException |
27
|
|
|
* @throws \LTDBeget\sphinx\informer\exceptions\DocumentationSourceException |
28
|
|
|
* @throws \Symfony\Component\Yaml\Exception\ParseException |
29
|
|
|
*/ |
30
|
10 |
|
public static function fromString(string $plainData, eVersion $version): Configuration |
31
|
|
|
{ |
32
|
10 |
|
return PlainDeserializer::deserialize($plainData, new Configuration($version)); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @param array $plainData |
37
|
|
|
* @param eVersion $version |
38
|
|
|
* |
39
|
|
|
* @return Configuration |
40
|
|
|
* @throws \LTDBeget\sphinx\configurator\exceptions\SectionException |
41
|
|
|
* @throws \LogicException |
42
|
|
|
* @throws \InvalidArgumentException |
43
|
|
|
* @throws \BadMethodCallException |
44
|
|
|
* @throws \LTDBeget\sphinx\configurator\exceptions\ConfigurationException |
45
|
|
|
* @throws \LTDBeget\sphinx\configurator\exceptions\DeserializeException |
46
|
|
|
* @throws \Symfony\Component\Yaml\Exception\ParseException |
47
|
|
|
* @throws \LTDBeget\sphinx\informer\exceptions\DocumentationSourceException |
48
|
|
|
*/ |
49
|
1 |
|
public static function fromArray(array $plainData, eVersion $version): Configuration |
50
|
|
|
{ |
51
|
1 |
|
return ArrayDeserializer::deserialize($plainData, new Configuration($version)); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @param string $plainData |
56
|
|
|
* @param eVersion $version |
57
|
|
|
* |
58
|
|
|
* @return Configuration |
59
|
|
|
* @throws \LTDBeget\sphinx\configurator\exceptions\SectionException |
60
|
|
|
* @throws \LogicException |
61
|
|
|
* @throws \InvalidArgumentException |
62
|
|
|
* @throws \BadMethodCallException |
63
|
|
|
* @throws \LTDBeget\sphinx\configurator\exceptions\ConfigurationException |
64
|
|
|
* @throws \LTDBeget\sphinx\configurator\exceptions\DeserializeException |
65
|
|
|
* @throws \LTDBeget\sphinx\informer\exceptions\DocumentationSourceException |
66
|
|
|
* @throws \Symfony\Component\Yaml\Exception\ParseException |
67
|
|
|
*/ |
68
|
1 |
|
public static function fromJson(string $plainData, eVersion $version): Configuration |
69
|
|
|
{ |
70
|
1 |
|
return JsonDeserializer::deserialize($plainData, new Configuration($version)); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|