@@ -245,7 +245,7 @@ public static function delete(InputInterface $input, string $field, int $solrCor
245245 public static function getIndexFieldName (string $ indexName , int $ pid = 0 ): string
246246 {
247247 // Sanitize input.
248- $ pid = max (( int ) $ pid , 0 );
248+ $ pid = max ($ pid , 0 );
249249 if (!$ pid ) {
250250 Helper::error ('Invalid PID ' . $ pid . ' for metadata configuration ' );
251251 return '' ;
@@ -372,7 +372,7 @@ protected static function processLogical(Document $document, array $logicalUnit)
372372 $ solrDoc ->setField ('title ' , $ metadata ['title ' ][0 ]);
373373 $ solrDoc ->setField ('volume ' , $ metadata ['volume ' ][0 ] ?? '' );
374374 // verify date formatting
375- if (strtotime ($ metadata ['date ' ][0 ])) {
375+ if (strtotime ($ metadata ['date ' ][0 ])) {
376376 $ solrDoc ->setField ('date ' , self ::getFormattedDate ($ metadata ['date ' ][0 ]));
377377 }
378378 $ solrDoc ->setField ('record_id ' , $ metadata ['record_id ' ][0 ] ?? '' );
@@ -530,7 +530,7 @@ private static function processMetadata(Document $document, array $metadata, Que
530530 // TODO: Include also subentries if available.
531531 if (
532532 !empty ($ data )
533- && substr ($ indexName , - 8 ) !== '_sorting '
533+ && ! str_ends_with ($ indexName , '_sorting ' )
534534 ) {
535535 $ solrDoc ->setField (self ::getIndexFieldName ($ indexName , $ document ->getPid ()), $ data );
536536 if (in_array ($ indexName , self ::$ fields ['sortables ' ]) &&
@@ -575,7 +575,7 @@ private static function addFaceting($doc, QueryDocument &$solrDoc, array $physic
575575 foreach ($ doc ->metadataArray [$ logicalId ] as $ indexName => $ data ) {
576576 if (
577577 !empty ($ data )
578- && substr ($ indexName , - 8 ) !== '_sorting '
578+ && ! str_ends_with ($ indexName , '_sorting ' )
579579 ) {
580580 if (in_array ($ indexName , self ::$ fields ['facets ' ])) {
581581 // Remove appended "valueURI" from authors' names for indexing.
@@ -609,7 +609,7 @@ private static function addFaceting($doc, QueryDocument &$solrDoc, array $physic
609609 // Add sorting information to physical sub-elements if applicable.
610610 if (
611611 !empty ($ data )
612- && substr ($ indexName , - 8 ) == '_sorting '
612+ && str_ends_with ($ indexName , '_sorting ' )
613613 ) {
614614 $ solrDoc ->setField ($ indexName , $ doc ->metadataArray [$ doc ->getToplevelId ()][$ indexName ]);
615615 }
@@ -689,16 +689,16 @@ private static function getSolrDocument(Query $updateQuery, Document $document,
689689 private static function getFormattedDate (string $ date ): string
690690 {
691691 if (
692- preg_match ("/^[\d] {4}$/ " , $ date )
693- || preg_match ("/^[\d] {4}-[\d] {2}$/ " , $ date )
694- || preg_match ("/^[\d] {4}-[\d] {2}-[\d] {2}$/ " , $ date )
692+ preg_match ("/^\d {4}$/ " , $ date )
693+ || preg_match ("/^\d {4}-\d {2}$/ " , $ date )
694+ || preg_match ("/^\d {4}-\d {2}-\d {2}$/ " , $ date )
695695 ) {
696696 return $ date ;
697- // change date YYYYMMDD to YYYY-MM-DD
698- } elseif ( preg_match ( " /^[\d]{8}$/ " , $ date)) {
697+ } elseif ( preg_match ( " /^\d{8}$/ " , $ date)) {
698+ // change date YYYYMMDD to YYYY-MM-DD
699699 return date ("Y-m-d " , strtotime ($ date ));
700- // convert any datetime to proper ISO extended datetime format and timezone for SOLR
701700 } elseif (preg_match ("/^[0-9]{4}-[0-9]{2}-[0-9]{2}T.*$/ " , $ date )) {
701+ // convert any datetime to proper ISO extended datetime format and timezone for SOLR
702702 return date ('Y-m-d\TH:i:s\Z ' , strtotime ($ date ));
703703 }
704704 // date doesn't match any standard
0 commit comments