Skip to content

Commit

Permalink
0.3.10
Browse files Browse the repository at this point in the history
- add `titleMeta()` to `BookEntity` with extra infos with title slug and series slug
- move `ComicMeta` to `Kiwilan\Ebook\Entity\ComicMeta`
  • Loading branch information
ewilan-riviere committed May 5, 2023
1 parent 024f34a commit b3a3988
Show file tree
Hide file tree
Showing 10 changed files with 514 additions and 190 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ $hasMetadata = $ebook->hasMetadata(); // bool
$book = $ebook->book(); // BookEntity

$book->title(); // string
$book->titleMeta(); // TitleMeta, with `slug` and `sort` properties for `title` and `series`
$book->authors(); // BookCreator[] (name: string, role: string)
$book->authorFirst(); // First BookCreator (name: string, role: string)
$book->description(); // string
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "kiwilan/php-ebook",
"description": "PHP package to read metadata and extract covers from eBooks (.epub, .cbz, .cbr, .cb7, .cbt, .pdf).",
"version": "0.3.0",
"version": "0.3.10",
"keywords": [
"php",
"ebook",
Expand Down
206 changes: 19 additions & 187 deletions src/BookEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
use DateTime;
use Kiwilan\Ebook\Book\BookCreator;
use Kiwilan\Ebook\Book\BookIdentifier;
use Kiwilan\Ebook\Entity\ComicMeta;
use Kiwilan\Ebook\Entity\TitleMeta;
use Kiwilan\Ebook\Enums\AgeRatingEnum;
use Kiwilan\Ebook\Enums\MangaEnum;

class BookEntity
{
protected ?string $title = null;

protected ?TitleMeta $titleMeta = null;

protected ?BookCreator $authorFirst = null;

/** @var BookCreator[] */
Expand Down Expand Up @@ -86,6 +90,14 @@ public function title(): ?string
return $this->title;
}

/**
* Title metadata of the book with slug, sort title, series slug, etc.
*/
public function titleMeta(): ?TitleMeta
{
return $this->titleMeta;
}

/**
* First author of the book (useful if you need to display only one author).
*/
Expand Down Expand Up @@ -287,6 +299,13 @@ public function setTitle(?string $title): self
return $this;
}

public function setTitleMeta(Ebook $ebook): self
{
$this->titleMeta = TitleMeta::make($ebook);

return $this;
}

public function setAuthorFirst(?BookCreator $authorFirst): self
{
$this->authorFirst = $authorFirst;
Expand Down Expand Up @@ -515,190 +534,3 @@ public function __toString(): string
return "{$this->title} by {$authors}";
}
}

class ComicMeta
{
/** @var string[] */
protected ?array $characters = null;

/** @var string[] */
protected ?array $teams = null;

/** @var string[] */
protected ?array $locations = null;

public function __construct(
protected ?string $alternateSeries = null,
protected ?int $alternateNumber = null,
protected ?string $alternateCount = null,
protected ?int $count = null,
protected ?int $volume = null,
protected ?string $storyArc = null,
protected ?int $storyArcNumber = null,
protected ?string $seriesGroup = null,
protected ?string $imprint = null,
) {
}

/**
* @return string[]
*/
public function characters(): array
{
return $this->characters;
}

/**
* @return string[]
*/
public function teams(): array
{
return $this->teams;
}

/**
* @return string[]
*/
public function locations(): array
{
return $this->locations;
}

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

public function alternateNumber(): ?int
{
return $this->alternateNumber;
}

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

public function count(): ?int
{
return $this->count;
}

public function volume(): ?int
{
return $this->volume;
}

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

public function storyArcNumber(): ?int
{
return $this->storyArcNumber;
}

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

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

/**
* @param string[] $characters
*/
public function setCharacters(array $characters): self
{
$this->characters = $characters;

return $this;
}

/**
* @param string[] $teams
*/
public function setTeams(array $teams): self
{
$this->teams = $teams;

return $this;
}

/**
* @param string[] $locations
*/
public function setLocations(array $locations): self
{
$this->locations = $locations;

return $this;
}

public function setAlternateSeries(?string $alternateSeries): self
{
$this->alternateSeries = $alternateSeries;

return $this;
}

public function setAlternateNumber(?int $alternateNumber): self
{
$this->alternateNumber = $alternateNumber;

return $this;
}

public function setAlternateCount(?string $alternateCount): self
{
$this->alternateCount = $alternateCount;

return $this;
}

public function setCount(?int $count): self
{
$this->count = $count;

return $this;
}

public function setVolume(?int $volume): self
{
$this->volume = $volume;

return $this;
}

public function setStoryArc(?string $storyArc): self
{
$this->storyArc = $storyArc;

return $this;
}

public function setStoryArcNumber(?int $storyArcNumber): self
{
$this->storyArcNumber = $storyArcNumber;

return $this;
}

public function setSeriesGroup(?string $seriesGroup): self
{
$this->seriesGroup = $seriesGroup;

return $this;
}

public function setImprint(?string $imprint): self
{
$this->imprint = $imprint;

return $this;
}
}
2 changes: 1 addition & 1 deletion src/Cba/CbaCbam.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use DateTime;
use Kiwilan\Ebook\Book\BookCreator;
use Kiwilan\Ebook\BookEntity;
use Kiwilan\Ebook\ComicMeta;
use Kiwilan\Ebook\Entity\ComicMeta;
use Kiwilan\Ebook\Enums\AgeRatingEnum;
use Kiwilan\Ebook\Enums\MangaEnum;

Expand Down
2 changes: 2 additions & 0 deletions src/Ebook.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public static function read(string $path): self
'pdf' => $self->pdf(),
};

$self->book?->setTitleMeta($self);

return $self;
}

Expand Down
Loading

0 comments on commit b3a3988

Please sign in to comment.