Passed
Pull Request — master (#91)
by Alexander
02:40
created
Classes/Plugin/Eid/SearchInDocument.php 1 patch
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -28,16 +28,14 @@  discard block
 block discarded – undo
28 28
  * @subpackage dlf
29 29
  * @access public
30 30
  */
31
-class SearchInDocument
32
-{
31
+class SearchInDocument {
33 32
     /**
34 33
      * The main method of the eID script
35 34
      *
36 35
      * @param ServerRequestInterface $request
37 36
      * @return ResponseInterface JSON response of search suggestions
38 37
      */
39
-    public function main(ServerRequestInterface $request)
40
-    {
38
+    public function main(ServerRequestInterface $request) {
41 39
         $output = [
42 40
             'documents' => [],
43 41
             'numFound' => 0
@@ -118,8 +116,7 @@  discard block
 block discarded – undo
118 116
      *
119 117
      * @return string SOLR query
120 118
      */
121
-    private function getQuery($fields, $parameters)
122
-    {
119
+    private function getQuery($fields, $parameters) {
123 120
         return $fields['fulltext'] . ':(' . Solr::escapeQuery((string) $parameters['q']) . ') AND ' . $fields['uid'] . ':' . $this->getUid($parameters['uid']);
124 121
     }
125 122
 
@@ -133,8 +130,7 @@  discard block
 block discarded – undo
133 130
      *
134 131
      * @return int|string uid of the document
135 132
      */
136
-    private function getUid($uid)
137
-    {
133
+    private function getUid($uid) {
138 134
         return is_numeric($uid) ? intval($uid) : $uid;
139 135
     }
140 136
 }
Please login to merge, or discard this patch.
Classes/Common/DocumentList.php 1 patch
Braces   +32 added lines, -64 removed lines patch added patch discarded remove patch
@@ -104,8 +104,7 @@  discard block
 block discarded – undo
104 104
      *
105 105
      * @return void
106 106
      */
107
-    public function add(array $elements, $position = -1)
108
-    {
107
+    public function add(array $elements, $position = -1) {
109 108
         $position = MathUtility::forceIntegerInRange($position, 0, $this->count, $this->count);
110 109
         if (!empty($elements)) {
111 110
             array_splice($this->elements, $position, 0, $elements);
@@ -121,8 +120,7 @@  discard block
 block discarded – undo
121 120
      *
122 121
      * @return int The number of elements in the list
123 122
      */
124
-    public function count()
125
-    {
123
+    public function count() {
126 124
         return $this->count;
127 125
     }
128 126
 
@@ -134,8 +132,7 @@  discard block
 block discarded – undo
134 132
      *
135 133
      * @return array The current element
136 134
      */
137
-    public function current()
138
-    {
135
+    public function current() {
139 136
         if ($this->valid()) {
140 137
             return $this->getRecord($this->elements[$this->position]);
141 138
         } else {
@@ -153,8 +150,7 @@  discard block
 block discarded – undo
153 150
      *
154 151
      * @return mixed The element's full record
155 152
      */
156
-    protected function getRecord($element)
157
-    {
153
+    protected function getRecord($element) {
158 154
         if (
159 155
             is_array($element)
160 156
             && array_keys($element) == ['u', 'h', 's', 'p']
@@ -261,8 +257,7 @@  discard block
 block discarded – undo
261 257
      *
262 258
      * @return Result
263 259
      */
264
-    private function getSolrResult($record)
265
-    {
260
+    private function getSolrResult($record) {
266 261
         $fields = Solr::getFields();
267 262
 
268 263
         $query = $this->solr->service->createSelect();
@@ -334,8 +329,7 @@  discard block
 block discarded – undo
334 329
      *
335 330
      * @return array
336 331
      */
337
-    private function getSolrRecord($record, $result)
338
-    {
332
+    private function getSolrRecord($record, $result) {
339 333
         // If it is a fulltext search, fetch the highlighting results.
340 334
         if ($this->metadata['fulltextSearch']) {
341 335
             $data = $result->getData();
@@ -382,8 +376,7 @@  discard block
 block discarded – undo
382 376
      *
383 377
      * @return int The current position
384 378
      */
385
-    public function key()
386
-    {
379
+    public function key() {
387 380
         return $this->position;
388 381
     }
389 382
 
@@ -397,8 +390,7 @@  discard block
 block discarded – undo
397 390
      *
398 391
      * @return void
399 392
      */
400
-    public function move($position, $steps)
401
-    {
393
+    public function move($position, $steps) {
402 394
         $position = intval($position);
403 395
         // Check if list position is valid.
404 396
         if (
@@ -429,8 +421,7 @@  discard block
 block discarded – undo
429 421
      *
430 422
      * @return void
431 423
      */
432
-    public function moveUp($position)
433
-    {
424
+    public function moveUp($position) {
434 425
         $this->move($position, -1);
435 426
     }
436 427
 
@@ -443,8 +434,7 @@  discard block
 block discarded – undo
443 434
      *
444 435
      * @return void
445 436
      */
446
-    public function moveDown($position)
447
-    {
437
+    public function moveDown($position) {
448 438
         $this->move($position, 1);
449 439
     }
450 440
 
@@ -456,8 +446,7 @@  discard block
 block discarded – undo
456 446
      *
457 447
      * @return void
458 448
      */
459
-    public function next()
460
-    {
449
+    public function next() {
461 450
         $this->position++;
462 451
     }
463 452
 
@@ -471,8 +460,7 @@  discard block
 block discarded – undo
471 460
      *
472 461
      * @return bool Does the given offset exist?
473 462
      */
474
-    public function offsetExists($offset)
475
-    {
463
+    public function offsetExists($offset) {
476 464
         return isset($this->elements[$offset]);
477 465
     }
478 466
 
@@ -486,8 +474,7 @@  discard block
 block discarded – undo
486 474
      *
487 475
      * @return array The element at the given offset
488 476
      */
489
-    public function offsetGet($offset)
490
-    {
477
+    public function offsetGet($offset) {
491 478
         if ($this->offsetExists($offset)) {
492 479
             return $this->getRecord($this->elements[$offset]);
493 480
         } else {
@@ -507,8 +494,7 @@  discard block
 block discarded – undo
507 494
      *
508 495
      * @return void
509 496
      */
510
-    public function offsetSet($offset, $value)
511
-    {
497
+    public function offsetSet($offset, $value) {
512 498
         if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($offset)) {
513 499
             $this->elements[$offset] = $value;
514 500
         } else {
@@ -528,8 +514,7 @@  discard block
 block discarded – undo
528 514
      *
529 515
      * @return array The removed element
530 516
      */
531
-    public function remove($position)
532
-    {
517
+    public function remove($position) {
533 518
         $position = intval($position);
534 519
         if (
535 520
             $position < 0
@@ -553,8 +538,7 @@  discard block
 block discarded – undo
553 538
      *
554 539
      * @return array The indizes of the removed elements
555 540
      */
556
-    public function removeRange($position, $length)
557
-    {
541
+    public function removeRange($position, $length) {
558 542
         $position = intval($position);
559 543
         if (
560 544
             $position < 0
@@ -575,8 +559,7 @@  discard block
 block discarded – undo
575 559
      *
576 560
      * @return void
577 561
      */
578
-    public function reset()
579
-    {
562
+    public function reset() {
580 563
         $this->elements = [];
581 564
         $this->records = [];
582 565
         $this->metadata = [];
@@ -592,8 +575,7 @@  discard block
 block discarded – undo
592 575
      *
593 576
      * @return void
594 577
      */
595
-    public function rewind()
596
-    {
578
+    public function rewind() {
597 579
         $this->position = 0;
598 580
     }
599 581
 
@@ -606,8 +588,7 @@  discard block
 block discarded – undo
606 588
      *
607 589
      * @return void
608 590
      */
609
-    public function save($pid = 0)
610
-    {
591
+    public function save($pid = 0) {
611 592
         $pid = max(intval($pid), 0);
612 593
         // If no PID is given, save to the user's session instead
613 594
         if ($pid > 0) {
@@ -624,8 +605,7 @@  discard block
 block discarded – undo
624 605
      *
625 606
      * @return bool true on success or false on failure
626 607
      */
627
-    protected function solrConnect()
628
-    {
608
+    protected function solrConnect() {
629 609
         // Get Solr instance.
630 610
         if (!$this->solr) {
631 611
             // Connect to Solr server.
@@ -674,8 +654,7 @@  discard block
 block discarded – undo
674 654
      *
675 655
      * @return void
676 656
      */
677
-    public function sort($by, $asc = true)
678
-    {
657
+    public function sort($by, $asc = true) {
679 658
         $newOrder = [];
680 659
         $nonSortable = [];
681 660
         foreach ($this->elements as $num => $element) {
@@ -712,8 +691,7 @@  discard block
 block discarded – undo
712 691
      *
713 692
      * @return void
714 693
      */
715
-    public function offsetUnset($offset)
716
-    {
694
+    public function offsetUnset($offset) {
717 695
         unset($this->elements[$offset]);
718 696
         // Re-number the elements.
719 697
         $this->elements = array_values($this->elements);
@@ -728,8 +706,7 @@  discard block
 block discarded – undo
728 706
      *
729 707
      * @return bool Is the current list position valid?
730 708
      */
731
-    public function valid()
732
-    {
709
+    public function valid() {
733 710
         return isset($this->elements[$this->position]);
734 711
     }
735 712
 
@@ -740,8 +717,7 @@  discard block
 block discarded – undo
740 717
      *
741 718
      * @return array The list's metadata
742 719
      */
743
-    protected function _getMetadata()
744
-    {
720
+    protected function _getMetadata() {
745 721
         return $this->metadata;
746 722
     }
747 723
 
@@ -754,8 +730,7 @@  discard block
 block discarded – undo
754 730
      *
755 731
      * @return void
756 732
      */
757
-    protected function _setMetadata(array $metadata = [])
758
-    {
733
+    protected function _setMetadata(array $metadata = []) {
759 734
         $this->metadata = $metadata;
760 735
     }
761 736
 
@@ -769,8 +744,7 @@  discard block
 block discarded – undo
769 744
      *
770 745
      * @return void
771 746
      */
772
-    public function __construct(array $elements = [], array $metadata = [])
773
-    {
747
+    public function __construct(array $elements = [], array $metadata = []) {
774 748
         if (
775 749
             empty($elements)
776 750
             && empty($metadata)
@@ -803,8 +777,7 @@  discard block
 block discarded – undo
803 777
      *
804 778
      * @return void
805 779
      */
806
-    protected function __clone()
807
-    {
780
+    protected function __clone() {
808 781
         // This method is defined as protected because singleton objects should not be cloned.
809 782
     }
810 783
 
@@ -817,8 +790,7 @@  discard block
 block discarded – undo
817 790
      *
818 791
      * @return mixed Value of $this->$var
819 792
      */
820
-    public function __get($var)
821
-    {
793
+    public function __get($var) {
822 794
         $method = '_get' . ucfirst($var);
823 795
         if (
824 796
             !property_exists($this, $var)
@@ -840,8 +812,7 @@  discard block
 block discarded – undo
840 812
      *
841 813
      * @return bool true if variable is set and not empty, false otherwise
842 814
      */
843
-    public function __isset($var)
844
-    {
815
+    public function __isset($var) {
845 816
         return !empty($this->__get($var));
846 817
     }
847 818
 
@@ -855,8 +826,7 @@  discard block
 block discarded – undo
855 826
      *
856 827
      * @return void
857 828
      */
858
-    public function __set($var, $value)
859
-    {
829
+    public function __set($var, $value) {
860 830
         $method = '_set' . ucfirst($var);
861 831
         if (
862 832
             !property_exists($this, $var)
@@ -876,8 +846,7 @@  discard block
 block discarded – undo
876 846
      *
877 847
      * @return array Properties to be serialized
878 848
      */
879
-    public function __sleep()
880
-    {
849
+    public function __sleep() {
881 850
         return ['elements', 'metadata'];
882 851
     }
883 852
 
@@ -889,8 +858,7 @@  discard block
 block discarded – undo
889 858
      *
890 859
      * @return void
891 860
      */
892
-    public function __wakeup()
893
-    {
861
+    public function __wakeup() {
894 862
         $this->count = count($this->elements);
895 863
     }
896 864
 }
Please login to merge, or discard this patch.
Classes/Common/IiifManifest.php 1 patch
Braces   +28 added lines, -56 removed lines patch added patch discarded remove patch
@@ -56,8 +56,7 @@  discard block
 block discarded – undo
56 56
  * @property-read string $toplevelId This holds the toplevel manifest's @id
57 57
  * @property-read mixed $uid This holds the UID or the URL of the document
58 58
  */
59
-final class IiifManifest extends Document
60
-{
59
+final class IiifManifest extends Document {
61 60
     /**
62 61
      * This holds the manifest file as string for serialization purposes
63 62
      * @see __sleep() / __wakeup()
@@ -118,8 +117,7 @@  discard block
 block discarded – undo
118 117
      * {@inheritDoc}
119 118
      * @see Document::establishRecordId()
120 119
      */
121
-    protected function establishRecordId($pid)
122
-    {
120
+    protected function establishRecordId($pid) {
123 121
         if ($this->iiif !== null) {
124 122
             /*
125 123
              *  FIXME This will not consistently work because we can not be sure to have the pid at hand. It may miss
@@ -170,8 +168,7 @@  discard block
 block discarded – undo
170 168
      * {@inheritDoc}
171 169
      * @see Document::getDocument()
172 170
      */
173
-    protected function getDocument()
174
-    {
171
+    protected function getDocument() {
175 172
         return $this->iiif;
176 173
     }
177 174
 
@@ -184,8 +181,7 @@  discard block
 block discarded – undo
184 181
      * @return string 'IIIF1' if the resource is a Metadata API 1 resource, 'IIIF2' / 'IIIF3' if
185 182
      * the resource is a Presentation API 2 / 3 resource
186 183
      */
187
-    public function getIiifVersion()
188
-    {
184
+    public function getIiifVersion() {
189 185
         if (!isset($this->iiifVersion)) {
190 186
             if ($this->iiif instanceof AbstractIiifResource1) {
191 187
                 $this->iiifVersion = 'IIIF1';
@@ -226,8 +222,7 @@  discard block
 block discarded – undo
226 222
      *
227 223
      * @return array|string
228 224
      */
229
-    protected function getUseGroups($use)
230
-    {
225
+    protected function getUseGroups($use) {
231 226
         if (!$this->useGrpsLoaded) {
232 227
             // Get configured USE attributes.
233 228
             $extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey);
@@ -255,8 +250,7 @@  discard block
 block discarded – undo
255 250
      * {@inheritDoc}
256 251
      * @see Document::_getPhysicalStructure()
257 252
      */
258
-    protected function _getPhysicalStructure()
259
-    {
253
+    protected function _getPhysicalStructure() {
260 254
         // Is there no physical structure array yet?
261 255
         if (!$this->physicalStructureLoaded) {
262 256
             if ($this->iiif == null || !($this->iiif instanceof ManifestInterface)) {
@@ -369,8 +363,7 @@  discard block
 block discarded – undo
369 363
      * {@inheritDoc}
370 364
      * @see Document::getDownloadLocation()
371 365
      */
372
-    public function getDownloadLocation($id)
373
-    {
366
+    public function getDownloadLocation($id) {
374 367
         $fileLocation = $this->getFileLocation($id);
375 368
         $resource = $this->iiif->getContainedResourceById($fileLocation);
376 369
         if ($resource instanceof AbstractImageService) {
@@ -383,8 +376,7 @@  discard block
 block discarded – undo
383 376
      * {@inheritDoc}
384 377
      * @see Document::getFileLocation()
385 378
      */
386
-    public function getFileLocation($id)
387
-    {
379
+    public function getFileLocation($id) {
388 380
         if ($id == null) {
389 381
             return null;
390 382
         }
@@ -408,8 +400,7 @@  discard block
 block discarded – undo
408 400
      * {@inheritDoc}
409 401
      * @see Document::getFileMimeType()
410 402
      */
411
-    public function getFileMimeType($id)
412
-    {
403
+    public function getFileMimeType($id) {
413 404
         $fileResource = $this->iiif->getContainedResourceById($id);
414 405
         if ($fileResource instanceof CanvasInterface) {
415 406
             $format = "application/vnd.kitodo.iiif";
@@ -434,8 +425,7 @@  discard block
 block discarded – undo
434 425
      * {@inheritDoc}
435 426
      * @see Document::getLogicalStructure()
436 427
      */
437
-    public function getLogicalStructure($id, $recursive = false)
438
-    {
428
+    public function getLogicalStructure($id, $recursive = false) {
439 429
         $details = [];
440 430
         if (!$recursive && !empty($this->logicalUnits[$id])) {
441 431
             return $this->logicalUnits[$id];
@@ -470,8 +460,7 @@  discard block
 block discarded – undo
470 460
      * @param array $processedStructures: IIIF resources that already have been processed
471 461
      * @return array Logical structure array
472 462
      */
473
-    protected function getLogicalStructureInfo(IiifResourceInterface $resource, $recursive = false, &$processedStructures = [])
474
-    {
463
+    protected function getLogicalStructureInfo(IiifResourceInterface $resource, $recursive = false, &$processedStructures = []) {
475 464
         $details = [];
476 465
         $details['id'] = $resource->getId();
477 466
         $details['dmdId'] = '';
@@ -563,8 +552,7 @@  discard block
 block discarded – undo
563 552
      *
564 553
      * @todo This method is still in experimental; the method signature may change.
565 554
      */
566
-    public function getManifestMetadata($id, $cPid = 0, $withDescription = true, $withRights = true, $withRelated = true)
567
-    {
555
+    public function getManifestMetadata($id, $cPid = 0, $withDescription = true, $withRights = true, $withRelated = true) {
568 556
         if (!empty($this->originalMetadataArray[$id])) {
569 557
             return $this->originalMetadataArray[$id];
570 558
         }
@@ -606,8 +594,7 @@  discard block
 block discarded – undo
606 594
      * {@inheritDoc}
607 595
      * @see Document::getMetadata()
608 596
      */
609
-    public function getMetadata($id, $cPid = 0)
610
-    {
597
+    public function getMetadata($id, $cPid = 0) {
611 598
         if (!empty($this->metadataArray[$id]) && $this->metadataArray[0] == $cPid) {
612 599
             return $this->metadataArray[$id];
613 600
         }
@@ -714,8 +701,7 @@  discard block
 block discarded – undo
714 701
      * {@inheritDoc}
715 702
      * @see Document::_getSmLinks()
716 703
      */
717
-    protected function _getSmLinks()
718
-    {
704
+    protected function _getSmLinks() {
719 705
         if (!$this->smLinksLoaded && isset($this->iiif) && $this->iiif instanceof ManifestInterface) {
720 706
             if (!empty($this->iiif->getDefaultCanvases())) {
721 707
                 foreach ($this->iiif->getDefaultCanvases() as $canvas) {
@@ -739,8 +725,7 @@  discard block
 block discarded – undo
739 725
      *
740 726
      * @param RangeInterface $range: Current range whose canvases shall be linked
741 727
      */
742
-    private function smLinkRangeCanvasesRecursively(RangeInterface $range)
743
-    {
728
+    private function smLinkRangeCanvasesRecursively(RangeInterface $range) {
744 729
         // map range's canvases including all child ranges' canvases
745 730
         if (!$range->isTopRange()) {
746 731
             foreach ($range->getAllCanvasesRecursively() as $canvas) {
@@ -763,8 +748,7 @@  discard block
 block discarded – undo
763 748
      * @param CanvasInterface $canvas
764 749
      * @param IiifResourceInterface $resource
765 750
      */
766
-    private function smLinkCanvasToResource(CanvasInterface $canvas, IiifResourceInterface $resource)
767
-    {
751
+    private function smLinkCanvasToResource(CanvasInterface $canvas, IiifResourceInterface $resource) {
768 752
         $this->smLinks['l2p'][$resource->getId()][] = $canvas->getId();
769 753
         if (!is_array($this->smLinks['p2l'][$canvas->getId()]) || !in_array($resource->getId(), $this->smLinks['p2l'][$canvas->getId()])) {
770 754
             $this->smLinks['p2l'][$canvas->getId()][] = $resource->getId();
@@ -779,8 +763,7 @@  discard block
 block discarded – undo
779 763
      *
780 764
      * @see Document::getParentDocumentUidForSaving()
781 765
      */
782
-    protected function getParentDocumentUidForSaving($pid, $core, $owner)
783
-    {
766
+    protected function getParentDocumentUidForSaving($pid, $core, $owner) {
784 767
         // Do nothing.
785 768
     }
786 769
 
@@ -789,8 +772,7 @@  discard block
 block discarded – undo
789 772
      * @see Document::getFullText()
790 773
      */
791 774
     //TODO: rewrite it to get full OCR
792
-    public function getFullText($id)
793
-    {
775
+    public function getFullText($id) {
794 776
         $rawText = '';
795 777
         // Get text from raw text array if available.
796 778
         if (!empty($this->rawTextArray[$id])) {
@@ -847,8 +829,7 @@  discard block
 block discarded – undo
847 829
      *
848 830
      * @return IiifResourceInterface
849 831
      */
850
-    public function getIiif()
851
-    {
832
+    public function getIiif() {
852 833
         return $this->iiif;
853 834
     }
854 835
 
@@ -856,8 +837,7 @@  discard block
 block discarded – undo
856 837
      * {@inheritDoc}
857 838
      * @see Document::init()
858 839
      */
859
-    protected function init()
860
-    {
840
+    protected function init() {
861 841
         // Nothing to do here, at the moment
862 842
     }
863 843
 
@@ -865,8 +845,7 @@  discard block
 block discarded – undo
865 845
      * {@inheritDoc}
866 846
      * @see Document::loadLocation()
867 847
      */
868
-    protected function loadLocation($location)
869
-    {
848
+    protected function loadLocation($location) {
870 849
         $fileResource = GeneralUtility::getUrl($location);
871 850
         if ($fileResource !== false) {
872 851
             $conf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey);
@@ -889,8 +868,7 @@  discard block
 block discarded – undo
889 868
      * {@inheritDoc}
890 869
      * @see \Kitodo\Dlf\Common\Document::prepareMetadataArray()
891 870
      */
892
-    protected function prepareMetadataArray($cPid)
893
-    {
871
+    protected function prepareMetadataArray($cPid) {
894 872
         $id = $this->iiif->getId();
895 873
         $this->metadataArray[(string) $id] = $this->getMetadata((string) $id, $cPid);
896 874
     }
@@ -899,8 +877,7 @@  discard block
 block discarded – undo
899 877
      * {@inheritDoc}
900 878
      * @see Document::setPreloadedDocument()
901 879
      */
902
-    protected function setPreloadedDocument($preloadedDocument)
903
-    {
880
+    protected function setPreloadedDocument($preloadedDocument) {
904 881
         if ($preloadedDocument instanceof ManifestInterface) {
905 882
             $this->iiif = $preloadedDocument;
906 883
             return true;
@@ -912,8 +889,7 @@  discard block
 block discarded – undo
912 889
      * {@inheritDoc}
913 890
      * @see Document::ensureHasFulltextIsSet()
914 891
      */
915
-    protected function ensureHasFulltextIsSet()
916
-    {
892
+    protected function ensureHasFulltextIsSet() {
917 893
         /*
918 894
          *  TODO Check annotations and annotation lists of canvas for ALTO documents.
919 895
          *  Example:
@@ -959,8 +935,7 @@  discard block
 block discarded – undo
959 935
      * {@inheritDoc}
960 936
      * @see \Kitodo\Dlf\Common\Document::_getThumbnail()
961 937
      */
962
-    protected function _getThumbnail($forceReload = false)
963
-    {
938
+    protected function _getThumbnail($forceReload = false) {
964 939
         return $this->iiif->getThumbnailUrl();
965 940
     }
966 941
 
@@ -968,8 +943,7 @@  discard block
 block discarded – undo
968 943
      * {@inheritDoc}
969 944
      * @see \Kitodo\Dlf\Common\Document::_getToplevelId()
970 945
      */
971
-    protected function _getToplevelId()
972
-    {
946
+    protected function _getToplevelId() {
973 947
         if (empty($this->toplevelId)) {
974 948
             if (isset($this->iiif)) {
975 949
                 $this->toplevelId = $this->iiif->getId();
@@ -986,8 +960,7 @@  discard block
 block discarded – undo
986 960
      *
987 961
      * @return void
988 962
      */
989
-    public function __wakeup()
990
-    {
963
+    public function __wakeup() {
991 964
         $conf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey);
992 965
         IiifHelper::setUrlReader(IiifUrlReader::getInstance());
993 966
         IiifHelper::setMaxThumbnailHeight($conf['iiifThumbnailHeight']);
@@ -1006,8 +979,7 @@  discard block
 block discarded – undo
1006 979
      *
1007 980
      * @return string[]
1008 981
      */
1009
-    public function __sleep()
1010
-    {
982
+    public function __sleep() {
1011 983
         // TODO implement serializiation in IIIF library
1012 984
         $jsonArray = $this->iiif->getOriginalJsonArray();
1013 985
         $this->asJson = json_encode($jsonArray);
Please login to merge, or discard this patch.
Classes/Common/SolrSearchResult/ResultDocument.php 1 patch
Braces   +15 added lines, -30 removed lines patch added patch discarded remove patch
@@ -24,8 +24,7 @@  discard block
 block discarded – undo
24 24
  * @subpackage dlf
25 25
  * @access public
26 26
  */
27
-class ResultDocument
28
-{
27
+class ResultDocument {
29 28
 
30 29
     /**
31 30
      * The identifier
@@ -102,8 +101,7 @@  discard block
 block discarded – undo
102 101
      *
103 102
      * @return void
104 103
      */
105
-    public function __construct($record, $highlighting, $fields)
106
-    {
104
+    public function __construct($record, $highlighting, $fields) {
107 105
         $this->id = $record[$fields['id']];
108 106
         $this->uid = $record[$fields['uid']];
109 107
         $this->page = $record[$fields['page']];
@@ -124,8 +122,7 @@  discard block
 block discarded – undo
124 122
      *
125 123
      * @return string The result's record identifier
126 124
      */
127
-    public function getId()
128
-    {
125
+    public function getId() {
129 126
         return $this->id;
130 127
     }
131 128
 
@@ -136,8 +133,7 @@  discard block
 block discarded – undo
136 133
      *
137 134
      * @return string|null The result's record unified identifier
138 135
      */
139
-    public function getUid()
140
-    {
136
+    public function getUid() {
141 137
         return $this->uid;
142 138
     }
143 139
 
@@ -148,8 +144,7 @@  discard block
 block discarded – undo
148 144
      *
149 145
      * @return int The result's record page
150 146
      */
151
-    public function getPage()
152
-    {
147
+    public function getPage() {
153 148
         return $this->page;
154 149
     }
155 150
 
@@ -160,8 +155,7 @@  discard block
 block discarded – undo
160 155
      *
161 156
      * @return string All result's record snippets imploded to one string
162 157
      */
163
-    public function getSnippets()
164
-    {
158
+    public function getSnippets() {
165 159
         return $this->snippets;
166 160
     }
167 161
 
@@ -172,8 +166,7 @@  discard block
 block discarded – undo
172 166
      *
173 167
      * @return array(Page) All result's pages which contain search phrase
174 168
      */
175
-    public function getPages()
176
-    {
169
+    public function getPages() {
177 170
         return $this->pages;
178 171
     }
179 172
 
@@ -184,8 +177,7 @@  discard block
 block discarded – undo
184 177
      *
185 178
      * @return array(Region) All result's regions which contain search phrase
186 179
      */
187
-    public function getRegions()
188
-    {
180
+    public function getRegions() {
189 181
         return $this->regions;
190 182
     }
191 183
 
@@ -196,8 +188,7 @@  discard block
 block discarded – undo
196 188
      *
197 189
      * @return array(Highlight) All result's highlights of search phrase
198 190
      */
199
-    public function getHighlights()
200
-    {
191
+    public function getHighlights() {
201 192
         return $this->highlights;
202 193
     }
203 194
 
@@ -208,8 +199,7 @@  discard block
 block discarded – undo
208 199
      *
209 200
      * @return array(string) All result's highlights of search phrase
210 201
      */
211
-    public function getHighlightsIds()
212
-    {
202
+    public function getHighlightsIds() {
213 203
         $highlightsIds = [];
214 204
         foreach ($this->highlights as $highlight) {
215 205
             array_push($highlightsIds, $highlight->getId());
@@ -225,8 +215,7 @@  discard block
 block discarded – undo
225 215
      *
226 216
      * @return void
227 217
      */
228
-    private function parseSnippets()
229
-    {
218
+    private function parseSnippets() {
230 219
         $snippetArray = $this->getArrayByIndex('text');
231 220
 
232 221
         $this->snippets = !empty($snippetArray) ? implode(' [...] ', $snippetArray) : '';
@@ -240,8 +229,7 @@  discard block
 block discarded – undo
240 229
      *
241 230
      * @return void
242 231
      */
243
-    private function parsePages()
244
-    {
232
+    private function parsePages() {
245 233
         $pageArray = $this->getArrayByIndex('pages');
246 234
 
247 235
         $i = 0;
@@ -261,8 +249,7 @@  discard block
 block discarded – undo
261 249
      *
262 250
      * @return void
263 251
      */
264
-    private function parseRegions()
265
-    {
252
+    private function parseRegions() {
266 253
         $regionArray = $this->getArrayByIndex('regions');
267 254
 
268 255
         $i = 0;
@@ -282,8 +269,7 @@  discard block
 block discarded – undo
282 269
      *
283 270
      * @return void
284 271
      */
285
-    private function parseHighlights()
286
-    {
272
+    private function parseHighlights() {
287 273
         $highlightArray = $this->getArrayByIndex('highlights');
288 274
 
289 275
         foreach ($highlightArray as $highlights) {
@@ -304,8 +290,7 @@  discard block
 block discarded – undo
304 290
      *
305 291
      * @return array
306 292
      */
307
-    private function getArrayByIndex($index)
308
-    {
293
+    private function getArrayByIndex($index) {
309 294
         $objectArray = [];
310 295
         foreach ($this->snippetsForRecord as $snippet) {
311 296
             if (!empty($snippet[$index])) {
Please login to merge, or discard this patch.
Classes/Common/SolrSearchResult/Highlight.php 1 patch
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -20,8 +20,7 @@  discard block
 block discarded – undo
20 20
  * @subpackage dlf
21 21
  * @access public
22 22
  */
23
-class Highlight
24
-{
23
+class Highlight {
25 24
 
26 25
     /**
27 26
      * The identifier in form 'w_h_x_y'
@@ -80,8 +79,7 @@  discard block
 block discarded – undo
80 79
      *
81 80
      * @return void
82 81
      */
83
-    public function __construct($highlight)
84
-    {
82
+    public function __construct($highlight) {
85 83
         $this->parentRegionId = $highlight['parentRegionIdx'];
86 84
         $this->xBeginPosition = $highlight['ulx'];
87 85
         $this->xEndPosition = $highlight['lrx'];
@@ -97,8 +95,7 @@  discard block
 block discarded – undo
97 95
      *
98 96
      * @return string The highlight's identifier
99 97
      */
100
-    public function getId()
101
-    {
98
+    public function getId() {
102 99
         return $this->id;
103 100
     }
104 101
 
@@ -109,8 +106,7 @@  discard block
 block discarded – undo
109 106
      *
110 107
      * @return int The highlight's horizontal beginning position
111 108
      */
112
-    public function getXBeginPosition()
113
-    {
109
+    public function getXBeginPosition() {
114 110
         return $this->xBeginPosition;
115 111
     }
116 112
 
@@ -121,8 +117,7 @@  discard block
 block discarded – undo
121 117
      *
122 118
      * @return int The highlight's horizontal ending position
123 119
      */
124
-    public function getXEndPosition()
125
-    {
120
+    public function getXEndPosition() {
126 121
         return $this->xEndPosition;
127 122
     }
128 123
 
@@ -133,8 +128,7 @@  discard block
 block discarded – undo
133 128
      *
134 129
      * @return int The highlight's vertical beginning position
135 130
      */
136
-    public function getYBeginPosition()
137
-    {
131
+    public function getYBeginPosition() {
138 132
         return $this->yBeginPosition;
139 133
     }
140 134
 
@@ -145,8 +139,7 @@  discard block
 block discarded – undo
145 139
      *
146 140
      * @return int The highlight's vertical ending position
147 141
      */
148
-    public function getYEndPosition()
149
-    {
142
+    public function getYEndPosition() {
150 143
         return $this->yEndPosition;
151 144
     }
152 145
 }
Please login to merge, or discard this patch.
Classes/Format/Alto.php 1 patch
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -22,8 +22,7 @@  discard block
 block discarded – undo
22 22
  * @subpackage dlf
23 23
  * @access public
24 24
  */
25
-class Alto implements \Kitodo\Dlf\Common\FulltextInterface
26
-{
25
+class Alto implements \Kitodo\Dlf\Common\FulltextInterface {
27 26
     /**
28 27
      * This extracts the fulltext data from ALTO XML
29 28
      *
@@ -33,8 +32,7 @@  discard block
 block discarded – undo
33 32
      *
34 33
      * @return string The raw unformatted fulltext
35 34
      */
36
-    public function getRawText(\SimpleXMLElement $xml)
37
-    {
35
+    public function getRawText(\SimpleXMLElement $xml) {
38 36
         $rawText = '';
39 37
         $xml->registerXPathNamespace('alto', 'http://www.loc.gov/standards/alto/ns-v2#');
40 38
         // Get all (presumed) words of the text.
@@ -54,8 +52,7 @@  discard block
 block discarded – undo
54 52
      *
55 53
      * @return string The unformatted fulltext in MiniOCR format
56 54
      */
57
-    public function getTextAsMiniOcr(\SimpleXMLElement $xml)
58
-    {
55
+    public function getTextAsMiniOcr(\SimpleXMLElement $xml) {
59 56
         $xml->registerXPathNamespace('alto', 'http://www.loc.gov/standards/alto/ns-v2#');
60 57
 
61 58
         // get all text blocks
@@ -99,8 +96,7 @@  discard block
 block discarded – undo
99 96
      *
100 97
      * @return string The parsed word extracted from attribute
101 98
      */
102
-    private function getWord($attributes)
103
-    {
99
+    private function getWord($attributes) {
104 100
         return htmlspecialchars((string) $attributes['CONTENT']) . ' ';
105 101
     }
106 102
 
@@ -113,8 +109,7 @@  discard block
 block discarded – undo
113 109
      *
114 110
      * @return string The parsed word coordinates extracted from attribute
115 111
      */
116
-    private function getCoordinates($attributes)
117
-    {
112
+    private function getCoordinates($attributes) {
118 113
         return (string) $attributes['HPOS'] . ' ' . (string) $attributes['VPOS'] . ' ' . (string) $attributes['WIDTH'] . ' ' . (string) $attributes['HEIGHT'];
119 114
     }
120 115
 }
Please login to merge, or discard this patch.
Classes/Common/MetsDocument.php 1 patch
Braces   +28 added lines, -56 removed lines patch added patch discarded remove patch
@@ -48,8 +48,7 @@  discard block
 block discarded – undo
48 48
  * @property-read string $toplevelId This holds the toplevel structure's @ID (METS) or the manifest's @id (IIIF)
49 49
  * @property-read mixed $uid This holds the UID or the URL of the document
50 50
  */
51
-final class MetsDocument extends Document
52
-{
51
+final class MetsDocument extends Document {
53 52
     /**
54 53
      * This holds the whole XML file as string for serialization purposes
55 54
      * @see __sleep() / __wakeup()
@@ -128,8 +127,7 @@  discard block
 block discarded – undo
128 127
      *
129 128
      * @return  void
130 129
      */
131
-    public function addMetadataFromMets(&$metadata, $id)
132
-    {
130
+    public function addMetadataFromMets(&$metadata, $id) {
133 131
         $details = $this->getLogicalStructure($id);
134 132
         if (!empty($details)) {
135 133
             $metadata['mets_order'][0] = $details['order'];
@@ -143,8 +141,7 @@  discard block
 block discarded – undo
143 141
      * {@inheritDoc}
144 142
      * @see \Kitodo\Dlf\Common\Document::establishRecordId()
145 143
      */
146
-    protected function establishRecordId($pid)
147
-    {
144
+    protected function establishRecordId($pid) {
148 145
         // Check for METS object @ID.
149 146
         if (!empty($this->mets['OBJID'])) {
150 147
             $this->recordId = (string) $this->mets['OBJID'];
@@ -164,8 +161,7 @@  discard block
 block discarded – undo
164 161
      * {@inheritDoc}
165 162
      * @see \Kitodo\Dlf\Common\Document::getDownloadLocation()
166 163
      */
167
-    public function getDownloadLocation($id)
168
-    {
164
+    public function getDownloadLocation($id) {
169 165
         $fileMimeType = $this->getFileMimeType($id);
170 166
         $fileLocation = $this->getFileLocation($id);
171 167
         if ($fileMimeType === 'application/vnd.kitodo.iiif') {
@@ -190,8 +186,7 @@  discard block
 block discarded – undo
190 186
      * {@inheritDoc}
191 187
      * @see \Kitodo\Dlf\Common\Document::getFileLocation()
192 188
      */
193
-    public function getFileLocation($id)
194
-    {
189
+    public function getFileLocation($id) {
195 190
         $location = $this->mets->xpath('./mets:fileSec/mets:fileGrp/mets:file[@ID="' . $id . '"]/mets:FLocat[@LOCTYPE="URL"]');
196 191
         if (
197 192
             !empty($id)
@@ -208,8 +203,7 @@  discard block
 block discarded – undo
208 203
      * {@inheritDoc}
209 204
      * @see \Kitodo\Dlf\Common\Document::getFileMimeType()
210 205
      */
211
-    public function getFileMimeType($id)
212
-    {
206
+    public function getFileMimeType($id) {
213 207
         $mimetype = $this->mets->xpath('./mets:fileSec/mets:fileGrp/mets:file[@ID="' . $id . '"]/@MIMETYPE');
214 208
         if (
215 209
             !empty($id)
@@ -226,8 +220,7 @@  discard block
 block discarded – undo
226 220
      * {@inheritDoc}
227 221
      * @see \Kitodo\Dlf\Common\Document::getLogicalStructure()
228 222
      */
229
-    public function getLogicalStructure($id, $recursive = false)
230
-    {
223
+    public function getLogicalStructure($id, $recursive = false) {
231 224
         $details = [];
232 225
         // Is the requested logical unit already loaded?
233 226
         if (
@@ -267,8 +260,7 @@  discard block
 block discarded – undo
267 260
      *
268 261
      * @return array Array of the element's id, label, type and physical page indexes/mptr link
269 262
      */
270
-    protected function getLogicalStructureInfo(\SimpleXMLElement $structure, $recursive = false)
271
-    {
263
+    protected function getLogicalStructureInfo(\SimpleXMLElement $structure, $recursive = false) {
272 264
         // Get attributes.
273 265
         foreach ($structure->attributes() as $attribute => $value) {
274 266
             $attributes[$attribute] = (string) $value;
@@ -366,8 +358,7 @@  discard block
 block discarded – undo
366 358
      * {@inheritDoc}
367 359
      * @see \Kitodo\Dlf\Common\Document::getMetadata()
368 360
      */
369
-    public function getMetadata($id, $cPid = 0)
370
-    {
361
+    public function getMetadata($id, $cPid = 0) {
371 362
         // Make sure $cPid is a non-negative integer.
372 363
         $cPid = max(intval($cPid), 0);
373 364
         // If $cPid is not given, try to get it elsewhere.
@@ -669,8 +660,7 @@  discard block
 block discarded – undo
669 660
      * {@inheritDoc}
670 661
      * @see \Kitodo\Dlf\Common\Document::getFullText()
671 662
      */
672
-    public function getFullText($id)
673
-    {
663
+    public function getFullText($id) {
674 664
         $fullText = '';
675 665
 
676 666
         // Load fileGrps and check for full text files.
@@ -685,8 +675,7 @@  discard block
 block discarded – undo
685 675
      * {@inheritDoc}
686 676
      * @see Document::getStructureDepth()
687 677
      */
688
-    public function getStructureDepth($logId)
689
-    {
678
+    public function getStructureDepth($logId) {
690 679
         $ancestors = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="' . $logId . '"]/ancestor::*');
691 680
         if (!empty($ancestors)) {
692 681
             return count($ancestors);
@@ -699,8 +688,7 @@  discard block
 block discarded – undo
699 688
      * {@inheritDoc}
700 689
      * @see \Kitodo\Dlf\Common\Document::init()
701 690
      */
702
-    protected function init()
703
-    {
691
+    protected function init() {
704 692
         // Get METS node from XML file.
705 693
         $this->registerNamespaces($this->xml);
706 694
         $mets = $this->xml->xpath('//mets:mets');
@@ -717,8 +705,7 @@  discard block
 block discarded – undo
717 705
      * {@inheritDoc}
718 706
      * @see \Kitodo\Dlf\Common\Document::loadLocation()
719 707
      */
720
-    protected function loadLocation($location)
721
-    {
708
+    protected function loadLocation($location) {
722 709
         $fileResource = GeneralUtility::getUrl($location);
723 710
         if ($fileResource !== false) {
724 711
             $xml = Helper::getXmlFileAsString($fileResource);
@@ -736,8 +723,7 @@  discard block
 block discarded – undo
736 723
      * {@inheritDoc}
737 724
      * @see \Kitodo\Dlf\Common\Document::ensureHasFulltextIsSet()
738 725
      */
739
-    protected function ensureHasFulltextIsSet()
740
-    {
726
+    protected function ensureHasFulltextIsSet() {
741 727
         // Are the fileGrps already loaded?
742 728
         if (!$this->fileGrpsLoaded) {
743 729
             $this->_getFileGrps();
@@ -748,8 +734,7 @@  discard block
 block discarded – undo
748 734
      * {@inheritDoc}
749 735
      * @see Document::getParentDocumentUid()
750 736
      */
751
-    protected function getParentDocumentUidForSaving($pid, $core, $owner)
752
-    {
737
+    protected function getParentDocumentUidForSaving($pid, $core, $owner) {
753 738
         $partof = 0;
754 739
         // Get the closest ancestor of the current document which has a MPTR child.
755 740
         $parentMptr = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="' . $this->_getToplevelId() . '"]/ancestor::mets:div[./mets:mptr][1]/mets:mptr');
@@ -772,8 +757,7 @@  discard block
 block discarded – undo
772 757
      * {@inheritDoc}
773 758
      * @see Document::setPreloadedDocument()
774 759
      */
775
-    protected function setPreloadedDocument($preloadedDocument)
776
-    {
760
+    protected function setPreloadedDocument($preloadedDocument) {
777 761
 
778 762
         if ($preloadedDocument instanceof \SimpleXMLElement) {
779 763
             $this->xml = $preloadedDocument;
@@ -786,8 +770,7 @@  discard block
 block discarded – undo
786 770
      * {@inheritDoc}
787 771
      * @see Document::getDocument()
788 772
      */
789
-    protected function getDocument()
790
-    {
773
+    protected function getDocument() {
791 774
         return $this->mets;
792 775
     }
793 776
 
@@ -798,8 +781,7 @@  discard block
 block discarded – undo
798 781
      *
799 782
      * @return array Array of dmdSecs with their IDs as array key
800 783
      */
801
-    protected function _getDmdSec()
802
-    {
784
+    protected function _getDmdSec() {
803 785
         if (!$this->dmdSecLoaded) {
804 786
             // Get available data formats.
805 787
             $this->loadFormats();
@@ -837,8 +819,7 @@  discard block
 block discarded – undo
837 819
      *
838 820
      * @return array Array of file use groups with file IDs
839 821
      */
840
-    protected function _getFileGrps()
841
-    {
822
+    protected function _getFileGrps() {
842 823
         if (!$this->fileGrpsLoaded) {
843 824
             // Get configured USE attributes.
844 825
             $extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey);
@@ -883,8 +864,7 @@  discard block
 block discarded – undo
883 864
      * {@inheritDoc}
884 865
      * @see \Kitodo\Dlf\Common\Document::prepareMetadataArray()
885 866
      */
886
-    protected function prepareMetadataArray($cPid)
887
-    {
867
+    protected function prepareMetadataArray($cPid) {
888 868
         $ids = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID]/@ID');
889 869
         // Get all logical structure nodes with metadata.
890 870
         if (!empty($ids)) {
@@ -902,8 +882,7 @@  discard block
 block discarded – undo
902 882
      *
903 883
      * @return \SimpleXMLElement The XML's METS part as \SimpleXMLElement object
904 884
      */
905
-    protected function _getMets()
906
-    {
885
+    protected function _getMets() {
907 886
         return $this->mets;
908 887
     }
909 888
 
@@ -911,8 +890,7 @@  discard block
 block discarded – undo
911 890
      * {@inheritDoc}
912 891
      * @see \Kitodo\Dlf\Common\Document::_getPhysicalStructure()
913 892
      */
914
-    protected function _getPhysicalStructure()
915
-    {
893
+    protected function _getPhysicalStructure() {
916 894
         // Is there no physical structure array yet?
917 895
         if (!$this->physicalStructureLoaded) {
918 896
             // Does the document have a structMap node of type "PHYSICAL"?
@@ -972,8 +950,7 @@  discard block
 block discarded – undo
972 950
      * {@inheritDoc}
973 951
      * @see \Kitodo\Dlf\Common\Document::_getSmLinks()
974 952
      */
975
-    protected function _getSmLinks()
976
-    {
953
+    protected function _getSmLinks() {
977 954
         if (!$this->smLinksLoaded) {
978 955
             $smLinks = $this->mets->xpath('./mets:structLink/mets:smLink');
979 956
             if (!empty($smLinks)) {
@@ -991,8 +968,7 @@  discard block
 block discarded – undo
991 968
      * {@inheritDoc}
992 969
      * @see \Kitodo\Dlf\Common\Document::_getThumbnail()
993 970
      */
994
-    protected function _getThumbnail($forceReload = false)
995
-    {
971
+    protected function _getThumbnail($forceReload = false) {
996 972
         if (
997 973
             !$this->thumbnailLoaded
998 974
             || $forceReload
@@ -1071,8 +1047,7 @@  discard block
 block discarded – undo
1071 1047
      * {@inheritDoc}
1072 1048
      * @see \Kitodo\Dlf\Common\Document::_getToplevelId()
1073 1049
      */
1074
-    protected function _getToplevelId()
1075
-    {
1050
+    protected function _getToplevelId() {
1076 1051
         if (empty($this->toplevelId)) {
1077 1052
             // Get all logical structure nodes with metadata, but without associated METS-Pointers.
1078 1053
             $divs = $this->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID and not(./mets:mptr)]');
@@ -1104,8 +1079,7 @@  discard block
 block discarded – undo
1104 1079
      *
1105 1080
      * @return array Properties to be serialized
1106 1081
      */
1107
-    public function __sleep()
1108
-    {
1082
+    public function __sleep() {
1109 1083
         // \SimpleXMLElement objects can't be serialized, thus save the XML as string for serialization
1110 1084
         $this->asXML = $this->xml->asXML();
1111 1085
         return ['uid', 'pid', 'recordId', 'parentId', 'asXML'];
@@ -1118,8 +1092,7 @@  discard block
 block discarded – undo
1118 1092
      *
1119 1093
      * @return string String representing the METS object
1120 1094
      */
1121
-    public function __toString()
1122
-    {
1095
+    public function __toString() {
1123 1096
         $xml = new \DOMDocument('1.0', 'utf-8');
1124 1097
         $xml->appendChild($xml->importNode(dom_import_simplexml($this->mets), true));
1125 1098
         $xml->formatOutput = true;
@@ -1134,8 +1107,7 @@  discard block
 block discarded – undo
1134 1107
      *
1135 1108
      * @return void
1136 1109
      */
1137
-    public function __wakeup()
1138
-    {
1110
+    public function __wakeup() {
1139 1111
         $xml = Helper::getXmlFileAsString($this->asXML);
1140 1112
         if ($xml !== false) {
1141 1113
             $this->asXML = '';
Please login to merge, or discard this patch.
Classes/Common/Indexer.php 1 patch
Braces   +8 added lines, -16 removed lines patch added patch discarded remove patch
@@ -28,8 +28,7 @@  discard block
 block discarded – undo
28 28
  * @subpackage dlf
29 29
  * @access public
30 30
  */
31
-class Indexer
32
-{
31
+class Indexer {
33 32
     /**
34 33
      * The extension key
35 34
      *
@@ -90,8 +89,7 @@  discard block
 block discarded – undo
90 89
      *
91 90
      * @return bool true on success or false on failure
92 91
      */
93
-    public static function add(Document &$doc, $core = 0)
94
-    {
92
+    public static function add(Document &$doc, $core = 0) {
95 93
         if (in_array($doc->uid, self::$processedDocs)) {
96 94
             return true;
97 95
         } elseif (self::solrConnect($core, $doc->pid)) {
@@ -211,8 +209,7 @@  discard block
 block discarded – undo
211 209
      *
212 210
      * @return string The field's dynamic index name
213 211
      */
214
-    public static function getIndexFieldName($index_name, $pid = 0)
215
-    {
212
+    public static function getIndexFieldName($index_name, $pid = 0) {
216 213
         // Sanitize input.
217 214
         $pid = max(intval($pid), 0);
218 215
         if (!$pid) {
@@ -238,8 +235,7 @@  discard block
 block discarded – undo
238 235
      *
239 236
      * @return void
240 237
      */
241
-    protected static function loadIndexConf($pid)
242
-    {
238
+    protected static function loadIndexConf($pid) {
243 239
         if (!self::$fieldsLoaded) {
244 240
             $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
245 241
                 ->getQueryBuilderForTable('tx_dlf_metadata');
@@ -309,8 +305,7 @@  discard block
 block discarded – undo
309 305
      *
310 306
      * @return bool true on success or false on failure
311 307
      */
312
-    protected static function processLogical(Document &$doc, array $logicalUnit)
313
-    {
308
+    protected static function processLogical(Document &$doc, array $logicalUnit) {
314 309
         $success = true;
315 310
         // Get metadata for logical unit.
316 311
         $metadata = $doc->metadataArray[$logicalUnit['id']];
@@ -439,8 +434,7 @@  discard block
 block discarded – undo
439 434
      *
440 435
      * @return bool true on success or false on failure
441 436
      */
442
-    protected static function processPhysical(Document &$doc, $page, array $physicalUnit)
443
-    {
437
+    protected static function processPhysical(Document &$doc, $page, array $physicalUnit) {
444 438
         if ($doc->hasFulltext && $fullText = $doc->getFullText($physicalUnit['id'])) {
445 439
             // Read extension configuration.
446 440
             $extConf = GeneralUtility::makeInstance(ExtensionConfiguration::class)->get(self::$extKey);
@@ -524,8 +518,7 @@  discard block
 block discarded – undo
524 518
      *
525 519
      * @return bool true on success or false on failure
526 520
      */
527
-    protected static function solrConnect($core, $pid = 0)
528
-    {
521
+    protected static function solrConnect($core, $pid = 0) {
529 522
         // Get Solr instance.
530 523
         if (!self::$solr) {
531 524
             // Connect to Solr server.
@@ -548,8 +541,7 @@  discard block
 block discarded – undo
548 541
      *
549 542
      * @access private
550 543
      */
551
-    private function __construct()
552
-    {
544
+    private function __construct() {
553 545
         // This is a static class, thus no instances should be created.
554 546
     }
555 547
 }
Please login to merge, or discard this patch.
Classes/Common/Document.php 1 patch
Braces   +32 added lines, -64 removed lines patch added patch discarded remove patch
@@ -48,8 +48,7 @@  discard block
 block discarded – undo
48 48
  * @property-read mixed $uid This holds the UID or the URL of the document
49 49
  * @abstract
50 50
  */
51
-abstract class Document
52
-{
51
+abstract class Document {
53 52
     /**
54 53
      * This holds the logger
55 54
      *
@@ -341,8 +340,7 @@  discard block
 block discarded – undo
341 340
      *
342 341
      * @return void
343 342
      */
344
-    public static function clearRegistry()
345
-    {
343
+    public static function clearRegistry() {
346 344
         // Reset registry array.
347 345
         self::$registry = [];
348 346
     }
@@ -607,8 +605,7 @@  discard block
 block discarded – undo
607 605
      *
608 606
      * @return int The physical page number
609 607
      */
610
-    public function getPhysicalPage($logicalPage)
611
-    {
608
+    public function getPhysicalPage($logicalPage) {
612 609
         if (
613 610
             !empty($this->lastSearchedPhysicalPage['logicalPage'])
614 611
             && $this->lastSearchedPhysicalPage['logicalPage'] == $logicalPage
@@ -653,8 +650,7 @@  discard block
 block discarded – undo
653 650
      *
654 651
      * @return string The OCR full text
655 652
      */
656
-    protected function getFullTextFromXml($id)
657
-    {
653
+    protected function getFullTextFromXml($id) {
658 654
         $fullText = '';
659 655
         // Load available text formats, ...
660 656
         $this->loadFormats();
@@ -716,8 +712,7 @@  discard block
 block discarded – undo
716 712
      *
717 713
      * @return string The format of the OCR full text
718 714
      */
719
-    private function getTextFormat($fileContent)
720
-    {
715
+    private function getTextFormat($fileContent) {
721 716
         // Get the root element's name as text format.
722 717
         return strtoupper(Helper::getXmlFileAsString($fileContent)->getName());
723 718
     }
@@ -734,8 +729,7 @@  discard block
 block discarded – undo
734 729
      *
735 730
      * @return string The title of the document itself or a parent document
736 731
      */
737
-    public static function getTitle($uid, $recursive = false)
738
-    {
732
+    public static function getTitle($uid, $recursive = false) {
739 733
         $title = '';
740 734
         // Sanitize input.
741 735
         $uid = max(intval($uid), 0);
@@ -787,8 +781,7 @@  discard block
 block discarded – undo
787 781
      *
788 782
      * @return array The logical structure node's / resource's parsed metadata array
789 783
      */
790
-    public function getTitledata($cPid = 0)
791
-    {
784
+    public function getTitledata($cPid = 0) {
792 785
         $titledata = $this->getMetadata($this->_getToplevelId(), $cPid);
793 786
         // Add information from METS structural map to titledata array.
794 787
         if ($this instanceof MetsDocument) {
@@ -821,8 +814,7 @@  discard block
 block discarded – undo
821 814
      * @return int|bool: false if structure with $logId is not a child of this substructure,
822 815
      * or the actual depth.
823 816
      */
824
-    protected function getTreeDepth($structure, $depth, $logId)
825
-    {
817
+    protected function getTreeDepth($structure, $depth, $logId) {
826 818
         foreach ($structure as $element) {
827 819
             if ($element['id'] == $logId) {
828 820
                 return $depth;
@@ -844,8 +836,7 @@  discard block
 block discarded – undo
844 836
      * @param string $logId: The id of the logical structure element whose depth is requested
845 837
      * @return int|bool tree depth as integer or false if no element with $logId exists within the TOC.
846 838
      */
847
-    public function getStructureDepth($logId)
848
-    {
839
+    public function getStructureDepth($logId) {
849 840
         return $this->getTreeDepth($this->_getTableOfContents(), 1, $logId);
850 841
     }
851 842
 
@@ -895,8 +886,7 @@  discard block
 block discarded – undo
895 886
      *
896 887
      * @return bool true on success or false on failure
897 888
      */
898
-    protected function load($location)
899
-    {
889
+    protected function load($location) {
900 890
         // Load XML / JSON-LD file.
901 891
         if (GeneralUtility::isValidUrl($location)) {
902 892
             // Load extension configuration
@@ -929,8 +919,7 @@  discard block
 block discarded – undo
929 919
      *
930 920
      * @return void
931 921
      */
932
-    protected function loadFormats()
933
-    {
922
+    protected function loadFormats() {
934 923
         if (!$this->formatsLoaded) {
935 924
             $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
936 925
                 ->getQueryBuilderForTable('tx_dlf_formats');
@@ -970,8 +959,7 @@  discard block
 block discarded – undo
970 959
      *
971 960
      * @return void
972 961
      */
973
-    public function registerNamespaces(&$obj)
974
-    {
962
+    public function registerNamespaces(&$obj) {
975 963
         // TODO Check usage. XML specific method does not seem to be used anywhere outside this class within the project, but it is public and may be used by extensions.
976 964
         $this->loadFormats();
977 965
         // Do we have a \SimpleXMLElement or \DOMXPath object?
@@ -1000,8 +988,7 @@  discard block
 block discarded – undo
1000 988
      *
1001 989
      * @return bool true on success or false on failure
1002 990
      */
1003
-    public function save($pid = 0, $core = 0, $owner = null)
1004
-    {
991
+    public function save($pid = 0, $core = 0, $owner = null) {
1005 992
         if (\TYPO3_MODE !== 'BE') {
1006 993
             $this->logger->error('Saving a document is only allowed in the backend');
1007 994
             return false;
@@ -1329,8 +1316,7 @@  discard block
 block discarded – undo
1329 1316
      *
1330 1317
      * @return int The PID of the metadata definitions
1331 1318
      */
1332
-    protected function _getCPid()
1333
-    {
1319
+    protected function _getCPid() {
1334 1320
         return $this->cPid;
1335 1321
     }
1336 1322
 
@@ -1341,8 +1327,7 @@  discard block
 block discarded – undo
1341 1327
      *
1342 1328
      * @return bool Are there any fulltext files available?
1343 1329
      */
1344
-    protected function _getHasFulltext()
1345
-    {
1330
+    protected function _getHasFulltext() {
1346 1331
         $this->ensureHasFulltextIsSet();
1347 1332
         return $this->hasFulltext;
1348 1333
     }
@@ -1354,8 +1339,7 @@  discard block
 block discarded – undo
1354 1339
      *
1355 1340
      * @return string The location of the document
1356 1341
      */
1357
-    protected function _getLocation()
1358
-    {
1342
+    protected function _getLocation() {
1359 1343
         return $this->location;
1360 1344
     }
1361 1345
 
@@ -1377,8 +1361,7 @@  discard block
 block discarded – undo
1377 1361
      *
1378 1362
      * @return array Array of metadata with their corresponding logical structure node ID as key
1379 1363
      */
1380
-    protected function _getMetadataArray()
1381
-    {
1364
+    protected function _getMetadataArray() {
1382 1365
         // Set metadata definitions' PID.
1383 1366
         $cPid = ($this->cPid ? $this->cPid : $this->pid);
1384 1367
         if (!$cPid) {
@@ -1403,8 +1386,7 @@  discard block
 block discarded – undo
1403 1386
      *
1404 1387
      * @return int The total number of pages and/or tracks
1405 1388
      */
1406
-    protected function _getNumPages()
1407
-    {
1389
+    protected function _getNumPages() {
1408 1390
         $this->_getPhysicalStructure();
1409 1391
         return $this->numPages;
1410 1392
     }
@@ -1416,8 +1398,7 @@  discard block
 block discarded – undo
1416 1398
      *
1417 1399
      * @return int The UID of the parent document or zero if not applicable
1418 1400
      */
1419
-    protected function _getParentId()
1420
-    {
1401
+    protected function _getParentId() {
1421 1402
         return $this->parentId;
1422 1403
     }
1423 1404
 
@@ -1440,8 +1421,7 @@  discard block
 block discarded – undo
1440 1421
      *
1441 1422
      * @return array Array of elements' type, label and file representations ordered by @ID attribute / Canvas order
1442 1423
      */
1443
-    protected function _getPhysicalStructureInfo()
1444
-    {
1424
+    protected function _getPhysicalStructureInfo() {
1445 1425
         // Is there no physical structure array yet?
1446 1426
         if (!$this->physicalStructureLoaded) {
1447 1427
             // Build physical structure array.
@@ -1457,8 +1437,7 @@  discard block
 block discarded – undo
1457 1437
      *
1458 1438
      * @return int The PID of the document or zero if not in database
1459 1439
      */
1460
-    protected function _getPid()
1461
-    {
1440
+    protected function _getPid() {
1462 1441
         return $this->pid;
1463 1442
     }
1464 1443
 
@@ -1469,8 +1448,7 @@  discard block
 block discarded – undo
1469 1448
      *
1470 1449
      * @return bool Is the document instantiated successfully?
1471 1450
      */
1472
-    protected function _getReady()
1473
-    {
1451
+    protected function _getReady() {
1474 1452
         return $this->ready;
1475 1453
     }
1476 1454
 
@@ -1481,8 +1459,7 @@  discard block
 block discarded – undo
1481 1459
      *
1482 1460
      * @return mixed The METS file's / IIIF manifest's record identifier
1483 1461
      */
1484
-    protected function _getRecordId()
1485
-    {
1462
+    protected function _getRecordId() {
1486 1463
         return $this->recordId;
1487 1464
     }
1488 1465
 
@@ -1493,8 +1470,7 @@  discard block
 block discarded – undo
1493 1470
      *
1494 1471
      * @return int The UID of the root document or zero if not applicable
1495 1472
      */
1496
-    protected function _getRootId()
1497
-    {
1473
+    protected function _getRootId() {
1498 1474
         if (!$this->rootIdLoaded) {
1499 1475
             if ($this->parentId) {
1500 1476
                 $parent = self::getInstance($this->parentId, $this->pid);
@@ -1524,8 +1500,7 @@  discard block
 block discarded – undo
1524 1500
      *
1525 1501
      * @return array Array of structure nodes' id, label, type and physical page indexes/mptr / Canvas link with original hierarchy preserved
1526 1502
      */
1527
-    protected function _getTableOfContents()
1528
-    {
1503
+    protected function _getTableOfContents() {
1529 1504
         // Is there no logical structure array yet?
1530 1505
         if (!$this->tableOfContentsLoaded) {
1531 1506
             // Get all logical structures.
@@ -1566,8 +1541,7 @@  discard block
 block discarded – undo
1566 1541
      *
1567 1542
      * @return mixed The UID or the URL of the document
1568 1543
      */
1569
-    protected function _getUid()
1570
-    {
1544
+    protected function _getUid() {
1571 1545
         return $this->uid;
1572 1546
     }
1573 1547
 
@@ -1580,8 +1554,7 @@  discard block
 block discarded – undo
1580 1554
      *
1581 1555
      * @return void
1582 1556
      */
1583
-    protected function _setCPid($value)
1584
-    {
1557
+    protected function _setCPid($value) {
1585 1558
         $this->cPid = max(intval($value), 0);
1586 1559
     }
1587 1560
 
@@ -1592,8 +1565,7 @@  discard block
 block discarded – undo
1592 1565
      *
1593 1566
      * @return void
1594 1567
      */
1595
-    protected function __clone()
1596
-    {
1568
+    protected function __clone() {
1597 1569
         // This method is defined as protected because singleton objects should not be cloned.
1598 1570
     }
1599 1571
 
@@ -1610,8 +1582,7 @@  discard block
 block discarded – undo
1610 1582
      *
1611 1583
      * @return void
1612 1584
      */
1613
-    protected function __construct($uid, $pid, $preloadedDocument)
1614
-    {
1585
+    protected function __construct($uid, $pid, $preloadedDocument) {
1615 1586
         $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
1616 1587
             ->getQueryBuilderForTable('tx_dlf_documents');
1617 1588
         $location = '';
@@ -1723,8 +1694,7 @@  discard block
 block discarded – undo
1723 1694
      *
1724 1695
      * @return mixed Value of $this->$var
1725 1696
      */
1726
-    public function __get($var)
1727
-    {
1697
+    public function __get($var) {
1728 1698
         $method = '_get' . ucfirst($var);
1729 1699
         if (
1730 1700
             !property_exists($this, $var)
@@ -1746,8 +1716,7 @@  discard block
 block discarded – undo
1746 1716
      *
1747 1717
      * @return bool true if variable is set and not empty, false otherwise
1748 1718
      */
1749
-    public function __isset($var)
1750
-    {
1719
+    public function __isset($var) {
1751 1720
         return !empty($this->__get($var));
1752 1721
     }
1753 1722
 
@@ -1761,8 +1730,7 @@  discard block
 block discarded – undo
1761 1730
      *
1762 1731
      * @return void
1763 1732
      */
1764
-    public function __set($var, $value)
1765
-    {
1733
+    public function __set($var, $value) {
1766 1734
         $method = '_set' . ucfirst($var);
1767 1735
         if (
1768 1736
             !property_exists($this, $var)
Please login to merge, or discard this patch.