@@ -20,7 +20,14 @@ enum_entry,
2020 uuid_entry ,
2121 xml_element_entry ,
2222 xml_entry };
23- use function Flow \Types \DSL \{type_date , type_datetime , type_json , type_optional , type_string , type_time , type_uuid , type_xml , type_xml_element };
23+ use function Flow \Types \DSL \{
24+ type_html ,
25+ type_json ,
26+ type_optional ,
27+ type_string ,
28+ type_uuid ,
29+ type_xml
30+ };
2431use Flow \ETL \Exception \{InvalidArgumentException ,
2532 RuntimeException ,
2633 SchemaDefinitionNotFoundException };
@@ -54,7 +61,6 @@ enum_entry,
5461};
5562use Flow \Types \Type \Native \String \StringTypeChecker ;
5663use Flow \Types \Type \TypeDetector ;
57- use Flow \Types \Value \Uuid ;
5864
5965final readonly class EntryFactory
6066{
@@ -91,41 +97,15 @@ public function create(string $entryName, mixed $value, Schema|Definition|null $
9197
9298 if ($ stringChecker ->isJson ()) {
9399 $ valueType = type_json ();
94- }
95-
96- if ($ stringChecker ->isUuid ()) {
100+ } elseif ($ stringChecker ->isUuid ()) {
97101 $ valueType = type_uuid ();
98- }
99-
100- if ($ stringChecker ->isXML ()) {
102+ } elseif ( $ stringChecker -> isHTML ()) {
103+ $ valueType = type_html ();
104+ } elseif ($ stringChecker ->isXML ()) {
101105 $ valueType = type_xml ();
102106 }
103107 }
104108
105- if ($ valueType instanceof InstanceOfType) {
106- if ($ valueType ->class === \DOMDocument::class) {
107- $ valueType = type_xml ();
108- } elseif ($ valueType ->class === \DOMElement::class) {
109- $ valueType = type_xml_element ();
110- } elseif ($ valueType ->class === \DateInterval::class) {
111- $ valueType = type_time ();
112- } elseif (\in_array ($ valueType ->class , [\DateTimeImmutable::class, \DateTimeInterface::class, \DateTime::class], true )) {
113- if ($ value instanceof \DateTimeInterface && $ value ->format ('H:i:s ' ) === '00:00:00 ' ) {
114- $ valueType = type_date ();
115- } else {
116- $ valueType = type_datetime ();
117- }
118- } else {
119- foreach (['Ramsey\Uuid\UuidInterface ' , Uuid::class, 'Symfony\Component\Uid\Uuid ' ] as $ uuidClass ) {
120- if (\is_a ($ valueType ->class , $ uuidClass , true )) {
121- $ valueType = type_uuid ();
122-
123- break ;
124- }
125- }
126- }
127- }
128-
129109 return $ this ->createAs ($ entryName , $ value , $ valueType );
130110 }
131111
0 commit comments