Skip to content

Deprecated methods #39

Answered by clemlatz
S1SYPHOS asked this question in Q&A
Mar 4, 2021 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Hey @S1SYPHOS ,

Thanks for the love 🙏🏻

You’re right that, unlike with the legacy public API, using the new one, you don’t need to validate a string before you try to convert it. So instead of:

$isbn = new Isbn("9781234567890");
if ($isbn->isValid) {
  $isbn13 = $isbn->format("ISBN-13");
}

Now you can just do:

$isbn13 = Isbn::convertToIsbn13("9781234567890");

and catch exceptions.

But if you don’t need to convert a string and you only need to validate it, you can call:

$isbn13 = Isbn::validateAsIsbn13("9781234567890 ");

and catch exceptions.

(I trust that you already understood all this, but I thought this might help other users that may be confused about the new API).

The difference betwe…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@S1SYPHOS
Comment options

Answer selected by clemlatz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #38 on March 04, 2021 20:22.