16
16
namespace Apisearch \Model ;
17
17
18
18
use Apisearch \Exception \InvalidFormatException ;
19
+ use Apisearch \Repository \RepositoryReference ;
19
20
20
21
/**
21
22
* Class Item.
@@ -99,6 +100,11 @@ class Item implements HttpTransportable, UUIDReference
99
100
*/
100
101
private $ score ;
101
102
103
+ /**
104
+ * @var RepositoryReference
105
+ */
106
+ private $ repositoryReference ;
107
+
102
108
/**
103
109
* Item constructor.
104
110
*
@@ -489,6 +495,22 @@ public function setScore(float $score)
489
495
return $ this ;
490
496
}
491
497
498
+ /**
499
+ * @return RepositoryReference|null
500
+ */
501
+ public function getRepositoryReference ():? RepositoryReference
502
+ {
503
+ return $ this ->repositoryReference ;
504
+ }
505
+
506
+ /**
507
+ * @param RepositoryReference $repositoryReference
508
+ */
509
+ public function setRepositoryReference (RepositoryReference $ repositoryReference )
510
+ {
511
+ $ this ->repositoryReference = $ repositoryReference ;
512
+ }
513
+
492
514
/**
493
515
* To array.
494
516
*
@@ -510,6 +532,9 @@ public function toArray(): array
510
532
'highlights ' => $ this ->highlights ,
511
533
'is_promoted ' => !$ this ->promoted ? null : true ,
512
534
'score ' => $ this ->score ,
535
+ 'repository_reference ' => $ this ->repositoryReference instanceof RepositoryReference
536
+ ? $ this ->repositoryReference ->compose ()
537
+ : null ,
513
538
], function ($ element ) {
514
539
return
515
540
!(
@@ -577,6 +602,10 @@ public static function createFromArray(array $array): self
577
602
$ item ->setScore ((float ) $ array ['score ' ]);
578
603
}
579
604
605
+ if (isset ($ array ['repository_reference ' ]) && !is_null ($ array ['repository_reference ' ])) {
606
+ $ item ->setRepositoryReference (RepositoryReference::createFromComposed ($ array ['repository_reference ' ]));
607
+ }
608
+
580
609
return $ item ;
581
610
}
582
611
0 commit comments