Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace Faker\Core;
6
 
7
use Faker\Calculator;
8
use Faker\Extension;
9
 
10
/**
11
 * @experimental This class is experimental and does not fall under our BC promise
12
 */
13
final class Barcode implements Extension\BarcodeExtension
14
{
15
    private function ean(int $length = 13): string
16
    {
17
        $code = Extension\Helper::numerify(str_repeat('#', $length - 1));
18
 
19
        return sprintf('%s%s', $code, Calculator\Ean::checksum($code));
20
    }
21
 
22
    public function ean13(): string
23
    {
24
        return $this->ean();
25
    }
26
 
27
    public function ean8(): string
28
    {
29
        return $this->ean(8);
30
    }
31
 
32
    public function isbn10(): string
33
    {
34
        $code = Extension\Helper::numerify(str_repeat('#', 9));
35
 
36
        return sprintf('%s%s', $code, Calculator\Isbn::checksum($code));
37
    }
38
 
39
    public function isbn13(): string
40
    {
41
        $code = '97' . mt_rand(8, 9) . Extension\Helper::numerify(str_repeat('#', 9));
42
 
43
        return sprintf('%s%s', $code, Calculator\Ean::checksum($code));
44
    }
45
}