File tree 3 files changed +66
-4
lines changed
3 files changed +66
-4
lines changed Original file line number Diff line number Diff line change @@ -159,7 +159,7 @@ public static function create(
159
159
array $ exactMatchingMetadata = [],
160
160
array $ suggest = []
161
161
) {
162
- return new self (
162
+ return new static (
163
163
$ uuid ,
164
164
null ,
165
165
$ metadata ,
@@ -192,7 +192,7 @@ public static function createLocated(
192
192
array $ exactMatchingMetadata = [],
193
193
array $ suggest = []
194
194
) {
195
- return new self (
195
+ return new static (
196
196
$ uuid ,
197
197
$ coordinate ,
198
198
$ metadata ,
@@ -617,7 +617,7 @@ public static function createFromArray(array $array): self
617
617
}
618
618
619
619
$ item = isset ($ array ['coordinate ' ])
620
- ? self ::createLocated (
620
+ ? static ::createLocated (
621
621
ItemUUID::createFromArray ($ array ['uuid ' ]),
622
622
Coordinate::createFromArray ($ array ['coordinate ' ]),
623
623
$ array ['metadata ' ] ?? [],
@@ -626,7 +626,7 @@ public static function createFromArray(array $array): self
626
626
$ array ['exact_matching_metadata ' ] ?? [],
627
627
$ array ['suggest ' ] ?? []
628
628
)
629
- : self ::create (
629
+ : static ::create (
630
630
ItemUUID::createFromArray ($ array ['uuid ' ]),
631
631
$ array ['metadata ' ] ?? [],
632
632
$ array ['indexed_metadata ' ] ?? [],
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Apisearch PHP Client.
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ *
9
+ * Feel free to edit as you please, and have fun.
10
+ *
11
+ * @author Marc Morera <[email protected] >
12
+ */
13
+
14
+ declare (strict_types=1 );
15
+
16
+ namespace Apisearch \Model ;
17
+
18
+ class ItemForDeletion extends Item
19
+ {
20
+ /**
21
+ * @param ItemUUID $uuid
22
+ *
23
+ * @return Item
24
+ */
25
+ public static function createByUUID (ItemUUID $ uuid )
26
+ {
27
+ return static ::create ($ uuid );
28
+ }
29
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Apisearch PHP Client.
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ *
9
+ * Feel free to edit as you please, and have fun.
10
+ *
11
+ * @author Marc Morera <[email protected] >
12
+ */
13
+
14
+ declare (strict_types=1 );
15
+
16
+ namespace Apisearch \Tests \Model ;
17
+
18
+ use Apisearch \Model \ItemForDeletion ;
19
+ use Apisearch \Model \ItemUUID ;
20
+ use PHPUnit \Framework \TestCase ;
21
+
22
+ class ItemForDeletionTest extends TestCase
23
+ {
24
+ public function testCreation ()
25
+ {
26
+ $ item = ItemForDeletion::createByUUID (ItemUUID::createByComposedUUID ('1~product ' ));
27
+ $ this ->assertEquals ('1~product ' , $ item ->composeUUID ());
28
+ $ this ->assertInstanceOf (ItemForDeletion::class, $ item );
29
+ $ item = ItemForDeletion::createFromArray ($ item ->toArray ());
30
+ $ this ->assertEquals ('1~product ' , $ item ->composeUUID ());
31
+ $ this ->assertInstanceOf (ItemForDeletion::class, $ item );
32
+ }
33
+ }
You can’t perform that action at this time.
0 commit comments