-
-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathFeedEntry.php
More file actions
36 lines (33 loc) · 900 Bytes
/
FeedEntry.php
File metadata and controls
36 lines (33 loc) · 900 Bytes
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
<?php
namespace Spekulatius\PHPScraper\DataTransferObjects;
/**
* A simplified DTO to hold feed entries with incomplete data.
*
* This isn't aimed at keeping all details but the key values.
*/
class FeedEntry
{
/**
* @todo with drop of PHP7.4 we should make these public and remove the initialization above.
* @todo with drop of PHP7.4 and 8.0 we should make this `readonly`.
*/
public function __construct(
// Support for PHP7.4
public string $title,
public string $description,
public string $link
) {
}
/**
* @param array<string, string> $data
**/
public static function fromArray(array $data): self
{
// Convert to an object and return the instance.
return new self(
$data['title'] ?? '',
$data['description'] ?? '',
$data['link']
);
}
}