Skip to content
This repository was archived by the owner on Jun 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Model/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public static function create(
array $exactMatchingMetadata = [],
array $suggest = []
) {
return new self(
return new static(
$uuid,
null,
$metadata,
Expand Down Expand Up @@ -192,7 +192,7 @@ public static function createLocated(
array $exactMatchingMetadata = [],
array $suggest = []
) {
return new self(
return new static(
$uuid,
$coordinate,
$metadata,
Expand Down Expand Up @@ -617,7 +617,7 @@ public static function createFromArray(array $array): self
}

$item = isset($array['coordinate'])
? self::createLocated(
? static::createLocated(
ItemUUID::createFromArray($array['uuid']),
Coordinate::createFromArray($array['coordinate']),
$array['metadata'] ?? [],
Expand All @@ -626,7 +626,7 @@ public static function createFromArray(array $array): self
$array['exact_matching_metadata'] ?? [],
$array['suggest'] ?? []
)
: self::create(
: static::create(
ItemUUID::createFromArray($array['uuid']),
$array['metadata'] ?? [],
$array['indexed_metadata'] ?? [],
Expand Down
29 changes: 29 additions & 0 deletions Model/ItemForDeletion.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/*
* This file is part of the Apisearch PHP Client.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Feel free to edit as you please, and have fun.
*
* @author Marc Morera <[email protected]>
*/

declare(strict_types=1);

namespace Apisearch\Model;

class ItemForDeletion extends Item
{
/**
* @param ItemUUID $uuid
*
* @return Item
*/
public static function createByUUID(ItemUUID $uuid)
{
return static::create($uuid);
}
}
33 changes: 33 additions & 0 deletions Tests/Model/ItemForDeletionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/*
* This file is part of the Apisearch PHP Client.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Feel free to edit as you please, and have fun.
*
* @author Marc Morera <[email protected]>
*/

declare(strict_types=1);

namespace Apisearch\Tests\Model;

use Apisearch\Model\ItemForDeletion;
use Apisearch\Model\ItemUUID;
use PHPUnit\Framework\TestCase;

class ItemForDeletionTest extends TestCase
{
public function testCreation()
{
$item = ItemForDeletion::createByUUID(ItemUUID::createByComposedUUID('1~product'));
$this->assertEquals('1~product', $item->composeUUID());
$this->assertInstanceOf(ItemForDeletion::class, $item);
$item = ItemForDeletion::createFromArray($item->toArray());
$this->assertEquals('1~product', $item->composeUUID());
$this->assertInstanceOf(ItemForDeletion::class, $item);
}
}