ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
SerializerFactory.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use InvalidArgumentException;
24
30{
33
34 public function core(): CoreSerializer
35 {
36 if (!isset(self::$core_instance)) {
37 self::$core_instance = new CoreSerializer();
38 }
39
41 }
42
43 public function plugin(): PluginSerializer
44 {
45 if (!isset(self::$plugin_instance)) {
46 self::$plugin_instance = new PluginSerializer();
47 }
48
50 }
51
56 public function fromSerializedIdentification(string $serialized_identification): SerializerInterface
57 {
58 $plugin = $this->plugin();
59 if ($plugin->canHandle($serialized_identification)) {
60 return $plugin;
61 }
62
63 $core = $this->core();
64 if ($core->canHandle($serialized_identification)) {
65 return $core;
66 }
67
68 throw new InvalidArgumentException("Nobody can handle serialized identification '$serialized_identification'.");
69 }
70}