forked from spatie/ray
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRequest.php
44 lines (33 loc) · 820 Bytes
/
Request.php
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
<?php
namespace Spatie\Ray;
use Spatie\Ray\Payloads\Payload;
class Request
{
/** @var string */
protected $uuid;
/** @var array */
protected $payloads;
/** @var array */
protected $meta;
public function __construct(string $uuid, array $payloads, array $meta = [])
{
$this->uuid = $uuid;
$this->payloads = $payloads;
$this->meta = $meta;
}
public function toArray(): array
{
$payloads = array_map(function (Payload $payload) {
return $payload->toArray();
}, $this->payloads);
return [
'uuid' => $this->uuid,
'payloads' => $payloads,
'meta' => $this->meta,
];
}
public function toJson(): string
{
return json_encode($this->toArray());
}
}