init
This commit is contained in:
commit
72a26edcff
22092 changed files with 2101903 additions and 0 deletions
36
lib/sc/src/DataTransferObjects/FeedEntry.php
Normal file
36
lib/sc/src/DataTransferObjects/FeedEntry.php
Normal file
|
|
@ -0,0 +1,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']
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue