@@ -19,11 +19,6 @@ public function __construct(XmlScanner $securityScanner, DocumentProperties $doc
19
19
$ this ->docProps = $ docProps ;
20
20
}
21
21
22
- private static function nullOrSimple (mixed $ obj ): ?SimpleXMLElement
23
- {
24
- return ($ obj instanceof SimpleXMLElement) ? $ obj : null ;
25
- }
26
-
27
22
private function extractPropertyData (string $ propertyData ): ?SimpleXMLElement
28
23
{
29
24
// okay to omit namespace because everything will be processed by xpath
@@ -33,7 +28,7 @@ private function extractPropertyData(string $propertyData): ?SimpleXMLElement
33
28
Settings::getLibXmlLoaderOptions ()
34
29
);
35
30
36
- return self :: nullOrSimple ( $ obj) ;
31
+ return $ obj === false ? null : $ obj ;
37
32
}
38
33
39
34
public function readCoreProperties (string $ propertyData ): void
@@ -45,15 +40,15 @@ public function readCoreProperties(string $propertyData): void
45
40
$ xmlCore ->registerXPathNamespace ('dcterms ' , Namespaces::DC_TERMS );
46
41
$ xmlCore ->registerXPathNamespace ('cp ' , Namespaces::CORE_PROPERTIES2 );
47
42
48
- $ this ->docProps ->setCreator (( string ) self :: getArrayItem ($ xmlCore ->xpath ('dc:creator ' )));
49
- $ this ->docProps ->setLastModifiedBy (( string ) self :: getArrayItem ($ xmlCore ->xpath ('cp:lastModifiedBy ' )));
50
- $ this ->docProps ->setCreated (( string ) self :: getArrayItem ($ xmlCore ->xpath ('dcterms:created ' ))); //! respect xsi:type
51
- $ this ->docProps ->setModified (( string ) self :: getArrayItem ($ xmlCore ->xpath ('dcterms:modified ' ))); //! respect xsi:type
52
- $ this ->docProps ->setTitle (( string ) self :: getArrayItem ($ xmlCore ->xpath ('dc:title ' )));
53
- $ this ->docProps ->setDescription (( string ) self :: getArrayItem ($ xmlCore ->xpath ('dc:description ' )));
54
- $ this ->docProps ->setSubject (( string ) self :: getArrayItem ($ xmlCore ->xpath ('dc:subject ' )));
55
- $ this ->docProps ->setKeywords (( string ) self :: getArrayItem ($ xmlCore ->xpath ('cp:keywords ' )));
56
- $ this ->docProps ->setCategory (( string ) self :: getArrayItem ($ xmlCore ->xpath ('cp:category ' )));
43
+ $ this ->docProps ->setCreator ($ this -> getArrayItem ($ xmlCore ->xpath ('dc:creator ' )));
44
+ $ this ->docProps ->setLastModifiedBy ($ this -> getArrayItem ($ xmlCore ->xpath ('cp:lastModifiedBy ' )));
45
+ $ this ->docProps ->setCreated ($ this -> getArrayItem ($ xmlCore ->xpath ('dcterms:created ' ))); //! respect xsi:type
46
+ $ this ->docProps ->setModified ($ this -> getArrayItem ($ xmlCore ->xpath ('dcterms:modified ' ))); //! respect xsi:type
47
+ $ this ->docProps ->setTitle ($ this -> getArrayItem ($ xmlCore ->xpath ('dc:title ' )));
48
+ $ this ->docProps ->setDescription ($ this -> getArrayItem ($ xmlCore ->xpath ('dc:description ' )));
49
+ $ this ->docProps ->setSubject ($ this -> getArrayItem ($ xmlCore ->xpath ('dc:subject ' )));
50
+ $ this ->docProps ->setKeywords ($ this -> getArrayItem ($ xmlCore ->xpath ('cp:keywords ' )));
51
+ $ this ->docProps ->setCategory ($ this -> getArrayItem ($ xmlCore ->xpath ('cp:category ' )));
57
52
}
58
53
}
59
54
@@ -96,8 +91,8 @@ public function readCustomProperties(string $propertyData): void
96
91
}
97
92
}
98
93
99
- private static function getArrayItem (null |array |false $ array, mixed $ key = 0 ): ? SimpleXMLElement
94
+ private function getArrayItem (null |array |false $ array ): string
100
95
{
101
- return is_array ($ array ) ? ($ array [$ key ] ?? null ) : null ;
96
+ return is_array ($ array ) ? (string ) ( $ array [0 ] ?? '' ) : '' ;
102
97
}
103
98
}
0 commit comments