-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathSearchModel.php
More file actions
55 lines (49 loc) · 1.32 KB
/
Copy pathSearchModel.php
File metadata and controls
55 lines (49 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
declare(strict_types=1);
namespace Mindee\V2\Parsing\Search;
use Stringable;
/**
* Individual model information.
*/
class SearchModel implements Stringable
{
/**
* @var string Model ID.
*/
public string $id;
/**
* @var string Model name.
*/
public string $name;
/**
* @var string Model type.
*/
public string $modelType;
/**
* @var array<ModelWebhook> List of webhooks associated with the model.
*/
public array $webhooks;
/**
* @param array<string, int|float|string|bool|null|array<array-key, mixed>> $rawResponse Raw server response array.
*/
public function __construct(array $rawResponse)
{
$this->id = $rawResponse['id'];
$this->name = $rawResponse['name'];
$this->modelType = $rawResponse['model_type'];
$this->webhooks = array_map(
static fn($webhook) => new ModelWebhook($webhook),
$rawResponse['webhooks'] ?? []
);
}
/**
* @return string String representation.
*/
public function __toString(): string
{
return ":Name: $this->name\n"
. ":ID: $this->id\n"
. ":Model Type: $this->modelType\n"
. ":Webhooks: " . implode(', ', array_map(static fn($webhook) => $webhook->name, $this->webhooks)) . "\n";
}
}