Passed
Push — master ( dfa252...d4a8e6 )
by Darko
07:13
created
Blacklight/Releases.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
             ($start === 0 ? ' LIMIT '.$num : ' LIMIT '.$num.' OFFSET '.$start)
87 87
         );
88 88
 
89
-        Cache::remember(md5($qry.$page), config('nntmux.cache_expiry_medium'), function () use ($qry, $cat, $maxAge, $excludedCats, $groupName) {
89
+        Cache::remember(md5($qry.$page), config('nntmux.cache_expiry_medium'), function() use ($qry, $cat, $maxAge, $excludedCats, $groupName) {
90 90
             $sql = self::fromQuery($qry);
91 91
             if (\count($sql) > 0) {
92 92
                 $possibleRows = $this->getBrowseCount($cat, $maxAge, $excludedCats, $groupName);
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 				GROUP BY r.id
263 263
 				ORDER BY %s %s %s",
264 264
             $this->uSQL($userShows, 'videos_id'),
265
-            (! empty($excludedCats) ? ' AND r.categories_id NOT IN ('.implode(',', $excludedCats).')' : ''),
265
+            (!empty($excludedCats) ? ' AND r.categories_id NOT IN ('.implode(',', $excludedCats).')' : ''),
266 266
             NZB::NZB_ADDED,
267 267
             Category::TV_ROOT,
268 268
             Category::TV_OTHER,
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
             $orderBy[1],
273 273
             ($offset === false ? '' : (' LIMIT '.$limit.' OFFSET '.$offset))
274 274
         );
275
-        Cache::remember(md5($sql), config('nntmux.cache_expiry_long'), function () use ($sql) {
275
+        Cache::remember(md5($sql), config('nntmux.cache_expiry_long'), function() use ($sql) {
276 276
             return self::fromQuery($sql);
277 277
         });
278 278
     }
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
     {
327 327
         // Delete NZB from disk.
328 328
         $nzbPath = $nzb->NZBPath($identifiers['g']);
329
-        if (! empty($nzbPath)) {
329
+        if (!empty($nzbPath)) {
330 330
             File::delete($nzbPath);
331 331
         }
332 332
 
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
      */
367 367
     public function updateMulti($guids, $category, $grabs, $videoId, $episodeId, $anidbId, $imdbId)
368 368
     {
369
-        if (! \is_array($guids) || \count($guids) < 1) {
369
+        if (!\is_array($guids) || \count($guids) < 1) {
370 370
             return false;
371 371
         }
372 372
 
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
         $sql = '(1=2 ';
391 391
         foreach ($userQuery as $query) {
392 392
             $sql .= sprintf('OR (r.%s = %d', $type, $query->$type);
393
-            if (! empty($query->categories)) {
393
+            if (!empty($query->categories)) {
394 394
                 $catsArr = explode('|', $query->categories);
395 395
                 if (\count($catsArr) > 1) {
396 396
                     $sql .= sprintf(' AND r.categories_id IN (%s)', implode(',', $catsArr));
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
             $orderBy = $this->getBrowseOrder($orderBy);
432 432
         }
433 433
 
434
-        $searchFields = Arr::where($searchArr, static function ($value) {
434
+        $searchFields = Arr::where($searchArr, static function($value) {
435 435
             return $value !== -1;
436 436
         });
437 437
 
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
             $searchResult = $this->elasticSearch->indexSearch($phrases, $limit);
442 442
         } else {
443 443
             $searchResult = $this->manticoreSearch->searchIndexes('releases_rt', '', [], $searchFields);
444
-            if (! empty($searchResult)) {
444
+            if (!empty($searchResult)) {
445 445
                 $searchResult = Arr::wrap(Arr::get($searchResult, 'id'));
446 446
             }
447 447
         }
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
             $limit,
506 506
             $offset
507 507
         );
508
-        Cache::remember(md5($sql), config('nntmux.cache_expiry_medium'), function () use ($sql, $baseSql) {
508
+        Cache::remember(md5($sql), config('nntmux.cache_expiry_medium'), function() use ($sql, $baseSql) {
509 509
             $releases = self::fromQuery($sql);
510 510
             if ($releases->isNotEmpty()) {
511 511
                 $releases[0]->_totalrows = $this->getPagerCount($baseSql);
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
                 $searchResult = $this->elasticSearch->indexSearchApi($searchName, $limit);
526 526
             } else {
527 527
                 $searchResult = $this->manticoreSearch->searchIndexes('releases_rt', $searchName, ['searchname']);
528
-                if (! empty($searchResult)) {
528
+                if (!empty($searchResult)) {
529 529
                     $searchResult = Arr::wrap(Arr::get($searchResult, 'id'));
530 530
                 }
531 531
             }
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
             ((int) $groupName !== -1 ? sprintf(' AND r.groups_id = %d ', UsenetGroup::getIDByName($groupName)) : ''),
542 542
             $catQuery,
543 543
             (\count($excludedCats) > 0 ? ' AND r.categories_id NOT IN ('.implode(',', $excludedCats).')' : ''),
544
-            (! empty($searchResult) ? 'AND r.id IN ('.implode(',', $searchResult).')' : ''),
544
+            (!empty($searchResult) ? 'AND r.id IN ('.implode(',', $searchResult).')' : ''),
545 545
             ($minSize > 0 ? sprintf('AND r.size >= %d', $minSize) : '')
546 546
         );
547 547
         $baseSql = sprintf(
@@ -572,8 +572,8 @@  discard block
 block discarded – undo
572 572
             $offset
573 573
         );
574 574
 
575
-        Cache::remember(md5($sql), config('nntmux.cache_expiry_medium'), function () use ($sql, $baseSql, $searchName, $searchResult) {
576
-            if ($searchName !== -1 && ! empty($searchResult)) {
575
+        Cache::remember(md5($sql), config('nntmux.cache_expiry_medium'), function() use ($sql, $baseSql, $searchName, $searchResult) {
576
+            if ($searchName !== -1 && !empty($searchResult)) {
577 577
                 $releases = self::fromQuery($sql);
578 578
             } elseif ($searchName !== -1 && empty($searchResult)) {
579 579
                 $releases = collect();
@@ -624,11 +624,11 @@  discard block
 block discarded – undo
624 624
             $show = self::fromQuery($showQry);
625 625
 
626 626
             if ($show->isNotEmpty()) {
627
-                if ((! empty($episode) && ! empty($series)) && $show[0]->episodes !== '') {
627
+                if ((!empty($episode) && !empty($series)) && $show[0]->episodes !== '') {
628 628
                     $showSql .= ' AND r.tv_episodes_id IN ('.$show[0]->episodes.') AND tve.series = '.$series;
629
-                } elseif (! empty($episode) && $show[0]->episodes !== '') {
629
+                } elseif (!empty($episode) && $show[0]->episodes !== '') {
630 630
                     $showSql = sprintf('AND r.tv_episodes_id IN (%s)', $show[0]->episodes);
631
-                } elseif (! empty($series) && empty($episode)) {
631
+                } elseif (!empty($series) && empty($episode)) {
632 632
                     // If $series is set but episode is not, return Season Packs and Episodes
633 633
                     $showSql .= ' AND r.tv_episodes_id IN ('.$show[0]->episodes.') AND tve.series = '.$series;
634 634
                 }
@@ -642,26 +642,26 @@  discard block
 block discarded – undo
642 642
         }
643 643
 
644 644
         // If $name is set it is a fallback search, add available SxxExx/airdate info to the query
645
-        if (! empty($name) && $showSql === '') {
646
-            if (! empty($series) && (int) $series < 1900) {
645
+        if (!empty($name) && $showSql === '') {
646
+            if (!empty($series) && (int) $series < 1900) {
647 647
                 $name .= sprintf(' S%s', str_pad($series, 2, '0', STR_PAD_LEFT));
648
-                if (! empty($episode) && ! str_contains($episode, '/')) {
648
+                if (!empty($episode) && !str_contains($episode, '/')) {
649 649
                     $name .= sprintf('E%s', str_pad($episode, 2, '0', STR_PAD_LEFT));
650 650
                 }
651 651
                 // If season is not empty but episode is, add a wildcard to the search
652 652
                 if (empty($episode)) {
653 653
                     $name .= '*';
654 654
                 }
655
-            } elseif (! empty($airDate)) {
655
+            } elseif (!empty($airDate)) {
656 656
                 $name .= sprintf(' %s', str_replace(['/', '-', '.', '_'], ' ', $airDate));
657 657
             }
658 658
         }
659
-        if (! empty($name)) {
659
+        if (!empty($name)) {
660 660
             if (config('nntmux.elasticsearch_enabled') === true) {
661 661
                 $searchResult = $this->elasticSearch->indexSearchTMA($name, $limit);
662 662
             } else {
663 663
                 $searchResult = $this->manticoreSearch->searchIndexes('releases_rt', $name, ['searchname']);
664
-                if (! empty($searchResult)) {
664
+                if (!empty($searchResult)) {
665 665
                     $searchResult = Arr::wrap(Arr::get($searchResult, 'id'));
666 666
                 }
667 667
             }
@@ -677,11 +677,11 @@  discard block
 block discarded – undo
677 677
             NZB::NZB_ADDED,
678 678
             $this->showPasswords(),
679 679
             $showSql,
680
-            (! empty($name) && ! empty($searchResult)) ? 'AND r.id IN ('.implode(',', $searchResult).')' : '',
680
+            (!empty($name) && !empty($searchResult)) ? 'AND r.id IN ('.implode(',', $searchResult).')' : '',
681 681
             Category::getCategorySearch($cat),
682 682
             $maxAge > 0 ? sprintf('AND r.postdate > NOW() - INTERVAL %d DAY', $maxAge) : '',
683 683
             $minSize > 0 ? sprintf('AND r.size >= %d', $minSize) : '',
684
-            ! empty($excludedCategories) ? sprintf('AND r.categories_id NOT IN('.implode(',', $excludedCategories).')') : ''
684
+            !empty($excludedCategories) ? sprintf('AND r.categories_id NOT IN('.implode(',', $excludedCategories).')') : ''
685 685
         );
686 686
         $baseSql = sprintf(
687 687
             "SELECT r.searchname, r.guid, r.postdate, r.groups_id, r.categories_id, r.size, r.totalpart, r.fromname, r.passwordstatus, r.grabs, r.comments, r.adddate, r.videos_id, r.tv_episodes_id, r.haspreview, r.jpgstatus,
@@ -714,8 +714,8 @@  discard block
 block discarded – undo
714 714
             $offset
715 715
         );
716 716
 
717
-        Cache::remember(md5($sql), config('nntmux.cache_expiry_medium'), function () use ($sql, $baseSql, $name, $searchResult) {
718
-            $releases = ((! empty($name) && ! empty($searchResult)) || empty($name)) ? self::fromQuery($sql) : [];
717
+        Cache::remember(md5($sql), config('nntmux.cache_expiry_medium'), function() use ($sql, $baseSql, $name, $searchResult) {
718
+            $releases = ((!empty($name) && !empty($searchResult)) || empty($name)) ? self::fromQuery($sql) : [];
719 719
             if (count($releases) !== 0 && $releases->isNotEmpty()) {
720 720
                 $releases[0]->_totalrows = $this->getPagerCount(
721 721
                     preg_replace('#LEFT(\s+OUTER)?\s+JOIN\s+(?!tv_episodes)\s+.*ON.*=.*\n#i', ' ', $baseSql)
@@ -759,11 +759,11 @@  discard block
 block discarded – undo
759 759
 
760 760
             $show = self::fromQuery($showQry);
761 761
             if ($show->isNotEmpty()) {
762
-                if ((! empty($episode) && ! empty($series)) && $show[0]->episodes !== '') {
762
+                if ((!empty($episode) && !empty($series)) && $show[0]->episodes !== '') {
763 763
                     $showSql .= ' AND r.tv_episodes_id IN ('.$show[0]->episodes.') AND tve.series = '.$series;
764
-                } elseif (! empty($episode) && $show[0]->episodes !== '') {
764
+                } elseif (!empty($episode) && $show[0]->episodes !== '') {
765 765
                     $showSql = sprintf('AND r.tv_episodes_id IN (%s)', $show[0]->episodes);
766
-                } elseif (! empty($series) && empty($episode)) {
766
+                } elseif (!empty($series) && empty($episode)) {
767 767
                     // If $series is set but episode is not, return Season Packs and Episodes
768 768
                     $showSql .= ' AND r.tv_episodes_id IN ('.$show[0]->episodes.') AND tve.series = '.$series;
769 769
                 }
@@ -776,26 +776,26 @@  discard block
 block discarded – undo
776 776
             }
777 777
         }
778 778
         // If $name is set it is a fallback search, add available SxxExx/airdate info to the query
779
-        if (! empty($name) && $showSql === '') {
780
-            if (! empty($series) && (int) $series < 1900) {
779
+        if (!empty($name) && $showSql === '') {
780
+            if (!empty($series) && (int) $series < 1900) {
781 781
                 $name .= sprintf(' S%s', str_pad($series, 2, '0', STR_PAD_LEFT));
782
-                if (! empty($episode) && ! str_contains($episode, '/')) {
782
+                if (!empty($episode) && !str_contains($episode, '/')) {
783 783
                     $name .= sprintf('E%s', str_pad($episode, 2, '0', STR_PAD_LEFT));
784 784
                 }
785 785
                 // If season is not empty but episode is, add a wildcard to the search
786 786
                 if (empty($episode)) {
787 787
                     $name .= '*';
788 788
                 }
789
-            } elseif (! empty($airDate)) {
789
+            } elseif (!empty($airDate)) {
790 790
                 $name .= sprintf(' %s', str_replace(['/', '-', '.', '_'], ' ', $airDate));
791 791
             }
792 792
         }
793
-        if (! empty($name)) {
793
+        if (!empty($name)) {
794 794
             if (config('nntmux.elasticsearch_enabled') === true) {
795 795
                 $searchResult = $this->elasticSearch->indexSearchTMA($name, $limit);
796 796
             } else {
797 797
                 $searchResult = $this->manticoreSearch->searchIndexes('releases_rt', $name, ['searchname']);
798
-                if (! empty($searchResult)) {
798
+                if (!empty($searchResult)) {
799 799
                     $searchResult = Arr::wrap(Arr::get($searchResult, 'id'));
800 800
                 }
801 801
             }
@@ -811,11 +811,11 @@  discard block
 block discarded – undo
811 811
             NZB::NZB_ADDED,
812 812
             $this->showPasswords(),
813 813
             $showSql,
814
-            (! empty($searchResult) ? 'AND r.id IN ('.implode(',', $searchResult).')' : ''),
814
+            (!empty($searchResult) ? 'AND r.id IN ('.implode(',', $searchResult).')' : ''),
815 815
             Category::getCategorySearch($cat),
816 816
             ($maxAge > 0 ? sprintf('AND r.postdate > NOW() - INTERVAL %d DAY', $maxAge) : ''),
817 817
             ($minSize > 0 ? sprintf('AND r.size >= %d', $minSize) : ''),
818
-            ! empty($excludedCategories) ? sprintf('AND r.categories_id NOT IN('.implode(',', $excludedCategories).')') : ''
818
+            !empty($excludedCategories) ? sprintf('AND r.categories_id NOT IN('.implode(',', $excludedCategories).')') : ''
819 819
         );
820 820
         $baseSql = sprintf(
821 821
             "SELECT r.searchname, r.guid, r.postdate, r.groups_id, r.categories_id, r.size, r.totalpart, r.fromname, r.passwordstatus, r.grabs, r.comments, r.adddate, r.tv_episodes_id, r.haspreview, r.jpgstatus,
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
             $offset
843 843
         );
844 844
 
845
-        Cache::remember(md5($sql), config('nntmux.cache_expiry_medium'), function () use ($sql, $baseSql) {
845
+        Cache::remember(md5($sql), config('nntmux.cache_expiry_medium'), function() use ($sql, $baseSql) {
846 846
             $releases = self::fromQuery($sql);
847 847
             if ($releases->isNotEmpty()) {
848 848
                 $releases[0]->_totalrows = $this->getPagerCount(
@@ -859,12 +859,12 @@  discard block
 block discarded – undo
859 859
      */
860 860
     public function animeSearch($aniDbID, int $offset = 0, int $limit = 100, string $name = '', array $cat = [-1], int $maxAge = -1, array $excludedCategories = [])
861 861
     {
862
-        if (! empty($name)) {
862
+        if (!empty($name)) {
863 863
             if (config('nntmux.elasticsearch_enabled') === true) {
864 864
                 $searchResult = $this->elasticSearch->indexSearchTMA($name, $limit);
865 865
             } else {
866 866
                 $searchResult = $this->manticoreSearch->searchIndexes('releases_rt', $name, ['searchname']);
867
-                if (! empty($searchResult)) {
867
+                if (!empty($searchResult)) {
868 868
                     $searchResult = Arr::wrap(Arr::get($searchResult, 'id'));
869 869
                 }
870 870
             }
@@ -881,8 +881,8 @@  discard block
 block discarded – undo
881 881
             $this->showPasswords(),
882 882
             NZB::NZB_ADDED,
883 883
             ($aniDbID > -1 ? sprintf(' AND r.anidbid = %d ', $aniDbID) : ''),
884
-            (! empty($searchResult) ? 'AND r.id IN ('.implode(',', $searchResult).')' : ''),
885
-            ! empty($excludedCategories) ? sprintf('AND r.categories_id NOT IN('.implode(',', $excludedCategories).')') : '',
884
+            (!empty($searchResult) ? 'AND r.id IN ('.implode(',', $searchResult).')' : ''),
885
+            !empty($excludedCategories) ? sprintf('AND r.categories_id NOT IN('.implode(',', $excludedCategories).')') : '',
886 886
             Category::getCategorySearch($cat),
887 887
             ($maxAge > 0 ? sprintf(' AND r.postdate > NOW() - INTERVAL %d DAY ', $maxAge) : '')
888 888
         );
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
             $offset
909 909
         );
910 910
 
911
-        Cache::remember(md5($sql), config('nntmux.cache_expiry_medium'), function () use ($sql, $baseSql) {
911
+        Cache::remember(md5($sql), config('nntmux.cache_expiry_medium'), function() use ($sql, $baseSql) {
912 912
             $releases = self::fromQuery($sql);
913 913
             if ($releases->isNotEmpty()) {
914 914
                 $releases[0]->_totalrows = $this->getPagerCount($baseSql);
@@ -923,12 +923,12 @@  discard block
 block discarded – undo
923 923
      */
924 924
     public function moviesSearch(int $imDbId = -1, int $tmDbId = -1, int $traktId = -1, int $offset = 0, int $limit = 100, string $name = '', array $cat = [-1], int $maxAge = -1, int $minSize = 0, array $excludedCategories = [])
925 925
     {
926
-        if (! empty($name)) {
926
+        if (!empty($name)) {
927 927
             if (config('nntmux.elasticsearch_enabled') === true) {
928 928
                 $searchResult = $this->elasticSearch->indexSearchTMA($name, $limit);
929 929
             } else {
930 930
                 $searchResult = $this->manticoreSearch->searchIndexes('releases_rt', $name, ['searchname']);
931
-                if (! empty($searchResult)) {
931
+                if (!empty($searchResult)) {
932 932
                     $searchResult = Arr::wrap(Arr::get($searchResult, 'id'));
933 933
                 }
934 934
             }
@@ -945,11 +945,11 @@  discard block
 block discarded – undo
945 945
 			%s %s %s %s %s %s %s',
946 946
             NZB::NZB_ADDED,
947 947
             $this->showPasswords(),
948
-            (! empty($searchResult) ? 'AND r.id IN ('.implode(',', $searchResult).')' : ''),
948
+            (!empty($searchResult) ? 'AND r.id IN ('.implode(',', $searchResult).')' : ''),
949 949
             ($imDbId !== -1 && is_numeric($imDbId)) ? sprintf(' AND m.imdbid = \'%s\' ', $imDbId) : '',
950 950
             ($tmDbId !== -1 && is_numeric($tmDbId)) ? sprintf(' AND m.tmdbid = %d ', $tmDbId) : '',
951 951
             ($traktId !== -1 && is_numeric($traktId)) ? sprintf(' AND m.traktid = %d ', $traktId) : '',
952
-            ! empty($excludedCategories) ? sprintf('AND r.categories_id NOT IN('.implode(',', $excludedCategories).')') : '',
952
+            !empty($excludedCategories) ? sprintf('AND r.categories_id NOT IN('.implode(',', $excludedCategories).')') : '',
953 953
             Category::getCategorySearch($cat),
954 954
             $maxAge > 0 ? sprintf(' AND r.postdate > NOW() - INTERVAL %d DAY ', $maxAge) : '',
955 955
             $minSize > 0 ? sprintf('AND r.size >= %d', $minSize) : ''
@@ -977,7 +977,7 @@  discard block
 block discarded – undo
977 977
             $offset
978 978
         );
979 979
 
980
-        Cache::remember(md5($sql), config('nntmux.cache_expiry_medium'), function () use ($sql, $baseSql) {
980
+        Cache::remember(md5($sql), config('nntmux.cache_expiry_medium'), function() use ($sql, $baseSql) {
981 981
             $releases = self::fromQuery($sql);
982 982
             if ($releases->isNotEmpty()) {
983 983
                 $releases[0]->_totalrows = $this->getPagerCount($baseSql);
@@ -1001,7 +1001,7 @@  discard block
 block discarded – undo
1001 1001
             }
1002 1002
 
1003 1003
             $results = $this->search(['searchname' => getSimilarName($name)], -1, '', '', -1, -1, 0, config('nntmux.items_per_page'), '', -1, $excludedCats, 'basic', [$parentCat]);
1004
-            if (! $results) {
1004
+            if (!$results) {
1005 1005
                 return $ret;
1006 1006
             }
1007 1007
 
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
             (int) config('nntmux.max_pager_results')
1031 1031
         );
1032 1032
 
1033
-        Cache::remember(md5($sql), config('nntmux.cache_expiry_short'), function () use ($sql) {
1033
+        Cache::remember(md5($sql), config('nntmux.cache_expiry_short'), function() use ($sql) {
1034 1034
             $count = self::fromQuery($sql);
1035 1035
 
1036 1036
             return $count[0]->count ?? 0;
Please login to merge, or discard this patch.