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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
<?php
namespace GeniBase\Storager;
use Gedcomx\Agent\Agent;
use Gedcomx\Conclusion\Conclusion;
use Gedcomx\Conclusion\DateInfo;
use Gedcomx\Conclusion\Event;
use Gedcomx\Conclusion\EventRole;
use Gedcomx\Conclusion\Fact;
use Gedcomx\Conclusion\Gender;
use Gedcomx\Conclusion\Identifier;
use Gedcomx\Conclusion\Name;
use Gedcomx\Conclusion\NameForm;
use Gedcomx\Conclusion\NamePart;
use Gedcomx\Conclusion\Person;
use Gedcomx\Conclusion\PlaceDescription;
use Gedcomx\Source\SourceDescription;
use Gedcomx\Source\SourceReference;
use GeniBase\DBase\DBaseService;
class StoragerFactory
{
public static function newStorager(DBaseService $dbs, $class)
{
if (is_object($class)) {
$class = get_class($class);
}
switch ($class) {
case Conclusion::class:
return new ConclusionStorager($dbs);
case SourceDescription::class:
return new SourceDescriptionStorager($dbs);
case SourceReference::class:
return new SourceReferenceStorager($dbs);
case DateInfo::class:
return new DateInfoStorager($dbs);
case Name::class:
return new NameStorager($dbs);
case NameForm::class:
return new NameFormStorager($dbs);
case NamePart::class:
return new NamePartStorager($dbs);
case Person::class:
return new PersonStorager($dbs);
case Gender::class:
return new GenderStorager($dbs);
case PlaceDescription::class:
return new PlaceDescriptionStorager($dbs);
case Fact::class:
return new FactStorager($dbs);
case Event::class:
return new EventStorager($dbs);
case EventRole::class:
return new EventRoleStorager($dbs);
case Agent::class:
return new AgentStorager($dbs);
case Identifier::class:
return new IdentifierStorager($dbs);
}
throw new \UnexpectedValueException('Not supported class: ' . $class);
}
}