/** * @test * @dataProvider \Rebuy\EanIsbn\Tests\Helper\IdentifierProvider::provideValidIsbn10 * @param $value */ public function convert_converts_isbn10_to_ean13($value) { $isbn10 = new Isbn10(str_replace('-', '', $value)); $valueWithoutChecksum = substr($isbn10->getValue(), 0, -1); $ean13 = $this->converter->convert($isbn10); $ean13WithoutChecksum = substr($ean13->getValue(), 0, -1); $this->assertInstanceOf(Ean13::class, $ean13); $this->assertEquals('978' . $valueWithoutChecksum, $ean13WithoutChecksum); }
/** * @param Isbn10 $isbn10 * * @return Ean13 */ private function convertIsbn10ToEan13(Isbn10 $isbn10) { $ean13WithoutChecksum = self::$isbn10ToEan13Prefix . substr($isbn10->getValue(), 0, -1); $ean13Checksum = $this->checksumCalculator->calculate($ean13WithoutChecksum); return new Ean13($ean13WithoutChecksum . $ean13Checksum); }