Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Spatie\LaravelIgnition\Support;
4
 
5
use Illuminate\Support\Arr;
6
use Spatie\FlareClient\Report;
7
 
8
class SentReports
9
{
10
    /** @var array<int, Report> */
11
    protected array $reports = [];
12
 
13
    public function add(Report $report): self
14
    {
15
        $this->reports[] = $report;
16
 
17
        return $this;
18
    }
19
 
20
    /**  @return array<int, Report> */
21
    public function all(): array
22
    {
23
        return $this->reports;
24
    }
25
 
26
    /** @return array<int, string> */
27
    public function uuids(): array
28
    {
29
        return array_map(fn (Report $report) => $report->trackingUuid(), $this->reports);
30
    }
31
 
32
    /** @return array<int, string> */
33
    public function urls(): array
34
    {
35
        return array_map(function (string $trackingUuid) {
36
            return "https://flareapp.io/tracked-occurrence/{$trackingUuid}";
37
        }, $this->uuids());
38
    }
39
 
40
    public function latestUuid(): ?string
41
    {
42
        return Arr::last($this->reports)?->trackingUuid();
43
    }
44
 
45
    public function latestUrl(): ?string
46
    {
47
        return Arr::last($this->urls());
48
    }
49
 
50
    public function clear(): void
51
    {
52
        $this->reports = [];
53
    }
54
}