Initial commit
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\FeedManagement\Application\ReadModel;
|
||||
|
||||
use App\Aggregator\Domain\Model\Identity\ArticleId;
|
||||
use App\Aggregator\Domain\Model\ValueObject\Crawling\OpenGraph;
|
||||
use App\Aggregator\Domain\Model\ValueObject\Link;
|
||||
use App\Aggregator\Domain\Model\ValueObject\ReadingTime;
|
||||
use App\Aggregator\Domain\Model\ValueObject\Scoring\Bias;
|
||||
use App\Aggregator\Domain\Model\ValueObject\Scoring\Credibility;
|
||||
use App\Aggregator\Domain\Model\ValueObject\Scoring\Reliability;
|
||||
use App\Aggregator\Domain\Model\ValueObject\Scoring\Sentiment;
|
||||
use App\Aggregator\Domain\Model\ValueObject\Scoring\Transparency;
|
||||
use App\SharedKernel\Domain\DataTransfert\DataMapping;
|
||||
|
||||
/**
|
||||
* Class ArticleDetails.
|
||||
*
|
||||
* @author bernard-ng <bernard@devscast.tech>
|
||||
*/
|
||||
final readonly class ArticleDetails
|
||||
{
|
||||
public function __construct(
|
||||
public ArticleId $id,
|
||||
public string $title,
|
||||
public Link $link,
|
||||
public array $categories,
|
||||
public string $body,
|
||||
public SourceReference $source,
|
||||
public string $hash,
|
||||
public Credibility $credibility,
|
||||
public Sentiment $sentiment,
|
||||
public ?OpenGraph $metadata,
|
||||
public ReadingTime $readingTime,
|
||||
public \DateTimeImmutable $publishedAt,
|
||||
public \DateTimeImmutable $crawledAt,
|
||||
public ?\DateTimeImmutable $updatedAt,
|
||||
public bool $bookmarked = false
|
||||
) {
|
||||
}
|
||||
|
||||
public static function create(array $item): self
|
||||
{
|
||||
return new self(
|
||||
ArticleId::fromBinary($item['article_id']),
|
||||
DataMapping::string($item, 'article_title'),
|
||||
Link::from(DataMapping::string($item, 'article_link')),
|
||||
explode(',', DataMapping::string($item, 'article_categories')),
|
||||
DataMapping::string($item, 'article_body'),
|
||||
SourceReference::create($item),
|
||||
DataMapping::string($item, 'article_hash'),
|
||||
new Credibility(
|
||||
DataMapping::enum($item, 'article_bias', Bias::class),
|
||||
DataMapping::enum($item, 'article_reliability', Reliability::class),
|
||||
DataMapping::enum($item, 'article_transparency', Transparency::class)
|
||||
),
|
||||
DataMapping::enum($item, 'article_sentiment', Sentiment::class),
|
||||
OpenGraph::tryFrom(DataMapping::nullableString($item, 'article_metadata')),
|
||||
ReadingTime::create(DataMapping::nullableInteger($item, 'article_reading_time')),
|
||||
DataMapping::datetime($item, 'article_published_at'),
|
||||
DataMapping::datetime($item, 'article_crawled_at'),
|
||||
DataMapping::nullableDatetime($item, 'article_updated_at'),
|
||||
DataMapping::boolean($item, 'article_is_bookmarked'),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\FeedManagement\Application\ReadModel;
|
||||
|
||||
use App\Aggregator\Domain\Model\Identity\ArticleId;
|
||||
use App\Aggregator\Domain\Model\ValueObject\Link;
|
||||
use App\Aggregator\Domain\Model\ValueObject\ReadingTime;
|
||||
use App\SharedKernel\Domain\DataTransfert\DataMapping;
|
||||
|
||||
/**
|
||||
* Class ArticleOverview.
|
||||
*
|
||||
* @author bernard-ng <bernard@devscast.tech>
|
||||
*/
|
||||
final readonly class ArticleOverview
|
||||
{
|
||||
public function __construct(
|
||||
public ArticleId $id,
|
||||
public string $title,
|
||||
public Link $link,
|
||||
public array $categories,
|
||||
public string $excerpt,
|
||||
public SourceReference $source,
|
||||
public ?string $image,
|
||||
public ReadingTime $readingTime,
|
||||
public \DateTimeImmutable $publishedAt,
|
||||
public bool $bookmarked = false
|
||||
) {
|
||||
}
|
||||
|
||||
public static function create(array $item): self
|
||||
{
|
||||
return new self(
|
||||
ArticleId::fromBinary($item['article_id']),
|
||||
DataMapping::string($item, 'article_title'),
|
||||
Link::from(DataMapping::string($item, 'article_link')),
|
||||
explode(',', DataMapping::string($item, 'article_categories')),
|
||||
trim(DataMapping::string($item, 'article_excerpt')),
|
||||
SourceReference::create($item),
|
||||
DataMapping::nullableString($item, 'article_image'),
|
||||
ReadingTime::create(DataMapping::nullableInteger($item, 'article_reading_time')),
|
||||
DataMapping::datetime($item, 'article_published_at'),
|
||||
DataMapping::boolean($item, 'article_is_bookmarked'),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\FeedManagement\Application\ReadModel;
|
||||
|
||||
use App\SharedKernel\Domain\Assert;
|
||||
use App\SharedKernel\Domain\Model\Pagination\PaginationInfo;
|
||||
|
||||
/**
|
||||
* Class ArticleOverviewList.
|
||||
*
|
||||
* @author bernard-ng <bernard@devscast.tech>
|
||||
*/
|
||||
final readonly class ArticleOverviewList
|
||||
{
|
||||
public function __construct(
|
||||
public array $items,
|
||||
public PaginationInfo $pagination
|
||||
) {
|
||||
Assert::allIsInstanceOf($this->items, ArticleOverview::class);
|
||||
}
|
||||
|
||||
public static function create(array $items, PaginationInfo $pagination): self
|
||||
{
|
||||
return new self(
|
||||
array_map(fn (array $item): ArticleOverview => ArticleOverview::create($item), $items),
|
||||
$pagination
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\FeedManagement\Application\ReadModel;
|
||||
|
||||
use App\FeedManagement\Domain\Model\Identity\BookmarkId;
|
||||
use App\SharedKernel\Domain\DataTransfert\DataMapping;
|
||||
|
||||
/**
|
||||
* Class Bookmark.
|
||||
*
|
||||
* @author bernard-ng <bernard@devscast.tech>
|
||||
*/
|
||||
final readonly class Bookmark
|
||||
{
|
||||
public function __construct(
|
||||
public BookmarkId $id,
|
||||
public string $name,
|
||||
public \DateTimeImmutable $createdAt,
|
||||
public ?string $description = null,
|
||||
public int $articlesCount = 0,
|
||||
public bool $isPublic = false,
|
||||
public ?\DateTimeImmutable $updatedAt = null
|
||||
) {
|
||||
}
|
||||
|
||||
public static function create(array $item): self
|
||||
{
|
||||
return new self(
|
||||
BookmarkId::fromBinary($item['bookmark_id']),
|
||||
DataMapping::string($item, 'bookmark_name'),
|
||||
DataMapping::datetime($item, 'bookmark_created_at'),
|
||||
DataMapping::nullableString($item, 'bookmark_description'),
|
||||
DataMapping::integer($item, 'bookmark_articles_count'),
|
||||
DataMapping::boolean($item, 'bookmark_is_public'),
|
||||
DataMapping::nullableDatetime($item, 'bookmark_updated_at')
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\FeedManagement\Application\ReadModel;
|
||||
|
||||
use App\SharedKernel\Domain\Assert;
|
||||
use App\SharedKernel\Domain\Model\Pagination\PaginationInfo;
|
||||
|
||||
/**
|
||||
* Class BookmarkList.
|
||||
*
|
||||
* @author bernard-ng <bernard@devscast.tech>
|
||||
*/
|
||||
final readonly class BookmarkList
|
||||
{
|
||||
public function __construct(
|
||||
public array $items,
|
||||
public PaginationInfo $pagination
|
||||
) {
|
||||
Assert::allIsInstanceOf($this->items, Bookmark::class);
|
||||
}
|
||||
|
||||
public static function create(array $items, PaginationInfo $pagination): self
|
||||
{
|
||||
return new self(
|
||||
array_map(fn (array $item): Bookmark => Bookmark::create($item), $items),
|
||||
$pagination
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\FeedManagement\Application\ReadModel;
|
||||
|
||||
/**
|
||||
* Class CategoryShare.
|
||||
*
|
||||
* @author bernard-ng <bernard@devscast.tech>
|
||||
*/
|
||||
final readonly class CategoryShare
|
||||
{
|
||||
public function __construct(
|
||||
public string $category,
|
||||
public int $count,
|
||||
public float $percentage
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\FeedManagement\Application\ReadModel;
|
||||
|
||||
use App\SharedKernel\Domain\Assert;
|
||||
|
||||
/**
|
||||
* Class CategoryShares.
|
||||
*
|
||||
* @author bernard-ng <bernard@devscast.tech>
|
||||
*/
|
||||
final readonly class CategoryShares
|
||||
{
|
||||
public function __construct(
|
||||
public array $items = [],
|
||||
public int $total = 0
|
||||
) {
|
||||
Assert::allIsInstanceOf($this->items, CategoryShare::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\FeedManagement\Application\ReadModel;
|
||||
|
||||
use App\Aggregator\Domain\Model\ValueObject\Scoring\Sentiment;
|
||||
use App\FeedManagement\Domain\Model\Identity\CommentId;
|
||||
use App\SharedKernel\Domain\DataTransfert\DataMapping;
|
||||
|
||||
/**
|
||||
* Class Comment.
|
||||
*
|
||||
* @author bernard-ng <bernard@devscast.tech>
|
||||
*/
|
||||
final readonly class Comment
|
||||
{
|
||||
public function __construct(
|
||||
public CommentId $id,
|
||||
public UserReference $user,
|
||||
public Sentiment $sentiment,
|
||||
public string $content,
|
||||
public \DateTimeImmutable $createdAt,
|
||||
) {
|
||||
}
|
||||
|
||||
public static function create(array $item): self
|
||||
{
|
||||
return new self(
|
||||
CommentId::fromBinary($item['comment_id']),
|
||||
UserReference::create($item),
|
||||
DataMapping::enum($item, 'comment_sentiment', Sentiment::class),
|
||||
DataMapping::string($item, 'comment_content'),
|
||||
DataMapping::dateTime($item, 'comment_created_at')
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\FeedManagement\Application\ReadModel;
|
||||
|
||||
use App\SharedKernel\Domain\Assert;
|
||||
use App\SharedKernel\Domain\Model\Pagination\PaginationInfo;
|
||||
|
||||
/**
|
||||
* Class CommentList.
|
||||
*
|
||||
* @author bernard-ng <bernard@devscast.tech>
|
||||
*/
|
||||
final readonly class CommentList
|
||||
{
|
||||
public function __construct(
|
||||
public array $items,
|
||||
public PaginationInfo $pagination
|
||||
) {
|
||||
Assert::allIsInstanceOf($this->items, Comment::class);
|
||||
}
|
||||
|
||||
public static function create(array $items, PaginationInfo $pagination): self
|
||||
{
|
||||
return new self(
|
||||
array_map(fn (array $item): Comment => Comment::create($item), $items),
|
||||
$pagination
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\FeedManagement\Application\ReadModel;
|
||||
|
||||
/**
|
||||
* Class DallyEntry.
|
||||
*
|
||||
* @author bernard-ng <bernard@devscast.tech>
|
||||
*/
|
||||
final readonly class PublicationEntry
|
||||
{
|
||||
public function __construct(
|
||||
public string $date,
|
||||
public int $count
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\FeedManagement\Application\ReadModel;
|
||||
|
||||
use App\SharedKernel\Domain\Assert;
|
||||
|
||||
/**
|
||||
* Class PublicationGraph.
|
||||
*
|
||||
* @author bernard-ng <bernard@devscast.tech>
|
||||
*/
|
||||
final readonly class PublicationGraph
|
||||
{
|
||||
public function __construct(
|
||||
public array $items = [],
|
||||
public int $total = 0
|
||||
) {
|
||||
Assert::allIsInstanceOf($this->items, PublicationEntry::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\FeedManagement\Application\ReadModel;
|
||||
|
||||
use App\Aggregator\Domain\Model\Identity\SourceId;
|
||||
use App\Aggregator\Domain\Model\ValueObject\Scoring\Bias;
|
||||
use App\Aggregator\Domain\Model\ValueObject\Scoring\Credibility;
|
||||
use App\Aggregator\Domain\Model\ValueObject\Scoring\Reliability;
|
||||
use App\Aggregator\Domain\Model\ValueObject\Scoring\Transparency;
|
||||
use App\SharedKernel\Domain\DataTransfert\DataMapping;
|
||||
|
||||
/**
|
||||
* Class SourceDetails.
|
||||
*
|
||||
* @author bernard-ng <bernard@devscast.tech>
|
||||
*/
|
||||
final readonly class SourceDetails
|
||||
{
|
||||
public function __construct(
|
||||
public SourceId $id,
|
||||
public string $name,
|
||||
public string $url,
|
||||
public Credibility $credibility,
|
||||
public PublicationGraph $publicationGraph,
|
||||
public CategoryShares $categoryShares,
|
||||
public int $articlesCount,
|
||||
public string $crawledAt,
|
||||
public ?string $displayName = null,
|
||||
public ?string $description = null,
|
||||
public ?string $updatedAt = null,
|
||||
public int $metadataAvailable = 0,
|
||||
public bool $followed = false,
|
||||
public ?string $image = null,
|
||||
) {
|
||||
}
|
||||
|
||||
public static function create(array $item, PublicationGraph $publicationGraph, CategoryShares $categoryShares): self
|
||||
{
|
||||
return new self(
|
||||
SourceId::fromBinary($item['source_id']),
|
||||
DataMapping::string($item, 'source_name'),
|
||||
DataMapping::string($item, 'source_url'),
|
||||
new Credibility(
|
||||
DataMapping::enum($item, 'source_bias', Bias::class),
|
||||
DataMapping::enum($item, 'source_reliability', Reliability::class),
|
||||
DataMapping::enum($item, 'source_transparency', Transparency::class)
|
||||
),
|
||||
$publicationGraph,
|
||||
$categoryShares,
|
||||
DataMapping::integer($item, 'articles_count'),
|
||||
DataMapping::string($item, 'source_crawled_at'),
|
||||
DataMapping::nullableString($item, 'source_display_name'),
|
||||
DataMapping::nullableString($item, 'source_description'),
|
||||
DataMapping::nullableString($item, 'source_updated_at'),
|
||||
DataMapping::integer($item, 'articles_metadata_available'),
|
||||
DataMapping::boolean($item, 'source_is_followed'),
|
||||
DataMapping::nullableString($item, 'source_image'),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\FeedManagement\Application\ReadModel;
|
||||
|
||||
use App\Aggregator\Domain\Model\Identity\SourceId;
|
||||
use App\SharedKernel\Domain\DataTransfert\DataMapping;
|
||||
|
||||
/**
|
||||
* Class SourceOverview.
|
||||
*
|
||||
* @author bernard-ng <bernard@devscast.tech>
|
||||
*/
|
||||
final readonly class SourceOverview
|
||||
{
|
||||
public function __construct(
|
||||
public SourceId $id,
|
||||
public string $name,
|
||||
public string $url,
|
||||
public ?string $displayName = null,
|
||||
public bool $followed = false,
|
||||
public ?string $image = null
|
||||
) {
|
||||
}
|
||||
|
||||
public static function create(array $item): self
|
||||
{
|
||||
return new self(
|
||||
SourceId::fromBinary($item['source_id']),
|
||||
DataMapping::string($item, 'source_name'),
|
||||
DataMapping::string($item, 'source_url'),
|
||||
DataMapping::nullableString($item, 'source_display_name'),
|
||||
DataMapping::boolean($item, 'source_is_followed'),
|
||||
DataMapping::nullableString($item, 'source_image')
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\FeedManagement\Application\ReadModel;
|
||||
|
||||
use App\SharedKernel\Domain\Assert;
|
||||
use App\SharedKernel\Domain\Model\Pagination\PaginationInfo;
|
||||
|
||||
/**
|
||||
* Class SourceOverviewList.
|
||||
*
|
||||
* @author bernard-ng <bernard@devscast.tech>
|
||||
*/
|
||||
final readonly class SourceOverviewList
|
||||
{
|
||||
public function __construct(
|
||||
public array $items,
|
||||
public PaginationInfo $pagination,
|
||||
) {
|
||||
Assert::allIsInstanceOf($items, SourceOverview::class);
|
||||
}
|
||||
|
||||
public static function create(array $items, PaginationInfo $pagination): self
|
||||
{
|
||||
return new self(
|
||||
array_map(fn (array $item): SourceOverview => SourceOverview::create($item), $items),
|
||||
$pagination
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\FeedManagement\Application\ReadModel;
|
||||
|
||||
use App\Aggregator\Domain\Model\Identity\SourceId;
|
||||
use App\SharedKernel\Domain\DataTransfert\DataMapping;
|
||||
|
||||
/**
|
||||
* Class SourceReference.
|
||||
*
|
||||
* @author bernard-ng <bernard@devscast.tech>
|
||||
*/
|
||||
final readonly class SourceReference
|
||||
{
|
||||
public function __construct(
|
||||
public SourceId $id,
|
||||
public string $name,
|
||||
public ?string $displayName,
|
||||
public ?string $image,
|
||||
public string $url
|
||||
) {
|
||||
}
|
||||
|
||||
public static function create(array $item): self
|
||||
{
|
||||
return new self(
|
||||
SourceId::fromBinary($item['source_id']),
|
||||
DataMapping::string($item, 'source_name'),
|
||||
DataMapping::nullableString($item, 'source_display_name'),
|
||||
DataMapping::nullableString($item, 'source_image'),
|
||||
DataMapping::string($item, 'source_url'),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\FeedManagement\Application\ReadModel;
|
||||
|
||||
use App\IdentityAndAccess\Domain\Model\Identity\UserId;
|
||||
use App\SharedKernel\Domain\DataTransfert\DataMapping;
|
||||
|
||||
/**
|
||||
* Class UserReference.
|
||||
*
|
||||
* @author bernard-ng <bernard@devscast.tech>
|
||||
*/
|
||||
final readonly class UserReference
|
||||
{
|
||||
public function __construct(
|
||||
public UserId $id,
|
||||
public string $name,
|
||||
) {
|
||||
}
|
||||
|
||||
public static function create(array $item): self
|
||||
{
|
||||
return new self(
|
||||
UserId::fromBinary($item['user_id']),
|
||||
DataMapping::string($item, 'user_name')
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user