You are here

class IsbnToolsService in ISBN Field 8

Hierarchy

Expanded class hierarchy of IsbnToolsService

1 string reference to 'IsbnToolsService'
isbn.services.yml in ./isbn.services.yml
isbn.services.yml
1 service uses IsbnToolsService
isbn.isbn_service in ./isbn.services.yml
Drupal\isbn\IsbnToolsService

File

src/IsbnToolsService.php, line 9

Namespace

Drupal\isbn
View source
class IsbnToolsService {
  protected $isbn_tools;

  /**
   * ISBNService constructor.
   */
  public function __construct() {
    $this->isbn_tools = new IsbnTools();
  }
  public function format($number) {
    try {
      return $this->isbn_tools
        ->format($number);
    } catch (InvalidIsbnException $e) {
    }
  }
  public function isValidIsbn($number) {
    return $this->isbn_tools
      ->isValidIsbn($number);
  }
  public function convertIsbn10to13($number) {
    try {
      return $this->isbn_tools
        ->convertIsbn10to13($number);
    } catch (InvalidIsbnException $e) {
    }
  }
  public function convertIsbn13to10($number) {
    try {
      return $this->isbn_tools
        ->convertIsbn13to10($number);
    } catch (\Exception $e) {
    }
  }
  public function cleanup($number) {
    return preg_replace('/[^0-9a-zA-Z]/', '', $number);
  }

}

Members