Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
ewilan-riviere committed Jul 11, 2024
1 parent 45cbfb6 commit 4aa41e9
Show file tree
Hide file tree
Showing 21 changed files with 72 additions and 37 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,14 @@ $ebook = Ebook::read('path/to/ebook.epub');
$metaTitle = $ebook->getMetaTitle(); // ?MetaTitle

$metaTitle->getSlug(); // string => slug title, like `lord-of-the-rings-en-01-fellowship-of-the-ring-j-r-r-tolkien-1954-epub`
$metaTitle->getSeriesSlug(); // ?string => slug series title, like `lord-of-the-rings-en-epub`
$metaTitle->getSeriesSlug(); // ?string => slug series title, like `lord-of-the-rings-en`
```

You can customize slug with `MetaTitle::class`:

```php
$meta->getSlug(removeDeterminers: true, addSeries: true, addVolume: true, addAuthor: true, addYear: true, addExtension: true, addLanguage: true);
$meta->getSeriesSlug(removeDeterminers: true, addAuthor: false, addExtension: true, addLanguage: true);
$meta->getSeriesSlug(removeDeterminers: true, addAuthor: false, addExtension: false, addLanguage: true);
```

### Cover
Expand Down
3 changes: 2 additions & 1 deletion src/Creator/EbookCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class EbookCreator
public function __construct(
protected string $path,
protected ArchiveZipCreate $archive,
) {}
) {
}

public static function create(string $path): ArchiveZipCreate
{
Expand Down
3 changes: 2 additions & 1 deletion src/Ebook.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ protected function __construct(
protected bool $isBadFile = false,
protected ?EbookParser $parser = null,
protected bool $hasParser = false,
) {}
) {
}

/**
* Read an ebook file.
Expand Down
3 changes: 2 additions & 1 deletion src/EbookCover.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class EbookCover
protected function __construct(
protected ?string $path = null,
protected ?string $contents = null,
) {}
) {
}

public static function make(?string $path = null, ?string $contents = null): ?self
{
Expand Down
3 changes: 2 additions & 1 deletion src/Formats/Cba/Parser/CbamTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ class CbamTemplate extends CbaTemplate

protected function __construct(
protected XmlReader $xml,
) {}
) {
}

public static function make(XmlReader $xml): self
{
Expand Down
3 changes: 2 additions & 1 deletion src/Formats/Djvu/Parser/DjvuParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ class DjvuParser
{
protected function __construct(
protected string $path,
) {}
) {
}

public static function make(string $path): DjvuParser
{
Expand Down
3 changes: 2 additions & 1 deletion src/Formats/EbookModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ abstract class EbookModule
{
protected function __construct(
protected Ebook $ebook,
) {}
) {
}

abstract public static function make(Ebook $ebook): self;

Expand Down
3 changes: 2 additions & 1 deletion src/Formats/EbookParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ protected function __construct(
protected ?Fb2Module $fb2 = null,
protected ?PdfModule $pdf = null,
protected ?string $type = null,
) {}
) {
}

public static function make(EbookModule $module): self
{
Expand Down
3 changes: 2 additions & 1 deletion src/Formats/Epub/Parser/EpubChapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ protected function __construct(
protected ?string $label = null,
protected ?string $source = null,
protected ?string $content = null,
) {}
) {
}

/**
* @param EpubHtml[] $html
Expand Down
3 changes: 2 additions & 1 deletion src/Formats/Epub/Parser/EpubContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class EpubContainer

protected function __construct(
protected XmlReader $xml,
) {}
) {
}

public static function make(string $content): self
{
Expand Down
9 changes: 6 additions & 3 deletions src/Formats/Epub/Parser/NcxItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class NcxItem

protected function __construct(
protected XmlReader $xml,
) {}
) {
}

public static function make(string $content): self
{
Expand Down Expand Up @@ -161,7 +162,8 @@ class NcxItemHead
protected function __construct(
protected ?string $name = null,
protected ?string $content = null,
) {}
) {
}

public static function make(array $xml): self
{
Expand Down Expand Up @@ -199,7 +201,8 @@ protected function __construct(
protected ?string $label = null,
protected ?string $src = null,
protected ?string $class = null,
) {}
) {
}

public static function make(array $xml): self
{
Expand Down
3 changes: 2 additions & 1 deletion src/Formats/Epub/Parser/OpfItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ class OpfItem

protected function __construct(
protected XmlReader $xml,
) {}
) {
}

public static function make(string $content, ?string $filename = null): self
{
Expand Down
27 changes: 18 additions & 9 deletions src/Formats/Fb2/Parser/Fb2Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ protected function __construct(
protected ?array $body = null,
protected ?array $binary = null,
protected ?string $cover = null,
) {}
) {
}

public static function make(string $path): self
{
Expand Down Expand Up @@ -278,7 +279,8 @@ public function __construct(
public ?Fb2MetaDescriptionTitle $title = null,
public ?Fb2MetaDescriptionDocument $document = null,
public ?Fb2MetaDescriptionPublish $publish = null,
) {}
) {
}
}

class Fb2MetaDescriptionTitle
Expand All @@ -295,7 +297,8 @@ public function __construct(
public ?string $keywords = null,
public ?Fb2MetaSequence $sequence = null,
public ?array $annotation = null,
) {}
) {
}
}

class Fb2MetaDescriptionDocument
Expand All @@ -309,7 +312,8 @@ public function __construct(
public ?string $date = null,
public ?string $id = null,
public ?string $version = null,
) {}
) {
}
}

class Fb2MetaDescriptionPublish
Expand All @@ -318,36 +322,41 @@ public function __construct(
public ?string $publisher = null,
public ?string $year = null,
public ?string $isbn = null,
) {}
) {
}
}

class Fb2MetaBinaryItem
{
public function __construct(
public ?array $attributes = null,
public ?string $content = null,
) {}
) {
}
}

class Fb2MetaAuthor
{
public function __construct(
public ?string $firstName = null,
public ?string $lastName = null,
) {}
) {
}
}

class Fb2MetaSequence
{
public function __construct(
public ?string $name = null,
public ?string $number = null,
) {}
) {
}
}

class Fb2MetaCoverpage
{
public function __construct(
public ?string $href = null,
) {}
) {
}
}
3 changes: 2 additions & 1 deletion src/Formats/Mobi/Parser/MobiImages.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ class MobiImages
protected function __construct(
protected Stream $stream,
protected array $items = [],
) {}
) {
}

public static function make(string $path): ?self
{
Expand Down
18 changes: 12 additions & 6 deletions src/Formats/Mobi/Parser/MobiParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ protected function __construct(
protected ?ExthHeader $exthHeader = null,
protected ?MobiImages $images = null,
protected bool $isValid = false,
) {}
) {
}

public static function make(string $path): ?self
{
Expand Down Expand Up @@ -239,7 +240,8 @@ public function __construct(
public int $textLength = 0,
public int $records = 0,
public int $recordSize = 0,
) {}
) {
}
}

class PalmRecord
Expand All @@ -248,7 +250,8 @@ public function __construct(
public int $offset = 0,
public int $attributes = 0,
public int $id = 0
) {}
) {
}
}

class MobiHeader
Expand All @@ -259,7 +262,8 @@ public function __construct(
public int $encoding = 0,
public int $id = 0,
public int $fileVersion = 0,
) {}
) {
}
}

class ExthHeader
Expand All @@ -270,7 +274,8 @@ class ExthHeader
public function __construct(
public int $length = 0,
public array $records = [],
) {}
) {
}
}

class ExthRecord
Expand All @@ -279,5 +284,6 @@ public function __construct(
public int $type = 0,
public int $length = 0,
public ?string $data = null,
) {}
) {
}
}
3 changes: 2 additions & 1 deletion src/Models/BookAuthor.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class BookAuthor
public function __construct(
protected ?string $name = null,
protected ?string $role = null,
) {}
) {
}

public function getName(): ?string
{
Expand Down
3 changes: 2 additions & 1 deletion src/Models/BookDescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class BookDescription
{
protected function __construct(
protected ?string $rawDescription = null,
) {}
) {
}

public static function make(?string $description): self
{
Expand Down
3 changes: 2 additions & 1 deletion src/Models/BookMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class BookMeta
public function __construct(
protected ?string $name = null,
protected ?string $contents = null,
) {}
) {
}

/**
* Get the meta name.
Expand Down
3 changes: 2 additions & 1 deletion src/Models/ComicMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public function __construct(
protected ?MangaEnum $manga = null,
protected ?string $mainCharacterOrTeam = null,
protected ?string $format = null,
) {}
) {
}

/**
* @return string[]
Expand Down
3 changes: 2 additions & 1 deletion src/Models/MetaTitle.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ protected function __construct(
protected ?string $seriesDeterminer = null,

protected bool $useIntl = true,
) {}
) {
}

/**
* Create a new MetaTitle instance from an Ebook.
Expand Down
3 changes: 2 additions & 1 deletion src/Utils/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class Stream
protected function __construct(
protected $path,
protected $resource,
) {}
) {
}

/**
* Creates a new instance of Stream.
Expand Down

0 comments on commit 4aa41e9

Please sign in to comment.