Completed
Push — master ( 9df6ee...5b7677 )
by
unknown
16s queued 13s
created
Classes/Common/Solr.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 
137 137
         // Get next available core name if none given.
138 138
         if (empty($core)) {
139
-            $core = 'dlfCore' . self::getNextCoreNumber();
139
+            $core = 'dlfCore'.self::getNextCoreNumber();
140 140
         }
141 141
         // Get Solr service instance.
142 142
         $solr = self::getInstance($core);
@@ -232,13 +232,13 @@  discard block
 block discarded – undo
232 232
                 ->execute();
233 233
 
234 234
             while ($resArray = $result->fetch()) {
235
-                $fields[] = $resArray['index_name'] . '_' . ($resArray['index_tokenized'] ? 't' : 'u') . ($resArray['index_stored'] ? 's' : 'u') . 'i';
235
+                $fields[] = $resArray['index_name'].'_'.($resArray['index_tokenized'] ? 't' : 'u').($resArray['index_stored'] ? 's' : 'u').'i';
236 236
             }
237 237
 
238 238
             // Check if queried field is valid.
239 239
             $splitQuery = explode(':', $query, 2);
240 240
             if (in_array($splitQuery[0], $fields)) {
241
-                $query = $splitQuery[0] . ':(' . self::escapeQuery(trim($splitQuery[1], '()')) . ')';
241
+                $query = $splitQuery[0].':('.self::escapeQuery(trim($splitQuery[1], '()')).')';
242 242
             } else {
243 243
                 $query = self::escapeQuery($query);
244 244
             }
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
     {
346 346
         $number = max(intval($number), 0);
347 347
         // Check if core already exists.
348
-        $solr = self::getInstance('dlfCore' . $number);
348
+        $solr = self::getInstance('dlfCore'.$number);
349 349
         if (!$solr->ready) {
350 350
             return $number;
351 351
         } else {
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
         // Set filter query to just get toplevel documents.
421 421
         $params['filterquery'][] = ['query' => 'toplevel:true'];
422 422
         // Set join query to get all documents with the same uids.
423
-        $params['query'] = '{!join from=uid to=uid}' . $params['query'];
423
+        $params['query'] = '{!join from=uid to=uid}'.$params['query'];
424 424
         // Perform search to determine the total number of toplevel hits and fetch the required rows.
425 425
         $selectQuery = $this->service->createSelect($params);
426 426
         $results = $this->service->select($selectQuery);
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
         // Set query.
478 478
         $parameters['query'] = $query;
479 479
         // Calculate cache identifier.
480
-        $cacheIdentifier = Helper::digest($this->core . print_r(array_merge($this->params, $parameters), true));
480
+        $cacheIdentifier = Helper::digest($this->core.print_r(array_merge($this->params, $parameters), true));
481 481
         $cache = GeneralUtility::makeInstance(CacheManager::class)->getCache('tx_dlf_solr');
482 482
         $resultSet = [];
483 483
         if (($entry = $cache->get($cacheIdentifier)) === false) {
@@ -608,12 +608,12 @@  discard block
 block discarded – undo
608 608
      */
609 609
     public function __get($var)
610 610
     {
611
-        $method = '_get' . ucfirst($var);
611
+        $method = '_get'.ucfirst($var);
612 612
         if (
613 613
             !property_exists($this, $var)
614 614
             || !method_exists($this, $method)
615 615
         ) {
616
-            $this->logger->warning('There is no getter function for property "' . $var . '"');
616
+            $this->logger->warning('There is no getter function for property "'.$var.'"');
617 617
             return;
618 618
         } else {
619 619
             return $this->$method();
@@ -646,12 +646,12 @@  discard block
 block discarded – undo
646 646
      */
647 647
     public function __set($var, $value)
648 648
     {
649
-        $method = '_set' . ucfirst($var);
649
+        $method = '_set'.ucfirst($var);
650 650
         if (
651 651
             !property_exists($this, $var)
652 652
             || !method_exists($this, $method)
653 653
         ) {
654
-            $this->logger->warning('There is no setter function for property "' . $var . '"');
654
+            $this->logger->warning('There is no setter function for property "'.$var.'"');
655 655
         } else {
656 656
             $this->$method($value);
657 657
         }
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
                     'scheme' => $this->config['scheme'],
689 689
                     'host' => $this->config['host'],
690 690
                     'port' => $this->config['port'],
691
-                    'path' => '/' . $this->config['path'],
691
+                    'path' => '/'.$this->config['path'],
692 692
                     'core' => $core,
693 693
                     'username' => $this->config['username'],
694 694
                     'password' => $this->config['password'],
Please login to merge, or discard this patch.
Braces   +22 added lines, -44 removed lines patch added patch discarded remove patch
@@ -37,8 +37,7 @@  discard block
 block discarded – undo
37 37
  * @property-read bool $ready Is the Solr service instantiated successfully?
38 38
  * @property-read \Solarium\Client $service This holds the Solr service object
39 39
  */
40
-class Solr implements LoggerAwareInterface
41
-{
40
+class Solr implements LoggerAwareInterface {
42 41
     use LoggerAwareTrait;
43 42
 
44 43
     /**
@@ -130,8 +129,7 @@  discard block
 block discarded – undo
130 129
      *
131 130
      * @return string The name of the new core
132 131
      */
133
-    public static function createCore($core = '')
134
-    {
132
+    public static function createCore($core = '') {
135 133
         $logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__);
136 134
 
137 135
         // Get next available core name if none given.
@@ -180,8 +178,7 @@  discard block
 block discarded – undo
180 178
      *
181 179
      * @return string The escaped query string
182 180
      */
183
-    public static function escapeQuery($query)
184
-    {
181
+    public static function escapeQuery($query) {
185 182
         $helper = GeneralUtility::makeInstance(\Solarium\Core\Query\Helper::class);
186 183
         // Escape query phrase or term.
187 184
         if (preg_match('/^".*"$/', $query)) {
@@ -204,8 +201,7 @@  discard block
 block discarded – undo
204 201
      *
205 202
      * @return string The escaped query string
206 203
      */
207
-    public static function escapeQueryKeepField($query, $pid)
208
-    {
204
+    public static function escapeQueryKeepField($query, $pid) {
209 205
         // Is there a field query?
210 206
         if (preg_match('/^[[:alnum:]]+_[tu][su]i:\(?.*\)?$/', $query)) {
211 207
             $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
@@ -255,8 +251,7 @@  discard block
 block discarded – undo
255 251
      *
256 252
      * @return array fields
257 253
      */
258
-    public static function getFields()
259
-    {
254
+    public static function getFields() {
260 255
         $conf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]);
261 256
 
262 257
         $fields = [];
@@ -298,8 +293,7 @@  discard block
 block discarded – undo
298 293
      *
299 294
      * @return \Kitodo\Dlf\Common\Solr Instance of this class
300 295
      */
301
-    public static function getInstance($core = null)
302
-    {
296
+    public static function getInstance($core = null) {
303 297
         $logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__);
304 298
 
305 299
         // Get core name if UID is given.
@@ -341,8 +335,7 @@  discard block
 block discarded – undo
341 335
      *
342 336
      * @return int First unused core number found
343 337
      */
344
-    public static function getNextCoreNumber($number = 0)
345
-    {
338
+    public static function getNextCoreNumber($number = 0) {
346 339
         $number = max(intval($number), 0);
347 340
         // Check if core already exists.
348 341
         $solr = self::getInstance('dlfCore' . $number);
@@ -360,8 +353,7 @@  discard block
 block discarded – undo
360 353
      *
361 354
      * @return void
362 355
      */
363
-    protected function loadSolrConnectionInfo()
364
-    {
356
+    protected function loadSolrConnectionInfo() {
365 357
         if (empty($this->config)) {
366 358
             $config = [];
367 359
             // Extract extension configuration.
@@ -399,8 +391,7 @@  discard block
 block discarded – undo
399 391
      *
400 392
      * @return \Kitodo\Dlf\Common\DocumentList The result list
401 393
      */
402
-    public function search()
403
-    {
394
+    public function search() {
404 395
         $toplevel = [];
405 396
         // Take over query parameters.
406 397
         $params = $this->params;
@@ -469,8 +460,7 @@  discard block
 block discarded – undo
469 460
      *
470 461
      * @return array The Apache Solr Documents that were fetched
471 462
      */
472
-    public function search_raw($query = '', $parameters = [])
473
-    {
463
+    public function search_raw($query = '', $parameters = []) {
474 464
         // Set additional query parameters.
475 465
         $parameters['start'] = 0;
476 466
         $parameters['rows'] = $this->limit;
@@ -502,8 +492,7 @@  discard block
 block discarded – undo
502 492
      *
503 493
      * @return string|null The core name of the current query endpoint or null if core admin endpoint
504 494
      */
505
-    protected function _getCore()
506
-    {
495
+    protected function _getCore() {
507 496
         return $this->core;
508 497
     }
509 498
 
@@ -514,8 +503,7 @@  discard block
 block discarded – undo
514 503
      *
515 504
      * @return int The max number of results
516 505
      */
517
-    protected function _getLimit()
518
-    {
506
+    protected function _getLimit() {
519 507
         return $this->limit;
520 508
     }
521 509
 
@@ -526,8 +514,7 @@  discard block
 block discarded – undo
526 514
      *
527 515
      * @return int Total number of hits for last search
528 516
      */
529
-    protected function _getNumberOfHits()
530
-    {
517
+    protected function _getNumberOfHits() {
531 518
         return $this->numberOfHits;
532 519
     }
533 520
 
@@ -538,8 +525,7 @@  discard block
 block discarded – undo
538 525
      *
539 526
      * @return bool Is the search instantiated successfully?
540 527
      */
541
-    protected function _getReady()
542
-    {
528
+    protected function _getReady() {
543 529
         return $this->ready;
544 530
     }
545 531
 
@@ -550,8 +536,7 @@  discard block
 block discarded – undo
550 536
      *
551 537
      * @return \Solarium\Client Apache Solr service object
552 538
      */
553
-    protected function _getService()
554
-    {
539
+    protected function _getService() {
555 540
         return $this->service;
556 541
     }
557 542
 
@@ -564,8 +549,7 @@  discard block
 block discarded – undo
564 549
      *
565 550
      * @return void
566 551
      */
567
-    protected function _setCPid($value)
568
-    {
552
+    protected function _setCPid($value) {
569 553
         $this->cPid = max(intval($value), 0);
570 554
     }
571 555
 
@@ -578,8 +562,7 @@  discard block
 block discarded – undo
578 562
      *
579 563
      * @return void
580 564
      */
581
-    protected function _setLimit($value)
582
-    {
565
+    protected function _setLimit($value) {
583 566
         $this->limit = max(intval($value), 0);
584 567
     }
585 568
 
@@ -592,8 +575,7 @@  discard block
 block discarded – undo
592 575
      *
593 576
      * @return void
594 577
      */
595
-    protected function _setParams(array $value)
596
-    {
578
+    protected function _setParams(array $value) {
597 579
         $this->params = $value;
598 580
     }
599 581
 
@@ -606,8 +588,7 @@  discard block
 block discarded – undo
606 588
      *
607 589
      * @return mixed Value of $this->$var
608 590
      */
609
-    public function __get($var)
610
-    {
591
+    public function __get($var) {
611 592
         $method = '_get' . ucfirst($var);
612 593
         if (
613 594
             !property_exists($this, $var)
@@ -629,8 +610,7 @@  discard block
 block discarded – undo
629 610
      *
630 611
      * @return bool true if variable is set and not empty, false otherwise
631 612
      */
632
-    public function __isset($var)
633
-    {
613
+    public function __isset($var) {
634 614
         return !empty($this->__get($var));
635 615
     }
636 616
 
@@ -644,8 +624,7 @@  discard block
 block discarded – undo
644 624
      *
645 625
      * @return void
646 626
      */
647
-    public function __set($var, $value)
648
-    {
627
+    public function __set($var, $value) {
649 628
         $method = '_set' . ucfirst($var);
650 629
         if (
651 630
             !property_exists($this, $var)
@@ -666,8 +645,7 @@  discard block
 block discarded – undo
666 645
      *
667 646
      * @return void
668 647
      */
669
-    protected function __construct($core)
670
-    {
648
+    protected function __construct($core) {
671 649
         // Get Solr connection parameters from configuration.
672 650
         $this->loadSolrConnectionInfo();
673 651
         // Configure connection adapter.
Please login to merge, or discard this patch.