@@ -31,8 +31,7 @@ discard block |
||
| 31 | 31 | * @subpackage dlf |
| 32 | 32 | * @access public |
| 33 | 33 | */ |
| 34 | -class Helper |
|
| 35 | -{ |
|
| 34 | +class Helper { |
|
| 36 | 35 | /** |
| 37 | 36 | * The extension key |
| 38 | 37 | * |
@@ -80,8 +79,7 @@ discard block |
||
| 80 | 79 | * |
| 81 | 80 | * @return \TYPO3\CMS\Core\Messaging\FlashMessageQueue The queue the message was added to |
| 82 | 81 | */ |
| 83 | - public static function addMessage($message, $title, $severity, $session = false, $queue = 'kitodo.default.flashMessages') |
|
| 84 | - { |
|
| 82 | + public static function addMessage($message, $title, $severity, $session = false, $queue = 'kitodo.default.flashMessages') { |
|
| 85 | 83 | $flashMessageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class); |
| 86 | 84 | $flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier($queue); |
| 87 | 85 | $flashMessage = GeneralUtility::makeInstance( |
@@ -106,8 +104,7 @@ discard block |
||
| 106 | 104 | * |
| 107 | 105 | * @return bool Is $id a valid GNL identifier of the given $type? |
| 108 | 106 | */ |
| 109 | - public static function checkIdentifier($id, $type) |
|
| 110 | - { |
|
| 107 | + public static function checkIdentifier($id, $type) { |
|
| 111 | 108 | $digits = substr($id, 0, 8); |
| 112 | 109 | $checksum = 0; |
| 113 | 110 | for ($i = 0, $j = strlen($digits); $i < $j; $i++) { |
@@ -171,8 +168,7 @@ discard block |
||
| 171 | 168 | * |
| 172 | 169 | * @return mixed The decrypted value or false on error |
| 173 | 170 | */ |
| 174 | - public static function decrypt($encrypted) |
|
| 175 | - { |
|
| 171 | + public static function decrypt($encrypted) { |
|
| 176 | 172 | if ( |
| 177 | 173 | !in_array(self::$cipherAlgorithm, openssl_get_cipher_methods(true)) |
| 178 | 174 | || !in_array(self::$hashAlgorithm, openssl_get_md_methods(true)) |
@@ -211,8 +207,7 @@ discard block |
||
| 211 | 207 | * |
| 212 | 208 | * @return \SimpleXMLElement|false |
| 213 | 209 | */ |
| 214 | - public static function getXmlFileAsString($content) |
|
| 215 | - { |
|
| 210 | + public static function getXmlFileAsString($content) { |
|
| 216 | 211 | // Don't make simplexml_load_string throw (when $content is an array |
| 217 | 212 | // or object) |
| 218 | 213 | if (!is_string($content)) { |
@@ -243,8 +238,7 @@ discard block |
||
| 243 | 238 | * |
| 244 | 239 | * @return void |
| 245 | 240 | */ |
| 246 | - public static function log($message, $severity = 0) |
|
| 247 | - { |
|
| 241 | + public static function log($message, $severity = 0) { |
|
| 248 | 242 | $logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(get_called_class()); |
| 249 | 243 | |
| 250 | 244 | switch ($severity) { |
@@ -274,8 +268,7 @@ discard block |
||
| 274 | 268 | * |
| 275 | 269 | * @return mixed Hashed string or false on error |
| 276 | 270 | */ |
| 277 | - public static function digest($string) |
|
| 278 | - { |
|
| 271 | + public static function digest($string) { |
|
| 279 | 272 | if (!in_array(self::$hashAlgorithm, openssl_get_md_methods(true))) { |
| 280 | 273 | self::log('OpenSSL library doesn\'t support hash algorithm', LOG_SEVERITY_ERROR); |
| 281 | 274 | return false; |
@@ -294,8 +287,7 @@ discard block |
||
| 294 | 287 | * |
| 295 | 288 | * @return mixed Encrypted string or false on error |
| 296 | 289 | */ |
| 297 | - public static function encrypt($string) |
|
| 298 | - { |
|
| 290 | + public static function encrypt($string) { |
|
| 299 | 291 | if ( |
| 300 | 292 | !in_array(self::$cipherAlgorithm, openssl_get_cipher_methods(true)) |
| 301 | 293 | || !in_array(self::$hashAlgorithm, openssl_get_md_methods(true)) |
@@ -328,8 +320,7 @@ discard block |
||
| 328 | 320 | * |
| 329 | 321 | * @return string The unqualified class name |
| 330 | 322 | */ |
| 331 | - public static function getUnqualifiedClassName($qualifiedClassname) |
|
| 332 | - { |
|
| 323 | + public static function getUnqualifiedClassName($qualifiedClassname) { |
|
| 333 | 324 | $nameParts = explode('\\', $qualifiedClassname); |
| 334 | 325 | return end($nameParts); |
| 335 | 326 | } |
@@ -343,8 +334,7 @@ discard block |
||
| 343 | 334 | * |
| 344 | 335 | * @return string The cleaned up string |
| 345 | 336 | */ |
| 346 | - public static function getCleanString($string) |
|
| 347 | - { |
|
| 337 | + public static function getCleanString($string) { |
|
| 348 | 338 | // Convert to lowercase. |
| 349 | 339 | $string = strtolower($string); |
| 350 | 340 | // Remove non-alphanumeric characters. |
@@ -365,8 +355,7 @@ discard block |
||
| 365 | 355 | * |
| 366 | 356 | * @return array Array of hook objects for the class |
| 367 | 357 | */ |
| 368 | - public static function getHookObjects($scriptRelPath) |
|
| 369 | - { |
|
| 358 | + public static function getHookObjects($scriptRelPath) { |
|
| 370 | 359 | $hookObjects = []; |
| 371 | 360 | if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey . '/' . $scriptRelPath]['hookClass'])) { |
| 372 | 361 | foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][self::$extKey . '/' . $scriptRelPath]['hookClass'] as $classRef) { |
@@ -387,8 +376,7 @@ discard block |
||
| 387 | 376 | * |
| 388 | 377 | * @return string "index_name" for the given UID |
| 389 | 378 | */ |
| 390 | - public static function getIndexNameFromUid($uid, $table, $pid = -1) |
|
| 391 | - { |
|
| 379 | + public static function getIndexNameFromUid($uid, $table, $pid = -1) { |
|
| 392 | 380 | // Sanitize input. |
| 393 | 381 | $uid = max(intval($uid), 0); |
| 394 | 382 | if ( |
@@ -438,8 +426,7 @@ discard block |
||
| 438 | 426 | * |
| 439 | 427 | * @return string Localized full name of language or unchanged input |
| 440 | 428 | */ |
| 441 | - public static function getLanguageName($code) |
|
| 442 | - { |
|
| 429 | + public static function getLanguageName($code) { |
|
| 443 | 430 | // Analyze code and set appropriate ISO table. |
| 444 | 431 | $isoCode = strtolower(trim($code)); |
| 445 | 432 | if (preg_match('/^[a-z]{3}$/', $isoCode)) { |
@@ -481,8 +468,7 @@ discard block |
||
| 481 | 468 | * |
| 482 | 469 | * @return array |
| 483 | 470 | */ |
| 484 | - public static function getDocumentStructures($pid = -1) |
|
| 485 | - { |
|
| 471 | + public static function getDocumentStructures($pid = -1) { |
|
| 486 | 472 | $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); |
| 487 | 473 | $queryBuilder = $connectionPool->getQueryBuilderForTable('tx_dlf_structures'); |
| 488 | 474 | |
@@ -522,8 +508,7 @@ discard block |
||
| 522 | 508 | * |
| 523 | 509 | * @return string Uniform Resource Name as string |
| 524 | 510 | */ |
| 525 | - public static function getURN($base, $id) |
|
| 526 | - { |
|
| 511 | + public static function getURN($base, $id) { |
|
| 527 | 512 | $concordance = [ |
| 528 | 513 | '0' => 1, |
| 529 | 514 | '1' => 2, |
@@ -590,8 +575,7 @@ discard block |
||
| 590 | 575 | * |
| 591 | 576 | * @return bool Is $id a valid PPN? |
| 592 | 577 | */ |
| 593 | - public static function isPPN($id) |
|
| 594 | - { |
|
| 578 | + public static function isPPN($id) { |
|
| 595 | 579 | return self::checkIdentifier($id, 'PPN'); |
| 596 | 580 | } |
| 597 | 581 | |
@@ -602,8 +586,7 @@ discard block |
||
| 602 | 586 | * |
| 603 | 587 | * @return bool |
| 604 | 588 | */ |
| 605 | - public static function isValidHttpUrl($url) |
|
| 606 | - { |
|
| 589 | + public static function isValidHttpUrl($url) { |
|
| 607 | 590 | if (!GeneralUtility::isValidUrl($url)) { |
| 608 | 591 | return false; |
| 609 | 592 | } |
@@ -629,8 +612,7 @@ discard block |
||
| 629 | 612 | * |
| 630 | 613 | * @return array Merged array |
| 631 | 614 | */ |
| 632 | - public static function mergeRecursiveWithOverrule(array $original, array $overrule, $addKeys = true, $includeEmptyValues = true, $enableUnsetFeature = true) |
|
| 633 | - { |
|
| 615 | + public static function mergeRecursiveWithOverrule(array $original, array $overrule, $addKeys = true, $includeEmptyValues = true, $enableUnsetFeature = true) { |
|
| 634 | 616 | \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($original, $overrule, $addKeys, $includeEmptyValues, $enableUnsetFeature); |
| 635 | 617 | return $original; |
| 636 | 618 | } |
@@ -644,8 +626,7 @@ discard block |
||
| 644 | 626 | * |
| 645 | 627 | * @return string All flash messages in the queue rendered as HTML. |
| 646 | 628 | */ |
| 647 | - public static function renderFlashMessages($queue = 'kitodo.default.flashMessages') |
|
| 648 | - { |
|
| 629 | + public static function renderFlashMessages($queue = 'kitodo.default.flashMessages') { |
|
| 649 | 630 | $flashMessageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class); |
| 650 | 631 | $flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier($queue); |
| 651 | 632 | $flashMessages = $flashMessageQueue->getAllMessagesAndFlush(); |
@@ -665,8 +646,7 @@ discard block |
||
| 665 | 646 | * |
| 666 | 647 | * @return string Localized label for $index_name |
| 667 | 648 | */ |
| 668 | - public static function translate($index_name, $table, $pid) |
|
| 669 | - { |
|
| 649 | + public static function translate($index_name, $table, $pid) { |
|
| 670 | 650 | // Load labels into static variable for future use. |
| 671 | 651 | static $labels = []; |
| 672 | 652 | // Sanitize input. |
@@ -794,8 +774,7 @@ discard block |
||
| 794 | 774 | * |
| 795 | 775 | * @return string Additional WHERE expression |
| 796 | 776 | */ |
| 797 | - public static function whereExpression($table, $showHidden = false) |
|
| 798 | - { |
|
| 777 | + public static function whereExpression($table, $showHidden = false) { |
|
| 799 | 778 | if (\TYPO3_MODE === 'FE') { |
| 800 | 779 | // Should we ignore the record's hidden flag? |
| 801 | 780 | $ignoreHide = 0; |
@@ -827,8 +806,7 @@ discard block |
||
| 827 | 806 | * |
| 828 | 807 | * @access private |
| 829 | 808 | */ |
| 830 | - private function __construct() |
|
| 831 | - { |
|
| 809 | + private function __construct() { |
|
| 832 | 810 | // This is a static class, thus no instances should be created. |
| 833 | 811 | } |
| 834 | 812 | |
@@ -854,8 +832,7 @@ discard block |
||
| 854 | 832 | * |
| 855 | 833 | * @access public |
| 856 | 834 | */ |
| 857 | - public static function polyfillExtbaseClassesForTYPO3v9() |
|
| 858 | - { |
|
| 835 | + public static function polyfillExtbaseClassesForTYPO3v9() { |
|
| 859 | 836 | $classes = require __DIR__ . '/../../Configuration/Extbase/Persistence/Classes.php'; |
| 860 | 837 | |
| 861 | 838 | $objectManager = GeneralUtility::makeInstance(ObjectManager::class); |
@@ -892,8 +869,7 @@ discard block |
||
| 892 | 869 | * |
| 893 | 870 | * @return string|bool |
| 894 | 871 | */ |
| 895 | - public static function getUrl(string $url) |
|
| 896 | - { |
|
| 872 | + public static function getUrl(string $url) { |
|
| 897 | 873 | if (!Helper::isValidHttpUrl($url)) { |
| 898 | 874 | return false; |
| 899 | 875 | } |
@@ -32,8 +32,7 @@ discard block |
||
| 32 | 32 | * @subpackage dlf |
| 33 | 33 | * @access public |
| 34 | 34 | */ |
| 35 | -class SearchController extends AbstractController |
|
| 36 | -{ |
|
| 35 | +class SearchController extends AbstractController { |
|
| 37 | 36 | /** |
| 38 | 37 | * @var CollectionRepository |
| 39 | 38 | */ |
@@ -42,8 +41,7 @@ discard block |
||
| 42 | 41 | /** |
| 43 | 42 | * @param CollectionRepository $collectionRepository |
| 44 | 43 | */ |
| 45 | - public function injectCollectionRepository(CollectionRepository $collectionRepository) |
|
| 46 | - { |
|
| 44 | + public function injectCollectionRepository(CollectionRepository $collectionRepository) { |
|
| 47 | 45 | $this->collectionRepository = $collectionRepository; |
| 48 | 46 | } |
| 49 | 47 | |
@@ -55,8 +53,7 @@ discard block |
||
| 55 | 53 | /** |
| 56 | 54 | * @param MetadataRepository $metadataRepository |
| 57 | 55 | */ |
| 58 | - public function injectMetadataRepository(MetadataRepository $metadataRepository) |
|
| 59 | - { |
|
| 56 | + public function injectMetadataRepository(MetadataRepository $metadataRepository) { |
|
| 60 | 57 | $this->metadataRepository = $metadataRepository; |
| 61 | 58 | } |
| 62 | 59 | |
@@ -71,8 +68,7 @@ discard block |
||
| 71 | 68 | * |
| 72 | 69 | * @return void |
| 73 | 70 | */ |
| 74 | - public function searchAction() |
|
| 75 | - { |
|
| 71 | + public function searchAction() { |
|
| 76 | 72 | // if search was triggered, get search parameters from POST variables |
| 77 | 73 | $this->searchParams = $this->getParametersSafely('searchParameter'); |
| 78 | 74 | |
@@ -87,8 +83,7 @@ discard block |
||
| 87 | 83 | * |
| 88 | 84 | * @return void |
| 89 | 85 | */ |
| 90 | - public function mainAction() |
|
| 91 | - { |
|
| 86 | + public function mainAction() { |
|
| 92 | 87 | $listViewSearch = false; |
| 93 | 88 | // Quit without doing anything if required variables are not set. |
| 94 | 89 | if (empty($this->settings['solrcore'])) { |
@@ -174,8 +169,7 @@ discard block |
||
| 174 | 169 | * |
| 175 | 170 | * @return string HTML output of facets menu |
| 176 | 171 | */ |
| 177 | - protected function addFacetsMenu() |
|
| 178 | - { |
|
| 172 | + protected function addFacetsMenu() { |
|
| 179 | 173 | // Quit without doing anything if no facets are configured. |
| 180 | 174 | if (empty($this->settings['facets']) && empty($this->settings['facetCollections'])) { |
| 181 | 175 | return ''; |
@@ -200,8 +194,7 @@ discard block |
||
| 200 | 194 | * |
| 201 | 195 | * @return array HMENU array |
| 202 | 196 | */ |
| 203 | - public function makeFacetsMenuArray($facets) |
|
| 204 | - { |
|
| 197 | + public function makeFacetsMenuArray($facets) { |
|
| 205 | 198 | $menuArray = []; |
| 206 | 199 | // Set default value for facet search. |
| 207 | 200 | $search = [ |
@@ -360,8 +353,7 @@ discard block |
||
| 360 | 353 | * |
| 361 | 354 | * @return array The array for the facet's menu entry |
| 362 | 355 | */ |
| 363 | - protected function getFacetsMenuEntry($field, $value, $count, $search, &$state) |
|
| 364 | - { |
|
| 356 | + protected function getFacetsMenuEntry($field, $value, $count, $search, &$state) { |
|
| 365 | 357 | $entryArray = []; |
| 366 | 358 | // Translate value. |
| 367 | 359 | if ($field == 'owner_faceting') { |
@@ -412,8 +404,7 @@ discard block |
||
| 412 | 404 | * |
| 413 | 405 | * @return string The extended search form or an empty string |
| 414 | 406 | */ |
| 415 | - protected function addExtendedSearch() |
|
| 416 | - { |
|
| 407 | + protected function addExtendedSearch() { |
|
| 417 | 408 | // Quit without doing anything if no fields for extended search are selected. |
| 418 | 409 | if ( |
| 419 | 410 | empty($this->settings['extendedSlotCount']) |
@@ -5,10 +5,8 @@ |
||
| 5 | 5 | use Kitodo\Dlf\Common\Helper; |
| 6 | 6 | use TYPO3\TestingFramework\Core\Unit\UnitTestCase; |
| 7 | 7 | |
| 8 | -class HelperTest extends UnitTestCase |
|
| 9 | -{ |
|
| 10 | - public function assertInvalidXml($xml) |
|
| 11 | - { |
|
| 8 | +class HelperTest extends UnitTestCase { |
|
| 9 | + public function assertInvalidXml($xml) { |
|
| 12 | 10 | $result = Helper::getXmlFileAsString($xml); |
| 13 | 11 | $this->assertEquals(false, $result); |
| 14 | 12 | } |
@@ -6,19 +6,16 @@ |
||
| 6 | 6 | use Kitodo\Dlf\Tests\Functional\FunctionalTestCase; |
| 7 | 7 | use TYPO3\CMS\Core\Utility\GeneralUtility; |
| 8 | 8 | |
| 9 | -class PageViewProxyTest extends FunctionalTestCase |
|
| 10 | -{ |
|
| 9 | +class PageViewProxyTest extends FunctionalTestCase { |
|
| 11 | 10 | protected $disableJsonWrappedResponse = true; |
| 12 | 11 | |
| 13 | - protected function getDlfConfiguration() |
|
| 14 | - { |
|
| 12 | + protected function getDlfConfiguration() { |
|
| 15 | 13 | return array_merge(parent::getDlfConfiguration(), [ |
| 16 | 14 | 'enableInternalProxy' => true, |
| 17 | 15 | ]); |
| 18 | 16 | } |
| 19 | 17 | |
| 20 | - protected function queryProxy(array $query, string $method = 'GET') |
|
| 21 | - { |
|
| 18 | + protected function queryProxy(array $query, string $method = 'GET') { |
|
| 22 | 19 | $query['eID'] = 'tx_dlf_pageview_proxy'; |
| 23 | 20 | |
| 24 | 21 | return $this->httpClient->request($method, '', [ |
@@ -5,12 +5,10 @@ |
||
| 5 | 5 | use Kitodo\Dlf\Tests\Functional\FunctionalTestCase; |
| 6 | 6 | use TYPO3\CMS\Core\Utility\GeneralUtility; |
| 7 | 7 | |
| 8 | -class PageViewProxyDisabledTest extends FunctionalTestCase |
|
| 9 | -{ |
|
| 8 | +class PageViewProxyDisabledTest extends FunctionalTestCase { |
|
| 10 | 9 | protected $disableJsonWrappedResponse = true; |
| 11 | 10 | |
| 12 | - protected function queryProxy(array $query, string $method = 'GET') |
|
| 13 | - { |
|
| 11 | + protected function queryProxy(array $query, string $method = 'GET') { |
|
| 14 | 12 | $query['eID'] = 'tx_dlf_pageview_proxy'; |
| 15 | 13 | |
| 16 | 14 | return $this->httpClient->request($method, '', [ |
@@ -12,8 +12,7 @@ discard block |
||
| 12 | 12 | use SimpleXMLElement; |
| 13 | 13 | use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager; |
| 14 | 14 | |
| 15 | -class OaiPmhTest extends FunctionalTestCase |
|
| 16 | -{ |
|
| 15 | +class OaiPmhTest extends FunctionalTestCase { |
|
| 17 | 16 | protected $disableJsonWrappedResponse = true; |
| 18 | 17 | |
| 19 | 18 | protected $coreExtensionsToLoad = [ |
@@ -53,8 +52,7 @@ discard block |
||
| 53 | 52 | $this->setUpOaiSolr(); |
| 54 | 53 | } |
| 55 | 54 | |
| 56 | - protected function setUpOaiSolr() |
|
| 57 | - { |
|
| 55 | + protected function setUpOaiSolr() { |
|
| 58 | 56 | // Setup Solr only once for all tests in this suite |
| 59 | 57 | static $solr = null; |
| 60 | 58 | |
@@ -71,8 +69,7 @@ discard block |
||
| 71 | 69 | $this->persistenceManager->persistAll(); |
| 72 | 70 | } |
| 73 | 71 | |
| 74 | - protected function importSolrDocuments(Solr $solr, string $path) |
|
| 75 | - { |
|
| 72 | + protected function importSolrDocuments(Solr $solr, string $path) { |
|
| 76 | 73 | $jsonDocuments = json_decode(file_get_contents($path), true); |
| 77 | 74 | |
| 78 | 75 | $updateQuery = $solr->service->createUpdate(); |
@@ -91,8 +88,7 @@ discard block |
||
| 91 | 88 | /** |
| 92 | 89 | * @test |
| 93 | 90 | */ |
| 94 | - public function correctlyRespondsOnBadVerb() |
|
| 95 | - { |
|
| 91 | + public function correctlyRespondsOnBadVerb() { |
|
| 96 | 92 | $client = new HttpClient(); |
| 97 | 93 | $response = $client->get($this->baseUrl, [ |
| 98 | 94 | 'query' => [ |
@@ -117,8 +113,7 @@ discard block |
||
| 117 | 113 | /** |
| 118 | 114 | * @test |
| 119 | 115 | */ |
| 120 | - public function canIdentify() |
|
| 121 | - { |
|
| 116 | + public function canIdentify() { |
|
| 122 | 117 | $oai = Endpoint::build($this->oaiUrl); |
| 123 | 118 | $identity = $oai->identify(); |
| 124 | 119 | |
@@ -131,8 +126,7 @@ discard block |
||
| 131 | 126 | /** |
| 132 | 127 | * @test |
| 133 | 128 | */ |
| 134 | - public function identifyGivesFallbackDatestampWhenNoDocuments() |
|
| 135 | - { |
|
| 129 | + public function identifyGivesFallbackDatestampWhenNoDocuments() { |
|
| 136 | 130 | $oai = Endpoint::build($this->oaiUrlNoStoragePid); |
| 137 | 131 | $identity = $oai->identify(); |
| 138 | 132 | |
@@ -142,8 +136,7 @@ discard block |
||
| 142 | 136 | /** |
| 143 | 137 | * @test |
| 144 | 138 | */ |
| 145 | - public function canListMetadataFormats() |
|
| 146 | - { |
|
| 139 | + public function canListMetadataFormats() { |
|
| 147 | 140 | $oai = Endpoint::build($this->oaiUrl); |
| 148 | 141 | $formats = $oai->listMetadataFormats(); |
| 149 | 142 | |
@@ -158,8 +151,7 @@ discard block |
||
| 158 | 151 | /** |
| 159 | 152 | * @test |
| 160 | 153 | */ |
| 161 | - public function canListRecords() |
|
| 162 | - { |
|
| 154 | + public function canListRecords() { |
|
| 163 | 155 | $oai = Endpoint::build($this->oaiUrl); |
| 164 | 156 | $result = $oai->listRecords('mets'); |
| 165 | 157 | |
@@ -172,8 +164,7 @@ discard block |
||
| 172 | 164 | /** |
| 173 | 165 | * @test |
| 174 | 166 | */ |
| 175 | - public function noRecordsUntil1900() |
|
| 176 | - { |
|
| 167 | + public function noRecordsUntil1900() { |
|
| 177 | 168 | $this->expectException(OaipmhException::class); |
| 178 | 169 | $this->expectExceptionMessage('empty list'); |
| 179 | 170 | |
@@ -186,8 +177,7 @@ discard block |
||
| 186 | 177 | /** |
| 187 | 178 | * @test |
| 188 | 179 | */ |
| 189 | - public function canUseResumptionToken() |
|
| 190 | - { |
|
| 180 | + public function canUseResumptionToken() { |
|
| 191 | 181 | // NOTE: cursor and expirationDate are optional by the specification, |
| 192 | 182 | // but we include them in our implementation |
| 193 | 183 | |
@@ -245,8 +235,7 @@ discard block |
||
| 245 | 235 | /** |
| 246 | 236 | * @test |
| 247 | 237 | */ |
| 248 | - public function noResumptionTokenForCompleteList() |
|
| 249 | - { |
|
| 238 | + public function noResumptionTokenForCompleteList() { |
|
| 250 | 239 | $client = new HttpClient(); |
| 251 | 240 | |
| 252 | 241 | foreach (['ListIdentifiers', 'ListRecords'] as $verb) { |
@@ -268,8 +257,7 @@ discard block |
||
| 268 | 257 | /** |
| 269 | 258 | * @test |
| 270 | 259 | */ |
| 271 | - public function canListAndResumeIdentifiers() |
|
| 272 | - { |
|
| 260 | + public function canListAndResumeIdentifiers() { |
|
| 273 | 261 | $oai = Endpoint::build($this->oaiUrl); |
| 274 | 262 | $result = $oai->listIdentifiers('mets'); |
| 275 | 263 | |
@@ -282,18 +270,15 @@ discard block |
||
| 282 | 270 | $this->assertEquals('oai:de:slub-dresden:db:id-476248086', $record->identifier); |
| 283 | 271 | } |
| 284 | 272 | |
| 285 | - protected function parseUtc(string $dateTime) |
|
| 286 | - { |
|
| 273 | + protected function parseUtc(string $dateTime) { |
|
| 287 | 274 | return DateTime::createFromFormat('Y-m-d\TH:i:s\Z', $dateTime); |
| 288 | 275 | } |
| 289 | 276 | |
| 290 | - protected function assertUtcDateString(string $dateTime) |
|
| 291 | - { |
|
| 277 | + protected function assertUtcDateString(string $dateTime) { |
|
| 292 | 278 | $this->assertInstanceOf(DateTime::class, $this->parseUtc($dateTime)); |
| 293 | 279 | } |
| 294 | 280 | |
| 295 | - protected function assertInFuture(string $dateTime) |
|
| 296 | - { |
|
| 281 | + protected function assertInFuture(string $dateTime) { |
|
| 297 | 282 | $this->assertGreaterThan(new DateTime(), $this->parseUtc($dateTime)); |
| 298 | 283 | } |
| 299 | 284 | } |
@@ -8,8 +8,7 @@ |
||
| 8 | 8 | use Kitodo\Dlf\Tests\Functional\FunctionalTestCase; |
| 9 | 9 | use TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage; |
| 10 | 10 | |
| 11 | -class DocumentRepositoryTest extends FunctionalTestCase |
|
| 12 | -{ |
|
| 11 | +class DocumentRepositoryTest extends FunctionalTestCase { |
|
| 13 | 12 | /** |
| 14 | 13 | * @var DocumentRepository |
| 15 | 14 | */ |
@@ -14,8 +14,7 @@ discard block |
||
| 14 | 14 | use TYPO3\CMS\Extbase\Object\ObjectManager; |
| 15 | 15 | use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager; |
| 16 | 16 | |
| 17 | -class SolrIndexingTest extends FunctionalTestCase |
|
| 18 | -{ |
|
| 17 | +class SolrIndexingTest extends FunctionalTestCase { |
|
| 19 | 18 | /** @var PersistenceManager */ |
| 20 | 19 | protected $persistenceManager; |
| 21 | 20 | |
@@ -45,8 +44,7 @@ discard block |
||
| 45 | 44 | /** |
| 46 | 45 | * @test |
| 47 | 46 | */ |
| 48 | - public function canCreateCore() |
|
| 49 | - { |
|
| 47 | + public function canCreateCore() { |
|
| 50 | 48 | $coreName = uniqid('testCore'); |
| 51 | 49 | $solr = Solr::getInstance($coreName); |
| 52 | 50 | $this->assertNull($solr->core); |
@@ -61,8 +59,7 @@ discard block |
||
| 61 | 59 | /** |
| 62 | 60 | * @test |
| 63 | 61 | */ |
| 64 | - public function canIndexAndSearchDocument() |
|
| 65 | - { |
|
| 62 | + public function canIndexAndSearchDocument() { |
|
| 66 | 63 | $core = $this->createSolrCore(); |
| 67 | 64 | |
| 68 | 65 | $document = $this->documentRepository->findByUid(1001); |
@@ -49,8 +49,7 @@ discard block |
||
| 49 | 49 | * @property-read string $toplevelId This holds the toplevel structure's "@ID" (METS) or the manifest's "@id" (IIIF) |
| 50 | 50 | * @abstract |
| 51 | 51 | */ |
| 52 | -abstract class Doc |
|
| 53 | -{ |
|
| 52 | +abstract class Doc { |
|
| 54 | 53 | /** |
| 55 | 54 | * This holds the logger |
| 56 | 55 | * |
@@ -326,8 +325,7 @@ discard block |
||
| 326 | 325 | * |
| 327 | 326 | * @return void |
| 328 | 327 | */ |
| 329 | - public static function clearRegistry() |
|
| 330 | - { |
|
| 328 | + public static function clearRegistry() { |
|
| 331 | 329 | // Reset registry array. |
| 332 | 330 | self::$registry = []; |
| 333 | 331 | } |
@@ -505,8 +503,7 @@ discard block |
||
| 505 | 503 | * |
| 506 | 504 | * @return int The physical page number |
| 507 | 505 | */ |
| 508 | - public function getPhysicalPage($logicalPage) |
|
| 509 | - { |
|
| 506 | + public function getPhysicalPage($logicalPage) { |
|
| 510 | 507 | if ( |
| 511 | 508 | !empty($this->lastSearchedPhysicalPage['logicalPage']) |
| 512 | 509 | && $this->lastSearchedPhysicalPage['logicalPage'] == $logicalPage |
@@ -551,8 +548,7 @@ discard block |
||
| 551 | 548 | * |
| 552 | 549 | * @return string The OCR full text |
| 553 | 550 | */ |
| 554 | - protected function getFullTextFromXml($id) |
|
| 555 | - { |
|
| 551 | + protected function getFullTextFromXml($id) { |
|
| 556 | 552 | $fullText = ''; |
| 557 | 553 | // Load available text formats, ... |
| 558 | 554 | $this->loadFormats(); |
@@ -614,8 +610,7 @@ discard block |
||
| 614 | 610 | * |
| 615 | 611 | * @return string The format of the OCR full text |
| 616 | 612 | */ |
| 617 | - private function getTextFormat($fileContent) |
|
| 618 | - { |
|
| 613 | + private function getTextFormat($fileContent) { |
|
| 619 | 614 | $xml = Helper::getXmlFileAsString($fileContent); |
| 620 | 615 | |
| 621 | 616 | if ($xml !== false) { |
@@ -638,8 +633,7 @@ discard block |
||
| 638 | 633 | * |
| 639 | 634 | * @return string The title of the document itself or a parent document |
| 640 | 635 | */ |
| 641 | - public static function getTitle($uid, $recursive = false) |
|
| 642 | - { |
|
| 636 | + public static function getTitle($uid, $recursive = false) { |
|
| 643 | 637 | $title = ''; |
| 644 | 638 | // Sanitize input. |
| 645 | 639 | $uid = max(intval($uid), 0); |
@@ -691,8 +685,7 @@ discard block |
||
| 691 | 685 | * |
| 692 | 686 | * @return array The logical structure node's / resource's parsed metadata array |
| 693 | 687 | */ |
| 694 | - public function getTitledata($cPid = 0) |
|
| 695 | - { |
|
| 688 | + public function getTitledata($cPid = 0) { |
|
| 696 | 689 | $titledata = $this->getMetadata($this->_getToplevelId(), $cPid); |
| 697 | 690 | // Add information from METS structural map to titledata array. |
| 698 | 691 | if ($this instanceof MetsDocument) { |
@@ -725,8 +718,7 @@ discard block |
||
| 725 | 718 | * @return int|bool: false if structure with $logId is not a child of this substructure, |
| 726 | 719 | * or the actual depth. |
| 727 | 720 | */ |
| 728 | - protected function getTreeDepth($structure, $depth, $logId) |
|
| 729 | - { |
|
| 721 | + protected function getTreeDepth($structure, $depth, $logId) { |
|
| 730 | 722 | foreach ($structure as $element) { |
| 731 | 723 | if ($element['id'] == $logId) { |
| 732 | 724 | return $depth; |
@@ -748,8 +740,7 @@ discard block |
||
| 748 | 740 | * @param string $logId: The id of the logical structure element whose depth is requested |
| 749 | 741 | * @return int|bool tree depth as integer or false if no element with $logId exists within the TOC. |
| 750 | 742 | */ |
| 751 | - public function getStructureDepth($logId) |
|
| 752 | - { |
|
| 743 | + public function getStructureDepth($logId) { |
|
| 753 | 744 | return $this->getTreeDepth($this->_getTableOfContents(), 1, $logId); |
| 754 | 745 | } |
| 755 | 746 | |
@@ -801,8 +792,7 @@ discard block |
||
| 801 | 792 | * |
| 802 | 793 | * @return bool true on success or false on failure |
| 803 | 794 | */ |
| 804 | - protected function load($location) |
|
| 805 | - { |
|
| 795 | + protected function load($location) { |
|
| 806 | 796 | // Load XML / JSON-LD file. |
| 807 | 797 | if (GeneralUtility::isValidUrl($location)) { |
| 808 | 798 | // the actual loading is format specific |
@@ -829,8 +819,7 @@ discard block |
||
| 829 | 819 | * |
| 830 | 820 | * @return void |
| 831 | 821 | */ |
| 832 | - protected function loadFormats() |
|
| 833 | - { |
|
| 822 | + protected function loadFormats() { |
|
| 834 | 823 | if (!$this->formatsLoaded) { |
| 835 | 824 | $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) |
| 836 | 825 | ->getQueryBuilderForTable('tx_dlf_formats'); |
@@ -870,8 +859,7 @@ discard block |
||
| 870 | 859 | * |
| 871 | 860 | * @return void |
| 872 | 861 | */ |
| 873 | - public function registerNamespaces(&$obj) |
|
| 874 | - { |
|
| 862 | + public function registerNamespaces(&$obj) { |
|
| 875 | 863 | // 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. |
| 876 | 864 | $this->loadFormats(); |
| 877 | 865 | // Do we have a \SimpleXMLElement or \DOMXPath object? |
@@ -896,8 +884,7 @@ discard block |
||
| 896 | 884 | * |
| 897 | 885 | * @return int The PID of the metadata definitions |
| 898 | 886 | */ |
| 899 | - protected function _getCPid() |
|
| 900 | - { |
|
| 887 | + protected function _getCPid() { |
|
| 901 | 888 | return $this->cPid; |
| 902 | 889 | } |
| 903 | 890 | |
@@ -908,8 +895,7 @@ discard block |
||
| 908 | 895 | * |
| 909 | 896 | * @return bool Are there any fulltext files available? |
| 910 | 897 | */ |
| 911 | - protected function _getHasFulltext() |
|
| 912 | - { |
|
| 898 | + protected function _getHasFulltext() { |
|
| 913 | 899 | $this->ensureHasFulltextIsSet(); |
| 914 | 900 | return $this->hasFulltext; |
| 915 | 901 | } |
@@ -921,8 +907,7 @@ discard block |
||
| 921 | 907 | * |
| 922 | 908 | * @return string The location of the document |
| 923 | 909 | */ |
| 924 | - protected function _getLocation() |
|
| 925 | - { |
|
| 910 | + protected function _getLocation() { |
|
| 926 | 911 | return $this->location; |
| 927 | 912 | } |
| 928 | 913 | |
@@ -944,8 +929,7 @@ discard block |
||
| 944 | 929 | * |
| 945 | 930 | * @return array Array of metadata with their corresponding logical structure node ID as key |
| 946 | 931 | */ |
| 947 | - protected function _getMetadataArray() |
|
| 948 | - { |
|
| 932 | + protected function _getMetadataArray() { |
|
| 949 | 933 | // Set metadata definitions' PID. |
| 950 | 934 | $cPid = ($this->cPid ? $this->cPid : $this->pid); |
| 951 | 935 | if (!$cPid) { |
@@ -970,8 +954,7 @@ discard block |
||
| 970 | 954 | * |
| 971 | 955 | * @return int The total number of pages and/or tracks |
| 972 | 956 | */ |
| 973 | - protected function _getNumPages() |
|
| 974 | - { |
|
| 957 | + protected function _getNumPages() { |
|
| 975 | 958 | $this->_getPhysicalStructure(); |
| 976 | 959 | return $this->numPages; |
| 977 | 960 | } |
@@ -983,8 +966,7 @@ discard block |
||
| 983 | 966 | * |
| 984 | 967 | * @return int The UID of the parent document or zero if not applicable |
| 985 | 968 | */ |
| 986 | - protected function _getParentId() |
|
| 987 | - { |
|
| 969 | + protected function _getParentId() { |
|
| 988 | 970 | return $this->parentId; |
| 989 | 971 | } |
| 990 | 972 | |
@@ -1007,8 +989,7 @@ discard block |
||
| 1007 | 989 | * |
| 1008 | 990 | * @return array Array of elements' type, label and file representations ordered by "@ID" attribute / Canvas order |
| 1009 | 991 | */ |
| 1010 | - protected function _getPhysicalStructureInfo() |
|
| 1011 | - { |
|
| 992 | + protected function _getPhysicalStructureInfo() { |
|
| 1012 | 993 | // Is there no physical structure array yet? |
| 1013 | 994 | if (!$this->physicalStructureLoaded) { |
| 1014 | 995 | // Build physical structure array. |
@@ -1024,8 +1005,7 @@ discard block |
||
| 1024 | 1005 | * |
| 1025 | 1006 | * @return int The PID of the document or zero if not in database |
| 1026 | 1007 | */ |
| 1027 | - protected function _getPid() |
|
| 1028 | - { |
|
| 1008 | + protected function _getPid() { |
|
| 1029 | 1009 | return $this->pid; |
| 1030 | 1010 | } |
| 1031 | 1011 | |
@@ -1036,8 +1016,7 @@ discard block |
||
| 1036 | 1016 | * |
| 1037 | 1017 | * @return bool Is the document instantiated successfully? |
| 1038 | 1018 | */ |
| 1039 | - protected function _getReady() |
|
| 1040 | - { |
|
| 1019 | + protected function _getReady() { |
|
| 1041 | 1020 | return $this->ready; |
| 1042 | 1021 | } |
| 1043 | 1022 | |
@@ -1048,8 +1027,7 @@ discard block |
||
| 1048 | 1027 | * |
| 1049 | 1028 | * @return mixed The METS file's / IIIF manifest's record identifier |
| 1050 | 1029 | */ |
| 1051 | - protected function _getRecordId() |
|
| 1052 | - { |
|
| 1030 | + protected function _getRecordId() { |
|
| 1053 | 1031 | return $this->recordId; |
| 1054 | 1032 | } |
| 1055 | 1033 | |
@@ -1060,8 +1038,7 @@ discard block |
||
| 1060 | 1038 | * |
| 1061 | 1039 | * @return int The UID of the root document or zero if not applicable |
| 1062 | 1040 | */ |
| 1063 | - protected function _getRootId() |
|
| 1064 | - { |
|
| 1041 | + protected function _getRootId() { |
|
| 1065 | 1042 | if (!$this->rootIdLoaded) { |
| 1066 | 1043 | if ($this->parentId) { |
| 1067 | 1044 | $parent = self::getInstance($this->parentId, ['storagePid' => $this->pid]); |
@@ -1091,8 +1068,7 @@ discard block |
||
| 1091 | 1068 | * |
| 1092 | 1069 | * @return array Array of structure nodes' id, label, type and physical page indexes/mptr / Canvas link with original hierarchy preserved |
| 1093 | 1070 | */ |
| 1094 | - protected function _getTableOfContents() |
|
| 1095 | - { |
|
| 1071 | + protected function _getTableOfContents() { |
|
| 1096 | 1072 | // Is there no logical structure array yet? |
| 1097 | 1073 | if (!$this->tableOfContentsLoaded) { |
| 1098 | 1074 | // Get all logical structures. |
@@ -1133,8 +1109,7 @@ discard block |
||
| 1133 | 1109 | * |
| 1134 | 1110 | * @return mixed The UID or the URL of the document |
| 1135 | 1111 | */ |
| 1136 | - protected function _getUid() |
|
| 1137 | - { |
|
| 1112 | + protected function _getUid() { |
|
| 1138 | 1113 | return $this->uid; |
| 1139 | 1114 | } |
| 1140 | 1115 | |
@@ -1147,8 +1122,7 @@ discard block |
||
| 1147 | 1122 | * |
| 1148 | 1123 | * @return void |
| 1149 | 1124 | */ |
| 1150 | - protected function _setCPid($value) |
|
| 1151 | - { |
|
| 1125 | + protected function _setCPid($value) { |
|
| 1152 | 1126 | $this->cPid = max(intval($value), 0); |
| 1153 | 1127 | } |
| 1154 | 1128 | |
@@ -1165,8 +1139,7 @@ discard block |
||
| 1165 | 1139 | * |
| 1166 | 1140 | * @return void |
| 1167 | 1141 | */ |
| 1168 | - protected function __construct($location, $pid, $preloadedDocument) |
|
| 1169 | - { |
|
| 1142 | + protected function __construct($location, $pid, $preloadedDocument) { |
|
| 1170 | 1143 | $this->setPreloadedDocument($preloadedDocument); |
| 1171 | 1144 | $this->init($location); |
| 1172 | 1145 | $this->establishRecordId($pid); |
@@ -1182,8 +1155,7 @@ discard block |
||
| 1182 | 1155 | * |
| 1183 | 1156 | * @return mixed Value of $this->$var |
| 1184 | 1157 | */ |
| 1185 | - public function __get($var) |
|
| 1186 | - { |
|
| 1158 | + public function __get($var) { |
|
| 1187 | 1159 | $method = '_get' . ucfirst($var); |
| 1188 | 1160 | if ( |
| 1189 | 1161 | !property_exists($this, $var) |
@@ -1205,8 +1177,7 @@ discard block |
||
| 1205 | 1177 | * |
| 1206 | 1178 | * @return bool true if variable is set and not empty, false otherwise |
| 1207 | 1179 | */ |
| 1208 | - public function __isset($var) |
|
| 1209 | - { |
|
| 1180 | + public function __isset($var) { |
|
| 1210 | 1181 | return !empty($this->__get($var)); |
| 1211 | 1182 | } |
| 1212 | 1183 | |
@@ -1220,8 +1191,7 @@ discard block |
||
| 1220 | 1191 | * |
| 1221 | 1192 | * @return void |
| 1222 | 1193 | */ |
| 1223 | - public function __set($var, $value) |
|
| 1224 | - { |
|
| 1194 | + public function __set($var, $value) { |
|
| 1225 | 1195 | $method = '_set' . ucfirst($var); |
| 1226 | 1196 | if ( |
| 1227 | 1197 | !property_exists($this, $var) |
@@ -1239,8 +1209,7 @@ discard block |
||
| 1239 | 1209 | * @param string $location |
| 1240 | 1210 | * @return Doc|false |
| 1241 | 1211 | */ |
| 1242 | - private static function getDocCache(string $location) |
|
| 1243 | - { |
|
| 1212 | + private static function getDocCache(string $location) { |
|
| 1244 | 1213 | $cacheIdentifier = md5($location); |
| 1245 | 1214 | $cache = GeneralUtility::makeInstance(CacheManager::class)->getCache('tx_dlf_doc'); |
| 1246 | 1215 | $cacheHit = $cache->get($cacheIdentifier); |
@@ -1255,8 +1224,7 @@ discard block |
||
| 1255 | 1224 | * @param Doc $doc |
| 1256 | 1225 | * @return void |
| 1257 | 1226 | */ |
| 1258 | - private static function setDocCache(string $location, Doc $doc) |
|
| 1259 | - { |
|
| 1227 | + private static function setDocCache(string $location, Doc $doc) { |
|
| 1260 | 1228 | $cacheIdentifier = md5($location); |
| 1261 | 1229 | $cache = GeneralUtility::makeInstance(CacheManager::class)->getCache('tx_dlf_doc'); |
| 1262 | 1230 | |