-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathSearchModels.php
More file actions
47 lines (38 loc) · 1.08 KB
/
Copy pathSearchModels.php
File metadata and controls
47 lines (38 loc) · 1.08 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
<?php
declare(strict_types=1);
namespace Mindee\V2\Parsing\Search;
use ArrayObject;
use Stringable;
use function count;
/**
* Array of search models.
* @extends ArrayObject<int, SearchModel>
*/
class SearchModels extends ArrayObject implements Stringable
{
/**
* @param array<array<string, int|float|string|bool|null|array<array-key, mixed>>> $prediction Raw prediction.
*/
public function __construct(array $prediction)
{
$models = array_map(static fn($entry) => new SearchModel($entry), $prediction);
parent::__construct($models);
}
/**
* Default string representation.
*/
public function __toString(): string
{
if ($this->count() === 0) {
return "\n";
}
$lines = [];
foreach ($this as $model) {
$lines[] = "* :Name: " . $model->name;
$lines[] = " :ID: " . $model->id;
$lines[] = " :Model Type: " . $model->modelType;
$lines[] = " :Webhooks: " . count($model->webhooks);
}
return implode("\n", $lines) . "\n";
}
}