Passed
Push — master ( 7d851f...e6959b )
by Robin
15:52 queued 12s
created
lib/private/FullTextSearch/Model/IndexDocument.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -389,7 +389,7 @@
 block discarded – undo
389 389
 		foreach ($ak as $source) {
390 390
 			$tags = $this->subTags[$source];
391 391
 			foreach ($tags as $tag) {
392
-				$subTags[] = $source . '_' . $tag;
392
+				$subTags[] = $source.'_'.$tag;
393 393
 			}
394 394
 		}
395 395
 
Please login to merge, or discard this patch.
Indentation   +934 added lines, -934 removed lines patch added patch discarded remove patch
@@ -47,940 +47,940 @@
 block discarded – undo
47 47
  * @package OC\FullTextSearch\Model
48 48
  */
49 49
 class IndexDocument implements IIndexDocument, JsonSerializable {
50
-	/** @var string */
51
-	protected $id = '';
50
+    /** @var string */
51
+    protected $id = '';
52 52
 
53
-	/** @var string */
54
-	protected $providerId = '';
53
+    /** @var string */
54
+    protected $providerId = '';
55 55
 
56
-	/** @var DocumentAccess */
57
-	protected $access;
58
-
59
-	/** @var IIndex */
60
-	protected $index;
61
-
62
-	/** @var int */
63
-	protected $modifiedTime = 0;
64
-
65
-	/** @var string */
66
-	protected $source = '';
67
-
68
-	/** @var array */
69
-	protected $tags = [];
70
-
71
-	/** @var array */
72
-	protected $metaTags = [];
73
-
74
-	/** @var array */
75
-	protected $subTags = [];
76
-
77
-	/** @var string */
78
-	protected $title = '';
79
-
80
-	/** @var string */
81
-	protected $content = '';
82
-
83
-	/** @var string */
84
-	protected $hash = '';
85
-
86
-	/** @var array */
87
-	protected $parts = [];
88
-
89
-	/** @var string */
90
-	protected $link = '';
91
-
92
-	/** @var array */
93
-	protected $more = [];
94
-
95
-	/** @var array */
96
-	protected $excerpts = [];
97
-
98
-	/** @var string */
99
-	protected $score = '';
100
-
101
-	/** @var array */
102
-	protected $info = [];
103
-
104
-	/** @var int */
105
-	protected $contentEncoded = 0;
106
-
107
-
108
-	/**
109
-	 * IIndexDocument constructor.
110
-	 *
111
-	 * On creation, we assure the uniqueness of the object using the providerId
112
-	 * and the Id of the original document.
113
-	 *
114
-	 * @since 15.0.0
115
-	 *
116
-	 * @param string $providerId
117
-	 * @param string $documentId
118
-	 */
119
-	public function __construct(string $providerId, string $documentId) {
120
-		$this->providerId = $providerId;
121
-		$this->id = $documentId;
122
-	}
123
-
124
-
125
-	/**
126
-	 * Returns the Id of the original document.
127
-	 *
128
-	 * @since 15.0.0
129
-	 *
130
-	 * @return string
131
-	 */
132
-	final public function getId(): string {
133
-		return $this->id;
134
-	}
135
-
136
-
137
-	/**
138
-	 * Returns the Id of the provider.
139
-	 *
140
-	 * @since 15.0.0
141
-	 *
142
-	 * @return string
143
-	 */
144
-	final public function getProviderId(): string {
145
-		return $this->providerId;
146
-	}
147
-
148
-
149
-	/**
150
-	 * Set the Index related to the IIndexDocument.
151
-	 *
152
-	 * @see IIndex
153
-	 *
154
-	 * @since 15.0.0
155
-	 *
156
-	 * @param IIndex $index
157
-	 *
158
-	 * @return IIndexDocument
159
-	 */
160
-	final public function setIndex(IIndex $index): IIndexDocument {
161
-		$this->index = $index;
162
-
163
-		return $this;
164
-	}
165
-
166
-	/**
167
-	 * Get the Index.
168
-	 *
169
-	 * @since 15.0.0
170
-	 *
171
-	 * @return IIndex
172
-	 */
173
-	final public function getIndex(): IIndex {
174
-		return $this->index;
175
-	}
176
-
177
-	/**
178
-	 * return if Index is defined.
179
-	 *
180
-	 * @since 16.0.0
181
-	 *
182
-	 * @return bool
183
-	 */
184
-	final public function hasIndex(): bool {
185
-		return ($this->index !== null);
186
-	}
187
-
188
-
189
-	/**
190
-	 * Set the modified time of the original document.
191
-	 *
192
-	 * @since 15.0.0
193
-	 *
194
-	 * @param int $modifiedTime
195
-	 *
196
-	 * @return IIndexDocument
197
-	 */
198
-	final public function setModifiedTime(int $modifiedTime): IIndexDocument {
199
-		$this->modifiedTime = $modifiedTime;
200
-
201
-		return $this;
202
-	}
203
-
204
-	/**
205
-	 * Get the modified time of the original document.
206
-	 *
207
-	 * @since 15.0.0
208
-	 *
209
-	 * @return int
210
-	 */
211
-	final public function getModifiedTime(): int {
212
-		return $this->modifiedTime;
213
-	}
214
-
215
-	/**
216
-	 * Check if the original document of the IIndexDocument is older than $time.
217
-	 *
218
-	 * @since 15.0.0
219
-	 *
220
-	 * @param int $time
221
-	 *
222
-	 * @return bool
223
-	 */
224
-	final public function isOlderThan(int $time): bool {
225
-		return ($this->modifiedTime < $time);
226
-	}
227
-
228
-
229
-	/**
230
-	 * Set the read rights of the original document using a IDocumentAccess.
231
-	 *
232
-	 * @see IDocumentAccess
233
-	 *
234
-	 * @since 15.0.0
235
-	 *
236
-	 * @param IDocumentAccess $access
237
-	 *
238
-	 * @return $this
239
-	 */
240
-	final public function setAccess(IDocumentAccess $access): IIndexDocument {
241
-		$this->access = $access;
242
-
243
-		return $this;
244
-	}
245
-
246
-	/**
247
-	 * Get the IDocumentAccess related to the original document.
248
-	 *
249
-	 * @since 15.0.0
250
-	 *
251
-	 * @return IDocumentAccess
252
-	 */
253
-	final public function getAccess(): IDocumentAccess {
254
-		return $this->access;
255
-	}
256
-
257
-
258
-	/**
259
-	 * Add a tag to the list.
260
-	 *
261
-	 * @since 15.0.0
262
-	 *
263
-	 * @param string $tag
264
-	 *
265
-	 * @return IIndexDocument
266
-	 */
267
-	final public function addTag(string $tag): IIndexDocument {
268
-		$this->tags[] = $tag;
269
-
270
-		return $this;
271
-	}
272
-
273
-	/**
274
-	 * Set the list of tags assigned to the original document.
275
-	 *
276
-	 * @since 15.0.0
277
-	 *
278
-	 * @param array $tags
279
-	 *
280
-	 * @return IIndexDocument
281
-	 */
282
-	final public function setTags(array $tags): IIndexDocument {
283
-		$this->tags = $tags;
284
-
285
-		return $this;
286
-	}
287
-
288
-	/**
289
-	 * Get the list of tags assigned to the original document.
290
-	 *
291
-	 * @since 15.0.0
292
-	 *
293
-	 * @return array
294
-	 */
295
-	final public function getTags(): array {
296
-		return $this->tags;
297
-	}
298
-
299
-
300
-	/**
301
-	 * Add a meta tag to the list.
302
-	 *
303
-	 * @since 15.0.0
304
-	 *
305
-	 * @param string $tag
306
-	 *
307
-	 * @return IIndexDocument
308
-	 */
309
-	final public function addMetaTag(string $tag): IIndexDocument {
310
-		$this->metaTags[] = $tag;
311
-
312
-		return $this;
313
-	}
314
-
315
-	/**
316
-	 * Set the list of meta tags assigned to the original document.
317
-	 *
318
-	 * @since 15.0.0
319
-	 *
320
-	 * @param array $tags
321
-	 *
322
-	 * @return IIndexDocument
323
-	 */
324
-	final public function setMetaTags(array $tags): IIndexDocument {
325
-		$this->metaTags = $tags;
326
-
327
-		return $this;
328
-	}
329
-
330
-	/**
331
-	 * Get the list of meta tags assigned to the original document.
332
-	 *
333
-	 * @since 15.0.0
334
-	 *
335
-	 * @return array
336
-	 */
337
-	final public function getMetaTags(): array {
338
-		return $this->metaTags;
339
-	}
340
-
341
-
342
-	/**
343
-	 * Add a sub tag to the list.
344
-	 *
345
-	 * @since 15.0.0
346
-	 *
347
-	 * @param string $sub
348
-	 * @param string $tag
349
-	 *
350
-	 * @return IIndexDocument
351
-	 */
352
-	final public function addSubTag(string $sub, string $tag): IIndexDocument {
353
-		if (!array_key_exists($sub, $this->subTags)) {
354
-			$this->subTags[$sub] = [];
355
-		}
356
-
357
-		$this->subTags[$sub][] = $tag;
358
-
359
-		return $this;
360
-	}
361
-
362
-
363
-	/**
364
-	 * Set the list of sub tags assigned to the original document.
365
-	 *
366
-	 * @since 15.0.0
367
-	 *
368
-	 * @param array $tags
369
-	 *
370
-	 * @return IIndexDocument
371
-	 */
372
-	final public function setSubTags(array $tags): IIndexDocument {
373
-		$this->subTags = $tags;
374
-
375
-		return $this;
376
-	}
377
-
378
-	/**
379
-	 * Get the list of sub tags assigned to the original document.
380
-	 * If $formatted is true, the result will be formatted in a one
381
-	 * dimensional array.
382
-	 *
383
-	 * @since 15.0.0
384
-	 *
385
-	 * @param bool $formatted
386
-	 *
387
-	 * @return array
388
-	 */
389
-	final public function getSubTags(bool $formatted = false): array {
390
-		if ($formatted === false) {
391
-			return $this->subTags;
392
-		}
393
-
394
-		$subTags = [];
395
-		$ak = array_keys($this->subTags);
396
-		foreach ($ak as $source) {
397
-			$tags = $this->subTags[$source];
398
-			foreach ($tags as $tag) {
399
-				$subTags[] = $source . '_' . $tag;
400
-			}
401
-		}
402
-
403
-		return $subTags;
404
-	}
405
-
406
-
407
-	/**
408
-	 * Set the source of the original document.
409
-	 *
410
-	 * @since 15.0.0
411
-	 *
412
-	 * @param string $source
413
-	 *
414
-	 * @return IIndexDocument
415
-	 */
416
-	final public function setSource(string $source): IIndexDocument {
417
-		$this->source = $source;
418
-
419
-		return $this;
420
-	}
421
-
422
-	/**
423
-	 * Get the source of the original document.
424
-	 *
425
-	 * @since 15.0.0
426
-	 *
427
-	 * @return string
428
-	 */
429
-	final public function getSource(): string {
430
-		return $this->source;
431
-	}
432
-
433
-
434
-	/**
435
-	 * Set the title of the original document.
436
-	 *
437
-	 * @since 15.0.0
438
-	 *
439
-	 * @param string $title
440
-	 *
441
-	 * @return IIndexDocument
442
-	 */
443
-	final public function setTitle(string $title): IIndexDocument {
444
-		$this->title = $title;
445
-
446
-		return $this;
447
-	}
448
-
449
-	/**
450
-	 * Get the title of the original document.
451
-	 *
452
-	 * @since 15.0.0
453
-	 *
454
-	 * @return string
455
-	 */
456
-	final public function getTitle(): string {
457
-		return $this->title;
458
-	}
459
-
460
-
461
-	/**
462
-	 * Set the content of the document.
463
-	 * $encoded can be NOT_ENCODED or ENCODED_BASE64 if the content is raw or
464
-	 * encoded in base64.
465
-	 *
466
-	 * @since 15.0.0
467
-	 *
468
-	 * @param string $content
469
-	 * @param int $encoded
470
-	 *
471
-	 * @return IIndexDocument
472
-	 */
473
-	final public function setContent(string $content, int $encoded = 0): IIndexDocument {
474
-		$this->content = $content;
475
-		$this->contentEncoded = $encoded;
476
-
477
-		return $this;
478
-	}
479
-
480
-	/**
481
-	 * Get the content of the original document.
482
-	 *
483
-	 * @since 15.0.0
484
-	 *
485
-	 * @return string
486
-	 */
487
-	final public function getContent(): string {
488
-		return $this->content;
489
-	}
490
-
491
-	/**
492
-	 * Returns the type of the encoding on the content.
493
-	 *
494
-	 * @since 15.0.0
495
-	 *
496
-	 * @return int
497
-	 */
498
-	final public function isContentEncoded(): int {
499
-		return $this->contentEncoded;
500
-	}
501
-
502
-	/**
503
-	 * Return the size of the content.
504
-	 *
505
-	 * @since 15.0.0
506
-	 *
507
-	 * @return int
508
-	 */
509
-	final public function getContentSize(): int {
510
-		return strlen($this->getContent());
511
-	}
512
-
513
-
514
-	/**
515
-	 * Generate an hash, based on the content of the original document.
516
-	 *
517
-	 * @since 15.0.0
518
-	 *
519
-	 * @return IIndexDocument
520
-	 */
521
-	final public function initHash(): IIndexDocument {
522
-		if ($this->getContent() === '' || is_null($this->getContent())) {
523
-			return $this;
524
-		}
525
-
526
-		$this->hash = hash("md5", $this->getContent());
527
-
528
-		return $this;
529
-	}
530
-
531
-	/**
532
-	 * Set the hash of the original document.
533
-	 *
534
-	 * @since 15.0.0
535
-	 *
536
-	 * @param string $hash
537
-	 *
538
-	 * @return IIndexDocument
539
-	 */
540
-	final public function setHash(string $hash): IIndexDocument {
541
-		$this->hash = $hash;
542
-
543
-		return $this;
544
-	}
545
-
546
-	/**
547
-	 * Get the hash of the original document.
548
-	 *
549
-	 * @since 15.0.0
550
-	 *
551
-	 * @return string
552
-	 */
553
-	final public function getHash(): string {
554
-		return $this->hash;
555
-	}
556
-
557
-
558
-	/**
559
-	 * Add a part, identified by a string, and its content.
560
-	 *
561
-	 * It is strongly advised to use alphanumerical chars with no space in the
562
-	 * $part string.
563
-	 *
564
-	 * @since 15.0.0
565
-	 *
566
-	 * @param string $part
567
-	 * @param string $content
568
-	 *
569
-	 * @return IIndexDocument
570
-	 */
571
-	final public function addPart(string $part, string $content): IIndexDocument {
572
-		$this->parts[$part] = $content;
573
-
574
-		return $this;
575
-	}
576
-
577
-	/**
578
-	 * Set all parts and their content.
579
-	 *
580
-	 * @since 15.0.0
581
-	 *
582
-	 * @param array $parts
583
-	 *
584
-	 * @return IIndexDocument
585
-	 */
586
-	final public function setParts(array $parts): IIndexDocument {
587
-		$this->parts = $parts;
588
-
589
-		return $this;
590
-	}
591
-
592
-	/**
593
-	 * Get all parts of the IIndexDocument.
594
-	 *
595
-	 * @since 15.0.0
596
-	 *
597
-	 * @return array
598
-	 */
599
-	final public function getParts(): array {
600
-		return $this->parts;
601
-	}
602
-
603
-
604
-	/**
605
-	 * Add a link, usable by the frontend.
606
-	 *
607
-	 * @since 15.0.0
608
-	 *
609
-	 * @param string $link
610
-	 *
611
-	 * @return IIndexDocument
612
-	 */
613
-	final public function setLink(string $link): IIndexDocument {
614
-		$this->link = $link;
615
-
616
-		return $this;
617
-	}
618
-
619
-	/**
620
-	 * Get the link.
621
-	 *
622
-	 * @since 15.0.0
623
-	 *
624
-	 * @return string
625
-	 */
626
-	final public function getLink(): string {
627
-		return $this->link;
628
-	}
629
-
630
-
631
-	/**
632
-	 * Set more information that couldn't be set using other method.
633
-	 *
634
-	 * @since 15.0.0
635
-	 *
636
-	 * @param array $more
637
-	 *
638
-	 * @return IIndexDocument
639
-	 */
640
-	final public function setMore(array $more): IIndexDocument {
641
-		$this->more = $more;
642
-
643
-		return $this;
644
-	}
645
-
646
-	/**
647
-	 * Get more information.
648
-	 *
649
-	 * @since 15.0.0
650
-	 *
651
-	 * @return array
652
-	 */
653
-	final public function getMore(): array {
654
-		return $this->more;
655
-	}
656
-
657
-
658
-	/**
659
-	 * Add some excerpt of the content of the original document, usually based
660
-	 * on the search request.
661
-	 *
662
-	 * @since 16.0.0
663
-	 *
664
-	 * @param string $source
665
-	 * @param string $excerpt
666
-	 *
667
-	 * @return IIndexDocument
668
-	 */
669
-	final public function addExcerpt(string $source, string $excerpt): IIndexDocument {
670
-		$this->excerpts[] =
671
-			[
672
-				'source' => $source,
673
-				'excerpt' => $this->cleanExcerpt($excerpt)
674
-			];
675
-
676
-		return $this;
677
-	}
678
-
679
-
680
-	/**
681
-	 * Set all excerpts of the content of the original document.
682
-	 *
683
-	 * @since 16.0.0
684
-	 *
685
-	 * @param array $excerpts
686
-	 *
687
-	 * @return IIndexDocument
688
-	 */
689
-	final public function setExcerpts(array $excerpts): IIndexDocument {
690
-		$new = [];
691
-		foreach ($excerpts as $entry) {
692
-			$new[] = [
693
-				'source' => $entry['source'],
694
-				'excerpt' => $this->cleanExcerpt($entry['excerpt'])
695
-			];
696
-		}
697
-
698
-		$this->excerpts = $new;
699
-
700
-		return $this;
701
-	}
702
-
703
-	/**
704
-	 * Get all excerpts of the content of the original document.
705
-	 *
706
-	 * @since 15.0.0
707
-	 *
708
-	 * @return array
709
-	 */
710
-	final public function getExcerpts(): array {
711
-		return $this->excerpts;
712
-	}
713
-
714
-	/**
715
-	 * Clean excerpt.
716
-	 *
717
-	 * @since 16.0.0
718
-	 *
719
-	 * @param string $excerpt
720
-	 * @return string
721
-	 */
722
-	private function cleanExcerpt(string $excerpt): string {
723
-		$excerpt = str_replace("\\n", ' ', $excerpt);
724
-		$excerpt = str_replace("\\r", ' ', $excerpt);
725
-		$excerpt = str_replace("\\t", ' ', $excerpt);
726
-		$excerpt = str_replace("\n", ' ', $excerpt);
727
-		$excerpt = str_replace("\r", ' ', $excerpt);
728
-		$excerpt = str_replace("\t", ' ', $excerpt);
729
-
730
-		return $excerpt;
731
-	}
732
-
733
-
734
-	/**
735
-	 * Set the score to the result assigned to this document during a search
736
-	 * request.
737
-	 *
738
-	 * @since 15.0.0
739
-	 *
740
-	 * @param string $score
741
-	 *
742
-	 * @return IIndexDocument
743
-	 */
744
-	final public function setScore(string $score): IIndexDocument {
745
-		$this->score = $score;
746
-
747
-		return $this;
748
-	}
749
-
750
-	/**
751
-	 * Get the score.
752
-	 *
753
-	 * @since 15.0.0
754
-	 *
755
-	 * @return string
756
-	 */
757
-	final public function getScore(): string {
758
-		return $this->score;
759
-	}
760
-
761
-
762
-	/**
763
-	 * Set some information about the original document that will be available
764
-	 * to the front-end when displaying search result. (as string)
765
-	 * Because this information will not be indexed, this method can also be
766
-	 * used to manage some data while filling the IIndexDocument before its
767
-	 * indexing.
768
-	 *
769
-	 * @since 15.0.0
770
-	 *
771
-	 * @param string $info
772
-	 * @param string $value
773
-	 *
774
-	 * @return IIndexDocument
775
-	 */
776
-	final public function setInfo(string $info, string $value): IIndexDocument {
777
-		$this->info[$info] = $value;
778
-
779
-		return $this;
780
-	}
781
-
782
-	/**
783
-	 * Get an information about a document. (string)
784
-	 *
785
-	 * @since 15.0.0
786
-	 *
787
-	 * @param string $info
788
-	 * @param string $default
789
-	 *
790
-	 * @return string
791
-	 */
792
-	final public function getInfo(string $info, string $default = ''): string {
793
-		if (!key_exists($info, $this->info)) {
794
-			return $default;
795
-		}
796
-
797
-		return $this->info[$info];
798
-	}
799
-
800
-	/**
801
-	 * Set some information about the original document that will be available
802
-	 * to the front-end when displaying search result. (as array)
803
-	 * Because this information will not be indexed, this method can also be
804
-	 * used to manage some data while filling the IIndexDocument before its
805
-	 * indexing.
806
-	 *
807
-	 * @since 15.0.0
808
-	 *
809
-	 * @param string $info
810
-	 * @param array $value
811
-	 *
812
-	 * @return IIndexDocument
813
-	 */
814
-	final public function setInfoArray(string $info, array $value): IIndexDocument {
815
-		$this->info[$info] = $value;
816
-
817
-		return $this;
818
-	}
819
-
820
-	/**
821
-	 * Get an information about a document. (array)
822
-	 *
823
-	 * @since 15.0.0
824
-	 *
825
-	 * @param string $info
826
-	 * @param array $default
827
-	 *
828
-	 * @return array
829
-	 */
830
-	final public function getInfoArray(string $info, array $default = []): array {
831
-		if (!key_exists($info, $this->info)) {
832
-			return $default;
833
-		}
834
-
835
-		return $this->info[$info];
836
-	}
837
-
838
-	/**
839
-	 * Set some information about the original document that will be available
840
-	 * to the front-end when displaying search result. (as int)
841
-	 * Because this information will not be indexed, this method can also be
842
-	 * used to manage some data while filling the IIndexDocument before its
843
-	 * indexing.
844
-	 *
845
-	 * @since 15.0.0
846
-	 *
847
-	 * @param string $info
848
-	 * @param int $value
849
-	 *
850
-	 * @return IIndexDocument
851
-	 */
852
-	final public function setInfoInt(string $info, int $value): IIndexDocument {
853
-		$this->info[$info] = $value;
854
-
855
-		return $this;
856
-	}
857
-
858
-	/**
859
-	 * Get an information about a document. (int)
860
-	 *
861
-	 * @since 15.0.0
862
-	 *
863
-	 * @param string $info
864
-	 * @param int $default
865
-	 *
866
-	 * @return int
867
-	 */
868
-	final public function getInfoInt(string $info, int $default = 0): int {
869
-		if (!key_exists($info, $this->info)) {
870
-			return $default;
871
-		}
872
-
873
-		return $this->info[$info];
874
-	}
875
-
876
-	/**
877
-	 * Set some information about the original document that will be available
878
-	 * to the front-end when displaying search result. (as bool)
879
-	 * Because this information will not be indexed, this method can also be
880
-	 * used to manage some data while filling the IIndexDocument before its
881
-	 * indexing.
882
-	 *
883
-	 * @since 15.0.0
884
-	 *
885
-	 * @param string $info
886
-	 * @param bool $value
887
-	 *
888
-	 * @return IIndexDocument
889
-	 */
890
-	final public function setInfoBool(string $info, bool $value): IIndexDocument {
891
-		$this->info[$info] = $value;
892
-
893
-		return $this;
894
-	}
895
-
896
-	/**
897
-	 * Get an information about a document. (bool)
898
-	 *
899
-	 * @since 15.0.0
900
-	 *
901
-	 * @param string $info
902
-	 * @param bool $default
903
-	 *
904
-	 * @return bool
905
-	 */
906
-	final public function getInfoBool(string $info, bool $default = false): bool {
907
-		if (!key_exists($info, $this->info)) {
908
-			return $default;
909
-		}
910
-
911
-		return $this->info[$info];
912
-	}
913
-
914
-	/**
915
-	 * Get all info.
916
-	 *
917
-	 * @since 15.0.0
918
-	 *
919
-	 * @return array
920
-	 */
921
-	final public function getInfoAll(): array {
922
-		$info = [];
923
-		foreach ($this->info as $k => $v) {
924
-			if (substr($k, 0, 1) === '_') {
925
-				continue;
926
-			}
927
-
928
-			$info[$k] = $v;
929
-		}
930
-
931
-		return $info;
932
-	}
933
-
934
-
935
-	/**
936
-	 * @since 15.0.0
937
-	 *
938
-	 * On some version of PHP, it is better to force destruct the object.
939
-	 * And during the index, the number of generated IIndexDocument can be
940
-	 * _huge_.
941
-	 */
942
-	public function __destruct() {
943
-		unset($this->id);
944
-		unset($this->providerId);
945
-		unset($this->access);
946
-		unset($this->modifiedTime);
947
-		unset($this->title);
948
-		unset($this->content);
949
-		unset($this->hash);
950
-		unset($this->link);
951
-		unset($this->source);
952
-		unset($this->tags);
953
-		unset($this->metaTags);
954
-		unset($this->subTags);
955
-		unset($this->more);
956
-		unset($this->excerpts);
957
-		unset($this->score);
958
-		unset($this->info);
959
-		unset($this->contentEncoded);
960
-	}
961
-
962
-	/**
963
-	 * @since 15.0.0
964
-	 */
965
-	public function jsonSerialize(): array {
966
-		return [
967
-			'id' => $this->getId(),
968
-			'providerId' => $this->getProviderId(),
969
-			'access' => $this->access,
970
-			'modifiedTime' => $this->getModifiedTime(),
971
-			'title' => $this->getTitle(),
972
-			'link' => $this->getLink(),
973
-			'index' => $this->index,
974
-			'source' => $this->getSource(),
975
-			'info' => $this->getInfoAll(),
976
-			'hash' => $this->getHash(),
977
-			'contentSize' => $this->getContentSize(),
978
-			'tags' => $this->getTags(),
979
-			'metatags' => $this->getMetaTags(),
980
-			'subtags' => $this->getSubTags(),
981
-			'more' => $this->getMore(),
982
-			'excerpts' => $this->getExcerpts(),
983
-			'score' => $this->getScore()
984
-		];
985
-	}
56
+    /** @var DocumentAccess */
57
+    protected $access;
58
+
59
+    /** @var IIndex */
60
+    protected $index;
61
+
62
+    /** @var int */
63
+    protected $modifiedTime = 0;
64
+
65
+    /** @var string */
66
+    protected $source = '';
67
+
68
+    /** @var array */
69
+    protected $tags = [];
70
+
71
+    /** @var array */
72
+    protected $metaTags = [];
73
+
74
+    /** @var array */
75
+    protected $subTags = [];
76
+
77
+    /** @var string */
78
+    protected $title = '';
79
+
80
+    /** @var string */
81
+    protected $content = '';
82
+
83
+    /** @var string */
84
+    protected $hash = '';
85
+
86
+    /** @var array */
87
+    protected $parts = [];
88
+
89
+    /** @var string */
90
+    protected $link = '';
91
+
92
+    /** @var array */
93
+    protected $more = [];
94
+
95
+    /** @var array */
96
+    protected $excerpts = [];
97
+
98
+    /** @var string */
99
+    protected $score = '';
100
+
101
+    /** @var array */
102
+    protected $info = [];
103
+
104
+    /** @var int */
105
+    protected $contentEncoded = 0;
106
+
107
+
108
+    /**
109
+     * IIndexDocument constructor.
110
+     *
111
+     * On creation, we assure the uniqueness of the object using the providerId
112
+     * and the Id of the original document.
113
+     *
114
+     * @since 15.0.0
115
+     *
116
+     * @param string $providerId
117
+     * @param string $documentId
118
+     */
119
+    public function __construct(string $providerId, string $documentId) {
120
+        $this->providerId = $providerId;
121
+        $this->id = $documentId;
122
+    }
123
+
124
+
125
+    /**
126
+     * Returns the Id of the original document.
127
+     *
128
+     * @since 15.0.0
129
+     *
130
+     * @return string
131
+     */
132
+    final public function getId(): string {
133
+        return $this->id;
134
+    }
135
+
136
+
137
+    /**
138
+     * Returns the Id of the provider.
139
+     *
140
+     * @since 15.0.0
141
+     *
142
+     * @return string
143
+     */
144
+    final public function getProviderId(): string {
145
+        return $this->providerId;
146
+    }
147
+
148
+
149
+    /**
150
+     * Set the Index related to the IIndexDocument.
151
+     *
152
+     * @see IIndex
153
+     *
154
+     * @since 15.0.0
155
+     *
156
+     * @param IIndex $index
157
+     *
158
+     * @return IIndexDocument
159
+     */
160
+    final public function setIndex(IIndex $index): IIndexDocument {
161
+        $this->index = $index;
162
+
163
+        return $this;
164
+    }
165
+
166
+    /**
167
+     * Get the Index.
168
+     *
169
+     * @since 15.0.0
170
+     *
171
+     * @return IIndex
172
+     */
173
+    final public function getIndex(): IIndex {
174
+        return $this->index;
175
+    }
176
+
177
+    /**
178
+     * return if Index is defined.
179
+     *
180
+     * @since 16.0.0
181
+     *
182
+     * @return bool
183
+     */
184
+    final public function hasIndex(): bool {
185
+        return ($this->index !== null);
186
+    }
187
+
188
+
189
+    /**
190
+     * Set the modified time of the original document.
191
+     *
192
+     * @since 15.0.0
193
+     *
194
+     * @param int $modifiedTime
195
+     *
196
+     * @return IIndexDocument
197
+     */
198
+    final public function setModifiedTime(int $modifiedTime): IIndexDocument {
199
+        $this->modifiedTime = $modifiedTime;
200
+
201
+        return $this;
202
+    }
203
+
204
+    /**
205
+     * Get the modified time of the original document.
206
+     *
207
+     * @since 15.0.0
208
+     *
209
+     * @return int
210
+     */
211
+    final public function getModifiedTime(): int {
212
+        return $this->modifiedTime;
213
+    }
214
+
215
+    /**
216
+     * Check if the original document of the IIndexDocument is older than $time.
217
+     *
218
+     * @since 15.0.0
219
+     *
220
+     * @param int $time
221
+     *
222
+     * @return bool
223
+     */
224
+    final public function isOlderThan(int $time): bool {
225
+        return ($this->modifiedTime < $time);
226
+    }
227
+
228
+
229
+    /**
230
+     * Set the read rights of the original document using a IDocumentAccess.
231
+     *
232
+     * @see IDocumentAccess
233
+     *
234
+     * @since 15.0.0
235
+     *
236
+     * @param IDocumentAccess $access
237
+     *
238
+     * @return $this
239
+     */
240
+    final public function setAccess(IDocumentAccess $access): IIndexDocument {
241
+        $this->access = $access;
242
+
243
+        return $this;
244
+    }
245
+
246
+    /**
247
+     * Get the IDocumentAccess related to the original document.
248
+     *
249
+     * @since 15.0.0
250
+     *
251
+     * @return IDocumentAccess
252
+     */
253
+    final public function getAccess(): IDocumentAccess {
254
+        return $this->access;
255
+    }
256
+
257
+
258
+    /**
259
+     * Add a tag to the list.
260
+     *
261
+     * @since 15.0.0
262
+     *
263
+     * @param string $tag
264
+     *
265
+     * @return IIndexDocument
266
+     */
267
+    final public function addTag(string $tag): IIndexDocument {
268
+        $this->tags[] = $tag;
269
+
270
+        return $this;
271
+    }
272
+
273
+    /**
274
+     * Set the list of tags assigned to the original document.
275
+     *
276
+     * @since 15.0.0
277
+     *
278
+     * @param array $tags
279
+     *
280
+     * @return IIndexDocument
281
+     */
282
+    final public function setTags(array $tags): IIndexDocument {
283
+        $this->tags = $tags;
284
+
285
+        return $this;
286
+    }
287
+
288
+    /**
289
+     * Get the list of tags assigned to the original document.
290
+     *
291
+     * @since 15.0.0
292
+     *
293
+     * @return array
294
+     */
295
+    final public function getTags(): array {
296
+        return $this->tags;
297
+    }
298
+
299
+
300
+    /**
301
+     * Add a meta tag to the list.
302
+     *
303
+     * @since 15.0.0
304
+     *
305
+     * @param string $tag
306
+     *
307
+     * @return IIndexDocument
308
+     */
309
+    final public function addMetaTag(string $tag): IIndexDocument {
310
+        $this->metaTags[] = $tag;
311
+
312
+        return $this;
313
+    }
314
+
315
+    /**
316
+     * Set the list of meta tags assigned to the original document.
317
+     *
318
+     * @since 15.0.0
319
+     *
320
+     * @param array $tags
321
+     *
322
+     * @return IIndexDocument
323
+     */
324
+    final public function setMetaTags(array $tags): IIndexDocument {
325
+        $this->metaTags = $tags;
326
+
327
+        return $this;
328
+    }
329
+
330
+    /**
331
+     * Get the list of meta tags assigned to the original document.
332
+     *
333
+     * @since 15.0.0
334
+     *
335
+     * @return array
336
+     */
337
+    final public function getMetaTags(): array {
338
+        return $this->metaTags;
339
+    }
340
+
341
+
342
+    /**
343
+     * Add a sub tag to the list.
344
+     *
345
+     * @since 15.0.0
346
+     *
347
+     * @param string $sub
348
+     * @param string $tag
349
+     *
350
+     * @return IIndexDocument
351
+     */
352
+    final public function addSubTag(string $sub, string $tag): IIndexDocument {
353
+        if (!array_key_exists($sub, $this->subTags)) {
354
+            $this->subTags[$sub] = [];
355
+        }
356
+
357
+        $this->subTags[$sub][] = $tag;
358
+
359
+        return $this;
360
+    }
361
+
362
+
363
+    /**
364
+     * Set the list of sub tags assigned to the original document.
365
+     *
366
+     * @since 15.0.0
367
+     *
368
+     * @param array $tags
369
+     *
370
+     * @return IIndexDocument
371
+     */
372
+    final public function setSubTags(array $tags): IIndexDocument {
373
+        $this->subTags = $tags;
374
+
375
+        return $this;
376
+    }
377
+
378
+    /**
379
+     * Get the list of sub tags assigned to the original document.
380
+     * If $formatted is true, the result will be formatted in a one
381
+     * dimensional array.
382
+     *
383
+     * @since 15.0.0
384
+     *
385
+     * @param bool $formatted
386
+     *
387
+     * @return array
388
+     */
389
+    final public function getSubTags(bool $formatted = false): array {
390
+        if ($formatted === false) {
391
+            return $this->subTags;
392
+        }
393
+
394
+        $subTags = [];
395
+        $ak = array_keys($this->subTags);
396
+        foreach ($ak as $source) {
397
+            $tags = $this->subTags[$source];
398
+            foreach ($tags as $tag) {
399
+                $subTags[] = $source . '_' . $tag;
400
+            }
401
+        }
402
+
403
+        return $subTags;
404
+    }
405
+
406
+
407
+    /**
408
+     * Set the source of the original document.
409
+     *
410
+     * @since 15.0.0
411
+     *
412
+     * @param string $source
413
+     *
414
+     * @return IIndexDocument
415
+     */
416
+    final public function setSource(string $source): IIndexDocument {
417
+        $this->source = $source;
418
+
419
+        return $this;
420
+    }
421
+
422
+    /**
423
+     * Get the source of the original document.
424
+     *
425
+     * @since 15.0.0
426
+     *
427
+     * @return string
428
+     */
429
+    final public function getSource(): string {
430
+        return $this->source;
431
+    }
432
+
433
+
434
+    /**
435
+     * Set the title of the original document.
436
+     *
437
+     * @since 15.0.0
438
+     *
439
+     * @param string $title
440
+     *
441
+     * @return IIndexDocument
442
+     */
443
+    final public function setTitle(string $title): IIndexDocument {
444
+        $this->title = $title;
445
+
446
+        return $this;
447
+    }
448
+
449
+    /**
450
+     * Get the title of the original document.
451
+     *
452
+     * @since 15.0.0
453
+     *
454
+     * @return string
455
+     */
456
+    final public function getTitle(): string {
457
+        return $this->title;
458
+    }
459
+
460
+
461
+    /**
462
+     * Set the content of the document.
463
+     * $encoded can be NOT_ENCODED or ENCODED_BASE64 if the content is raw or
464
+     * encoded in base64.
465
+     *
466
+     * @since 15.0.0
467
+     *
468
+     * @param string $content
469
+     * @param int $encoded
470
+     *
471
+     * @return IIndexDocument
472
+     */
473
+    final public function setContent(string $content, int $encoded = 0): IIndexDocument {
474
+        $this->content = $content;
475
+        $this->contentEncoded = $encoded;
476
+
477
+        return $this;
478
+    }
479
+
480
+    /**
481
+     * Get the content of the original document.
482
+     *
483
+     * @since 15.0.0
484
+     *
485
+     * @return string
486
+     */
487
+    final public function getContent(): string {
488
+        return $this->content;
489
+    }
490
+
491
+    /**
492
+     * Returns the type of the encoding on the content.
493
+     *
494
+     * @since 15.0.0
495
+     *
496
+     * @return int
497
+     */
498
+    final public function isContentEncoded(): int {
499
+        return $this->contentEncoded;
500
+    }
501
+
502
+    /**
503
+     * Return the size of the content.
504
+     *
505
+     * @since 15.0.0
506
+     *
507
+     * @return int
508
+     */
509
+    final public function getContentSize(): int {
510
+        return strlen($this->getContent());
511
+    }
512
+
513
+
514
+    /**
515
+     * Generate an hash, based on the content of the original document.
516
+     *
517
+     * @since 15.0.0
518
+     *
519
+     * @return IIndexDocument
520
+     */
521
+    final public function initHash(): IIndexDocument {
522
+        if ($this->getContent() === '' || is_null($this->getContent())) {
523
+            return $this;
524
+        }
525
+
526
+        $this->hash = hash("md5", $this->getContent());
527
+
528
+        return $this;
529
+    }
530
+
531
+    /**
532
+     * Set the hash of the original document.
533
+     *
534
+     * @since 15.0.0
535
+     *
536
+     * @param string $hash
537
+     *
538
+     * @return IIndexDocument
539
+     */
540
+    final public function setHash(string $hash): IIndexDocument {
541
+        $this->hash = $hash;
542
+
543
+        return $this;
544
+    }
545
+
546
+    /**
547
+     * Get the hash of the original document.
548
+     *
549
+     * @since 15.0.0
550
+     *
551
+     * @return string
552
+     */
553
+    final public function getHash(): string {
554
+        return $this->hash;
555
+    }
556
+
557
+
558
+    /**
559
+     * Add a part, identified by a string, and its content.
560
+     *
561
+     * It is strongly advised to use alphanumerical chars with no space in the
562
+     * $part string.
563
+     *
564
+     * @since 15.0.0
565
+     *
566
+     * @param string $part
567
+     * @param string $content
568
+     *
569
+     * @return IIndexDocument
570
+     */
571
+    final public function addPart(string $part, string $content): IIndexDocument {
572
+        $this->parts[$part] = $content;
573
+
574
+        return $this;
575
+    }
576
+
577
+    /**
578
+     * Set all parts and their content.
579
+     *
580
+     * @since 15.0.0
581
+     *
582
+     * @param array $parts
583
+     *
584
+     * @return IIndexDocument
585
+     */
586
+    final public function setParts(array $parts): IIndexDocument {
587
+        $this->parts = $parts;
588
+
589
+        return $this;
590
+    }
591
+
592
+    /**
593
+     * Get all parts of the IIndexDocument.
594
+     *
595
+     * @since 15.0.0
596
+     *
597
+     * @return array
598
+     */
599
+    final public function getParts(): array {
600
+        return $this->parts;
601
+    }
602
+
603
+
604
+    /**
605
+     * Add a link, usable by the frontend.
606
+     *
607
+     * @since 15.0.0
608
+     *
609
+     * @param string $link
610
+     *
611
+     * @return IIndexDocument
612
+     */
613
+    final public function setLink(string $link): IIndexDocument {
614
+        $this->link = $link;
615
+
616
+        return $this;
617
+    }
618
+
619
+    /**
620
+     * Get the link.
621
+     *
622
+     * @since 15.0.0
623
+     *
624
+     * @return string
625
+     */
626
+    final public function getLink(): string {
627
+        return $this->link;
628
+    }
629
+
630
+
631
+    /**
632
+     * Set more information that couldn't be set using other method.
633
+     *
634
+     * @since 15.0.0
635
+     *
636
+     * @param array $more
637
+     *
638
+     * @return IIndexDocument
639
+     */
640
+    final public function setMore(array $more): IIndexDocument {
641
+        $this->more = $more;
642
+
643
+        return $this;
644
+    }
645
+
646
+    /**
647
+     * Get more information.
648
+     *
649
+     * @since 15.0.0
650
+     *
651
+     * @return array
652
+     */
653
+    final public function getMore(): array {
654
+        return $this->more;
655
+    }
656
+
657
+
658
+    /**
659
+     * Add some excerpt of the content of the original document, usually based
660
+     * on the search request.
661
+     *
662
+     * @since 16.0.0
663
+     *
664
+     * @param string $source
665
+     * @param string $excerpt
666
+     *
667
+     * @return IIndexDocument
668
+     */
669
+    final public function addExcerpt(string $source, string $excerpt): IIndexDocument {
670
+        $this->excerpts[] =
671
+            [
672
+                'source' => $source,
673
+                'excerpt' => $this->cleanExcerpt($excerpt)
674
+            ];
675
+
676
+        return $this;
677
+    }
678
+
679
+
680
+    /**
681
+     * Set all excerpts of the content of the original document.
682
+     *
683
+     * @since 16.0.0
684
+     *
685
+     * @param array $excerpts
686
+     *
687
+     * @return IIndexDocument
688
+     */
689
+    final public function setExcerpts(array $excerpts): IIndexDocument {
690
+        $new = [];
691
+        foreach ($excerpts as $entry) {
692
+            $new[] = [
693
+                'source' => $entry['source'],
694
+                'excerpt' => $this->cleanExcerpt($entry['excerpt'])
695
+            ];
696
+        }
697
+
698
+        $this->excerpts = $new;
699
+
700
+        return $this;
701
+    }
702
+
703
+    /**
704
+     * Get all excerpts of the content of the original document.
705
+     *
706
+     * @since 15.0.0
707
+     *
708
+     * @return array
709
+     */
710
+    final public function getExcerpts(): array {
711
+        return $this->excerpts;
712
+    }
713
+
714
+    /**
715
+     * Clean excerpt.
716
+     *
717
+     * @since 16.0.0
718
+     *
719
+     * @param string $excerpt
720
+     * @return string
721
+     */
722
+    private function cleanExcerpt(string $excerpt): string {
723
+        $excerpt = str_replace("\\n", ' ', $excerpt);
724
+        $excerpt = str_replace("\\r", ' ', $excerpt);
725
+        $excerpt = str_replace("\\t", ' ', $excerpt);
726
+        $excerpt = str_replace("\n", ' ', $excerpt);
727
+        $excerpt = str_replace("\r", ' ', $excerpt);
728
+        $excerpt = str_replace("\t", ' ', $excerpt);
729
+
730
+        return $excerpt;
731
+    }
732
+
733
+
734
+    /**
735
+     * Set the score to the result assigned to this document during a search
736
+     * request.
737
+     *
738
+     * @since 15.0.0
739
+     *
740
+     * @param string $score
741
+     *
742
+     * @return IIndexDocument
743
+     */
744
+    final public function setScore(string $score): IIndexDocument {
745
+        $this->score = $score;
746
+
747
+        return $this;
748
+    }
749
+
750
+    /**
751
+     * Get the score.
752
+     *
753
+     * @since 15.0.0
754
+     *
755
+     * @return string
756
+     */
757
+    final public function getScore(): string {
758
+        return $this->score;
759
+    }
760
+
761
+
762
+    /**
763
+     * Set some information about the original document that will be available
764
+     * to the front-end when displaying search result. (as string)
765
+     * Because this information will not be indexed, this method can also be
766
+     * used to manage some data while filling the IIndexDocument before its
767
+     * indexing.
768
+     *
769
+     * @since 15.0.0
770
+     *
771
+     * @param string $info
772
+     * @param string $value
773
+     *
774
+     * @return IIndexDocument
775
+     */
776
+    final public function setInfo(string $info, string $value): IIndexDocument {
777
+        $this->info[$info] = $value;
778
+
779
+        return $this;
780
+    }
781
+
782
+    /**
783
+     * Get an information about a document. (string)
784
+     *
785
+     * @since 15.0.0
786
+     *
787
+     * @param string $info
788
+     * @param string $default
789
+     *
790
+     * @return string
791
+     */
792
+    final public function getInfo(string $info, string $default = ''): string {
793
+        if (!key_exists($info, $this->info)) {
794
+            return $default;
795
+        }
796
+
797
+        return $this->info[$info];
798
+    }
799
+
800
+    /**
801
+     * Set some information about the original document that will be available
802
+     * to the front-end when displaying search result. (as array)
803
+     * Because this information will not be indexed, this method can also be
804
+     * used to manage some data while filling the IIndexDocument before its
805
+     * indexing.
806
+     *
807
+     * @since 15.0.0
808
+     *
809
+     * @param string $info
810
+     * @param array $value
811
+     *
812
+     * @return IIndexDocument
813
+     */
814
+    final public function setInfoArray(string $info, array $value): IIndexDocument {
815
+        $this->info[$info] = $value;
816
+
817
+        return $this;
818
+    }
819
+
820
+    /**
821
+     * Get an information about a document. (array)
822
+     *
823
+     * @since 15.0.0
824
+     *
825
+     * @param string $info
826
+     * @param array $default
827
+     *
828
+     * @return array
829
+     */
830
+    final public function getInfoArray(string $info, array $default = []): array {
831
+        if (!key_exists($info, $this->info)) {
832
+            return $default;
833
+        }
834
+
835
+        return $this->info[$info];
836
+    }
837
+
838
+    /**
839
+     * Set some information about the original document that will be available
840
+     * to the front-end when displaying search result. (as int)
841
+     * Because this information will not be indexed, this method can also be
842
+     * used to manage some data while filling the IIndexDocument before its
843
+     * indexing.
844
+     *
845
+     * @since 15.0.0
846
+     *
847
+     * @param string $info
848
+     * @param int $value
849
+     *
850
+     * @return IIndexDocument
851
+     */
852
+    final public function setInfoInt(string $info, int $value): IIndexDocument {
853
+        $this->info[$info] = $value;
854
+
855
+        return $this;
856
+    }
857
+
858
+    /**
859
+     * Get an information about a document. (int)
860
+     *
861
+     * @since 15.0.0
862
+     *
863
+     * @param string $info
864
+     * @param int $default
865
+     *
866
+     * @return int
867
+     */
868
+    final public function getInfoInt(string $info, int $default = 0): int {
869
+        if (!key_exists($info, $this->info)) {
870
+            return $default;
871
+        }
872
+
873
+        return $this->info[$info];
874
+    }
875
+
876
+    /**
877
+     * Set some information about the original document that will be available
878
+     * to the front-end when displaying search result. (as bool)
879
+     * Because this information will not be indexed, this method can also be
880
+     * used to manage some data while filling the IIndexDocument before its
881
+     * indexing.
882
+     *
883
+     * @since 15.0.0
884
+     *
885
+     * @param string $info
886
+     * @param bool $value
887
+     *
888
+     * @return IIndexDocument
889
+     */
890
+    final public function setInfoBool(string $info, bool $value): IIndexDocument {
891
+        $this->info[$info] = $value;
892
+
893
+        return $this;
894
+    }
895
+
896
+    /**
897
+     * Get an information about a document. (bool)
898
+     *
899
+     * @since 15.0.0
900
+     *
901
+     * @param string $info
902
+     * @param bool $default
903
+     *
904
+     * @return bool
905
+     */
906
+    final public function getInfoBool(string $info, bool $default = false): bool {
907
+        if (!key_exists($info, $this->info)) {
908
+            return $default;
909
+        }
910
+
911
+        return $this->info[$info];
912
+    }
913
+
914
+    /**
915
+     * Get all info.
916
+     *
917
+     * @since 15.0.0
918
+     *
919
+     * @return array
920
+     */
921
+    final public function getInfoAll(): array {
922
+        $info = [];
923
+        foreach ($this->info as $k => $v) {
924
+            if (substr($k, 0, 1) === '_') {
925
+                continue;
926
+            }
927
+
928
+            $info[$k] = $v;
929
+        }
930
+
931
+        return $info;
932
+    }
933
+
934
+
935
+    /**
936
+     * @since 15.0.0
937
+     *
938
+     * On some version of PHP, it is better to force destruct the object.
939
+     * And during the index, the number of generated IIndexDocument can be
940
+     * _huge_.
941
+     */
942
+    public function __destruct() {
943
+        unset($this->id);
944
+        unset($this->providerId);
945
+        unset($this->access);
946
+        unset($this->modifiedTime);
947
+        unset($this->title);
948
+        unset($this->content);
949
+        unset($this->hash);
950
+        unset($this->link);
951
+        unset($this->source);
952
+        unset($this->tags);
953
+        unset($this->metaTags);
954
+        unset($this->subTags);
955
+        unset($this->more);
956
+        unset($this->excerpts);
957
+        unset($this->score);
958
+        unset($this->info);
959
+        unset($this->contentEncoded);
960
+    }
961
+
962
+    /**
963
+     * @since 15.0.0
964
+     */
965
+    public function jsonSerialize(): array {
966
+        return [
967
+            'id' => $this->getId(),
968
+            'providerId' => $this->getProviderId(),
969
+            'access' => $this->access,
970
+            'modifiedTime' => $this->getModifiedTime(),
971
+            'title' => $this->getTitle(),
972
+            'link' => $this->getLink(),
973
+            'index' => $this->index,
974
+            'source' => $this->getSource(),
975
+            'info' => $this->getInfoAll(),
976
+            'hash' => $this->getHash(),
977
+            'contentSize' => $this->getContentSize(),
978
+            'tags' => $this->getTags(),
979
+            'metatags' => $this->getMetaTags(),
980
+            'subtags' => $this->getSubTags(),
981
+            'more' => $this->getMore(),
982
+            'excerpts' => $this->getExcerpts(),
983
+            'score' => $this->getScore()
984
+        ];
985
+    }
986 986
 }
Please login to merge, or discard this patch.
apps/twofactor_backupcodes/lib/Listener/ProviderDisabled.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@
 block discarded – undo
53 53
 		$providers = $this->registry->getProviderStates($event->getUser());
54 54
 
55 55
 		// Loop over all providers. If all are disabled we remove the job
56
-		$state = array_reduce($providers, function (bool $carry, bool $enabled) {
56
+		$state = array_reduce($providers, function(bool $carry, bool $enabled) {
57 57
 			return $carry || $enabled;
58 58
 		}, false);
59 59
 
Please login to merge, or discard this patch.
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -35,33 +35,33 @@
 block discarded – undo
35 35
 
36 36
 class ProviderDisabled implements IEventListener {
37 37
 
38
-	/** @var IRegistry */
39
-	private $registry;
38
+    /** @var IRegistry */
39
+    private $registry;
40 40
 
41
-	/** @var IJobList */
42
-	private $jobList;
41
+    /** @var IJobList */
42
+    private $jobList;
43 43
 
44
-	public function __construct(IRegistry $registry,
45
-								IJobList $jobList) {
46
-		$this->registry = $registry;
47
-		$this->jobList = $jobList;
48
-	}
44
+    public function __construct(IRegistry $registry,
45
+                                IJobList $jobList) {
46
+        $this->registry = $registry;
47
+        $this->jobList = $jobList;
48
+    }
49 49
 
50
-	public function handle(Event $event): void {
51
-		if (!($event instanceof RegistryEvent)) {
52
-			return;
53
-		}
50
+    public function handle(Event $event): void {
51
+        if (!($event instanceof RegistryEvent)) {
52
+            return;
53
+        }
54 54
 
55
-		$providers = $this->registry->getProviderStates($event->getUser());
55
+        $providers = $this->registry->getProviderStates($event->getUser());
56 56
 
57
-		// Loop over all providers. If all are disabled we remove the job
58
-		$state = array_reduce($providers, function (bool $carry, bool $enabled) {
59
-			return $carry || $enabled;
60
-		}, false);
57
+        // Loop over all providers. If all are disabled we remove the job
58
+        $state = array_reduce($providers, function (bool $carry, bool $enabled) {
59
+            return $carry || $enabled;
60
+        }, false);
61 61
 
62
-		if ($state === false) {
63
-			$this->jobList->remove(RememberBackupCodesJob::class, ['uid' => $event->getUser()->getUID()]);
64
-		}
65
-	}
62
+        if ($state === false) {
63
+            $this->jobList->remove(RememberBackupCodesJob::class, ['uid' => $event->getUser()->getUID()]);
64
+        }
65
+    }
66 66
 
67 67
 }
Please login to merge, or discard this patch.
apps/oauth2/lib/Db/AccessToken.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -34,20 +34,20 @@
 block discarded – undo
34 34
  * @method void setHashedCode(string $token)
35 35
  */
36 36
 class AccessToken extends Entity {
37
-	/** @var int */
38
-	protected $tokenId;
39
-	/** @var int */
40
-	protected $clientId;
41
-	/** @var string */
42
-	protected $hashedCode;
43
-	/** @var string */
44
-	protected $encryptedToken;
37
+    /** @var int */
38
+    protected $tokenId;
39
+    /** @var int */
40
+    protected $clientId;
41
+    /** @var string */
42
+    protected $hashedCode;
43
+    /** @var string */
44
+    protected $encryptedToken;
45 45
 
46
-	public function __construct() {
47
-		$this->addType('id', 'int');
48
-		$this->addType('tokenId', 'int');
49
-		$this->addType('clientId', 'int');
50
-		$this->addType('hashedCode', 'string');
51
-		$this->addType('encryptedToken', 'string');
52
-	}
46
+    public function __construct() {
47
+        $this->addType('id', 'int');
48
+        $this->addType('tokenId', 'int');
49
+        $this->addType('clientId', 'int');
50
+        $this->addType('hashedCode', 'string');
51
+        $this->addType('encryptedToken', 'string');
52
+    }
53 53
 }
Please login to merge, or discard this patch.
lib/private/Authentication/Exceptions/WipeTokenException.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -26,16 +26,16 @@
 block discarded – undo
26 26
 use OC\Authentication\Token\IToken;
27 27
 
28 28
 class WipeTokenException extends InvalidTokenException {
29
-	/** @var IToken */
30
-	private $token;
29
+    /** @var IToken */
30
+    private $token;
31 31
 
32
-	public function __construct(IToken $token) {
33
-		parent::__construct();
32
+    public function __construct(IToken $token) {
33
+        parent::__construct();
34 34
 
35
-		$this->token = $token;
36
-	}
35
+        $this->token = $token;
36
+    }
37 37
 
38
-	public function getToken(): IToken {
39
-		return $this->token;
40
-	}
38
+    public function getToken(): IToken {
39
+        return $this->token;
40
+    }
41 41
 }
Please login to merge, or discard this patch.
apps/dav/lib/Migration/RegenerateBirthdayCalendars.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -30,43 +30,43 @@
 block discarded – undo
30 30
 
31 31
 class RegenerateBirthdayCalendars implements IRepairStep {
32 32
 
33
-	/** @var IJobList */
34
-	private $jobList;
33
+    /** @var IJobList */
34
+    private $jobList;
35 35
 
36
-	/** @var IConfig */
37
-	private $config;
36
+    /** @var IConfig */
37
+    private $config;
38 38
 
39
-	/**
40
-	 * @param IJobList $jobList
41
-	 * @param IConfig $config
42
-	 */
43
-	public function __construct(IJobList $jobList,
44
-								IConfig $config) {
45
-		$this->jobList = $jobList;
46
-		$this->config = $config;
47
-	}
39
+    /**
40
+     * @param IJobList $jobList
41
+     * @param IConfig $config
42
+     */
43
+    public function __construct(IJobList $jobList,
44
+                                IConfig $config) {
45
+        $this->jobList = $jobList;
46
+        $this->config = $config;
47
+    }
48 48
 
49
-	/**
50
-	 * @return string
51
-	 */
52
-	public function getName() {
53
-		return 'Regenerating birthday calendars to use new icons and fix old birthday events without year';
54
-	}
49
+    /**
50
+     * @return string
51
+     */
52
+    public function getName() {
53
+        return 'Regenerating birthday calendars to use new icons and fix old birthday events without year';
54
+    }
55 55
 
56
-	/**
57
-	 * @param IOutput $output
58
-	 */
59
-	public function run(IOutput $output) {
60
-		// only run once
61
-		if ($this->config->getAppValue('dav', 'regeneratedBirthdayCalendarsForYearFix') === 'yes') {
62
-			$output->info('Repair step already executed');
63
-			return;
64
-		}
56
+    /**
57
+     * @param IOutput $output
58
+     */
59
+    public function run(IOutput $output) {
60
+        // only run once
61
+        if ($this->config->getAppValue('dav', 'regeneratedBirthdayCalendarsForYearFix') === 'yes') {
62
+            $output->info('Repair step already executed');
63
+            return;
64
+        }
65 65
 
66
-		$output->info('Adding background jobs to regenerate birthday calendar');
67
-		$this->jobList->add(RegisterRegenerateBirthdayCalendars::class);
66
+        $output->info('Adding background jobs to regenerate birthday calendar');
67
+        $this->jobList->add(RegisterRegenerateBirthdayCalendars::class);
68 68
 
69
-		// if all were done, no need to redo the repair during next upgrade
70
-		$this->config->setAppValue('dav', 'regeneratedBirthdayCalendarsForYearFix', 'yes');
71
-	}
69
+        // if all were done, no need to redo the repair during next upgrade
70
+        $this->config->setAppValue('dav', 'regeneratedBirthdayCalendarsForYearFix', 'yes');
71
+    }
72 72
 }
Please login to merge, or discard this patch.
apps/twofactor_backupcodes/lib/Listener/ProviderEnabled.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -33,30 +33,30 @@
 block discarded – undo
33 33
 
34 34
 class ProviderEnabled implements IEventListener {
35 35
 
36
-	/** @var IRegistry */
37
-	private $registry;
38
-
39
-	/** @var IJobList */
40
-	private $jobList;
41
-
42
-	public function __construct(IRegistry $registry,
43
-								IJobList $jobList) {
44
-		$this->registry = $registry;
45
-		$this->jobList = $jobList;
46
-	}
47
-
48
-	public function handle(Event $event): void {
49
-		if (!($event instanceof RegistryEvent)) {
50
-			return;
51
-		}
52
-
53
-		$providers = $this->registry->getProviderStates($event->getUser());
54
-		if (isset($providers['backup_codes']) && $providers['backup_codes'] === true) {
55
-			// Backup codes already generated nothing to do here
56
-			return;
57
-		}
58
-
59
-		$this->jobList->add(RememberBackupCodesJob::class, ['uid' => $event->getUser()->getUID()]);
60
-	}
36
+    /** @var IRegistry */
37
+    private $registry;
38
+
39
+    /** @var IJobList */
40
+    private $jobList;
41
+
42
+    public function __construct(IRegistry $registry,
43
+                                IJobList $jobList) {
44
+        $this->registry = $registry;
45
+        $this->jobList = $jobList;
46
+    }
47
+
48
+    public function handle(Event $event): void {
49
+        if (!($event instanceof RegistryEvent)) {
50
+            return;
51
+        }
52
+
53
+        $providers = $this->registry->getProviderStates($event->getUser());
54
+        if (isset($providers['backup_codes']) && $providers['backup_codes'] === true) {
55
+            // Backup codes already generated nothing to do here
56
+            return;
57
+        }
58
+
59
+        $this->jobList->add(RememberBackupCodesJob::class, ['uid' => $event->getUser()->getUID()]);
60
+    }
61 61
 
62 62
 }
Please login to merge, or discard this patch.
apps/twofactor_backupcodes/lib/Listener/ClearNotifications.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -33,22 +33,22 @@
 block discarded – undo
33 33
 
34 34
 class ClearNotifications implements IEventListener {
35 35
 
36
-	/** @var IManager */
37
-	private $manager;
38
-
39
-	public function __construct(IManager $manager) {
40
-		$this->manager = $manager;
41
-	}
42
-
43
-	public function handle(Event $event): void {
44
-		if (!($event instanceof CodesGenerated)) {
45
-			return;
46
-		}
47
-
48
-		$notification = $this->manager->createNotification();
49
-		$notification->setApp('twofactor_backupcodes')
50
-			->setUser($event->getUser()->getUID())
51
-			->setObject('create', 'codes');
52
-		$this->manager->markProcessed($notification);
53
-	}
36
+    /** @var IManager */
37
+    private $manager;
38
+
39
+    public function __construct(IManager $manager) {
40
+        $this->manager = $manager;
41
+    }
42
+
43
+    public function handle(Event $event): void {
44
+        if (!($event instanceof CodesGenerated)) {
45
+            return;
46
+        }
47
+
48
+        $notification = $this->manager->createNotification();
49
+        $notification->setApp('twofactor_backupcodes')
50
+            ->setUser($event->getUser()->getUID())
51
+            ->setObject('create', 'codes');
52
+        $this->manager->markProcessed($notification);
53
+    }
54 54
 }
Please login to merge, or discard this patch.
apps/twofactor_backupcodes/lib/Listener/ActivityPublisher.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -33,36 +33,36 @@
 block discarded – undo
33 33
 
34 34
 class ActivityPublisher implements IEventListener {
35 35
 
36
-	/** @var IManager */
37
-	private $activityManager;
36
+    /** @var IManager */
37
+    private $activityManager;
38 38
 
39
-	/** @var ILogger */
40
-	private $logger;
39
+    /** @var ILogger */
40
+    private $logger;
41 41
 
42
-	public function __construct(IManager $activityManager,
43
-								ILogger $logger) {
44
-		$this->activityManager = $activityManager;
45
-		$this->logger = $logger;
46
-	}
42
+    public function __construct(IManager $activityManager,
43
+                                ILogger $logger) {
44
+        $this->activityManager = $activityManager;
45
+        $this->logger = $logger;
46
+    }
47 47
 
48
-	/**
49
-	 * Push an event to the user's activity stream
50
-	 */
51
-	public function handle(Event $event): void {
52
-		if ($event instanceof CodesGenerated) {
53
-			$activity = $this->activityManager->generateEvent();
54
-			$activity->setApp('twofactor_backupcodes')
55
-				->setType('security')
56
-				->setAuthor($event->getUser()->getUID())
57
-				->setAffectedUser($event->getUser()->getUID())
58
-				->setSubject('codes_generated');
59
-			try {
60
-				$this->activityManager->publish($activity);
61
-			} catch (BadMethodCallException $e) {
62
-				$this->logger->warning('could not publish backup code creation activity', ['app' => 'twofactor_backupcodes']);
63
-				$this->logger->logException($e, ['app' => 'twofactor_backupcodes']);
64
-			}
65
-		}
66
-	}
48
+    /**
49
+     * Push an event to the user's activity stream
50
+     */
51
+    public function handle(Event $event): void {
52
+        if ($event instanceof CodesGenerated) {
53
+            $activity = $this->activityManager->generateEvent();
54
+            $activity->setApp('twofactor_backupcodes')
55
+                ->setType('security')
56
+                ->setAuthor($event->getUser()->getUID())
57
+                ->setAffectedUser($event->getUser()->getUID())
58
+                ->setSubject('codes_generated');
59
+            try {
60
+                $this->activityManager->publish($activity);
61
+            } catch (BadMethodCallException $e) {
62
+                $this->logger->warning('could not publish backup code creation activity', ['app' => 'twofactor_backupcodes']);
63
+                $this->logger->logException($e, ['app' => 'twofactor_backupcodes']);
64
+            }
65
+        }
66
+    }
67 67
 
68 68
 }
Please login to merge, or discard this patch.
apps/twofactor_backupcodes/lib/Listener/RegistryUpdater.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -32,21 +32,21 @@
 block discarded – undo
32 32
 
33 33
 class RegistryUpdater implements IEventListener {
34 34
 
35
-	/** @var IRegistry */
36
-	private $registry;
37
-
38
-	/** @var BackupCodesProvider */
39
-	private $provider;
40
-
41
-	public function __construct(IRegistry $registry, BackupCodesProvider $provider) {
42
-		$this->registry = $registry;
43
-		$this->provider = $provider;
44
-	}
45
-
46
-	public function handle(Event $event): void {
47
-		if ($event instanceof CodesGenerated) {
48
-			$this->registry->enableProviderFor($this->provider, $event->getUser());
49
-		}
50
-	}
35
+    /** @var IRegistry */
36
+    private $registry;
37
+
38
+    /** @var BackupCodesProvider */
39
+    private $provider;
40
+
41
+    public function __construct(IRegistry $registry, BackupCodesProvider $provider) {
42
+        $this->registry = $registry;
43
+        $this->provider = $provider;
44
+    }
45
+
46
+    public function handle(Event $event): void {
47
+        if ($event instanceof CodesGenerated) {
48
+            $this->registry->enableProviderFor($this->provider, $event->getUser());
49
+        }
50
+    }
51 51
 
52 52
 }
Please login to merge, or discard this patch.