ILIAS  release_8 Revision v8.24
SerializerFactory.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
21
22use InvalidArgumentException;
23
29{
32
33 public function core(): CoreSerializer
34 {
35 if (!isset(self::$core_instance)) {
36 self::$core_instance = new CoreSerializer();
37 }
38
40 }
41
42 public function plugin(): PluginSerializer
43 {
44 if (!isset(self::$plugin_instance)) {
45 self::$plugin_instance = new PluginSerializer();
46 }
47
49 }
50
55 public function fromSerializedIdentification(string $serialized_identification): SerializerInterface
56 {
57 $plugin = $this->plugin();
58 if ($plugin->canHandle($serialized_identification)) {
59 return $plugin;
60 }
61
62 $core = $this->core();
63 if ($core->canHandle($serialized_identification)) {
64 return $core;
65 }
66
67 throw new InvalidArgumentException("Nobody can handle serialized identification '$serialized_identification'.");
68 }
69}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...