Skip to content

Commit

Permalink
add autodetect
Browse files Browse the repository at this point in the history
  • Loading branch information
ewilan-riviere committed Sep 24, 2023
1 parent 771d686 commit 2c15041
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Tools/BookIdentifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@

class BookIdentifier
{
/**
* @param bool $autoDetect Try to auto detect scheme, even if provided (default: `true`)
*/
public function __construct(
protected mixed $value = null,
protected ?string $scheme = null, // isbn10, isbn13, asin, etc.
protected bool $autoDetect = true,
) {
$this->value = BookMeta::parse($this->value);
$this->scheme = $this->parseScheme($this->scheme);
if ($this->autoDetect) {
$this->scheme = $this->parseScheme($this->scheme);
}
}

private function parseScheme(string $scheme = null): string
Expand Down

0 comments on commit 2c15041

Please sign in to comment.