File size: 4,354 Bytes
097eaf0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<?php

declare(strict_types=1);

namespace Firecrawl\Models;

final class Document
{
    /**
     * @param array<string, mixed>|null               $metadata
     * @param list<string>|null                        $links
     * @param list<string>|null                        $images
     * @param list<array<string, mixed>>|null          $attributes
     * @param array<string, mixed>|null               $actions
     * @param array<string, mixed>|null               $changeTracking
     * @param array<string, mixed>|null               $branding
     */
    public function __construct(
        private readonly ?string $markdown = null,
        private readonly ?string $html = null,
        private readonly ?string $rawHtml = null,
        private readonly mixed $json = null,
        private readonly ?string $summary = null,
        private readonly ?array $metadata = null,
        private readonly ?array $links = null,
        private readonly ?array $images = null,
        private readonly ?string $screenshot = null,
        private readonly ?string $audio = null,
        private readonly ?string $video = null,
        private readonly ?array $attributes = null,
        private readonly ?array $actions = null,
        private readonly ?string $answer = null,
        private readonly ?string $highlights = null,
        private readonly ?string $warning = null,
        private readonly ?array $changeTracking = null,
        private readonly ?array $branding = null,
    ) {}

    /** @param array<string, mixed> $data */
    public static function fromArray(array $data): self
    {
        return new self(
            markdown: $data['markdown'] ?? null,
            html: $data['html'] ?? null,
            rawHtml: $data['rawHtml'] ?? null,
            json: $data['json'] ?? null,
            summary: $data['summary'] ?? null,
            metadata: $data['metadata'] ?? null,
            links: $data['links'] ?? null,
            images: $data['images'] ?? null,
            screenshot: $data['screenshot'] ?? null,
            audio: $data['audio'] ?? null,
            video: $data['video'] ?? null,
            attributes: $data['attributes'] ?? null,
            actions: $data['actions'] ?? null,
            answer: $data['answer'] ?? null,
            highlights: $data['highlights'] ?? null,
            warning: $data['warning'] ?? null,
            changeTracking: $data['changeTracking'] ?? null,
            branding: $data['branding'] ?? null,
        );
    }

    public function getMarkdown(): ?string
    {
        return $this->markdown;
    }

    public function getHtml(): ?string
    {
        return $this->html;
    }

    public function getRawHtml(): ?string
    {
        return $this->rawHtml;
    }

    public function getJson(): mixed
    {
        return $this->json;
    }

    public function getSummary(): ?string
    {
        return $this->summary;
    }

    /** @return array<string, mixed>|null */
    public function getMetadata(): ?array
    {
        return $this->metadata;
    }

    /** @return list<string>|null */
    public function getLinks(): ?array
    {
        return $this->links;
    }

    /** @return list<string>|null */
    public function getImages(): ?array
    {
        return $this->images;
    }

    public function getScreenshot(): ?string
    {
        return $this->screenshot;
    }

    public function getAudio(): ?string
    {
        return $this->audio;
    }

    public function getVideo(): ?string
    {
        return $this->video;
    }

    /** @return list<array<string, mixed>>|null */
    public function getAttributes(): ?array
    {
        return $this->attributes;
    }

    /** @return array<string, mixed>|null */
    public function getActions(): ?array
    {
        return $this->actions;
    }

    public function getWarning(): ?string
    {
        return $this->warning;
    }

    public function getAnswer(): ?string
    {
        return $this->answer;
    }

    public function getHighlights(): ?string
    {
        return $this->highlights;
    }

    /** @return array<string, mixed>|null */
    public function getChangeTracking(): ?array
    {
        return $this->changeTracking;
    }

    /** @return array<string, mixed>|null */
    public function getBranding(): ?array
    {
        return $this->branding;
    }
}