ar_EG
2 years ago
ar_JO
2 years ago
ar_SA
2 years ago
at_AT
2 years ago
bg_BG
2 years ago
bn_BD
2 years ago
cs_CZ
2 years ago
da_DK
2 years ago
de_AT
2 years ago
de_CH
2 years ago
de_DE
2 years ago
el_CY
2 years ago
el_GR
2 years ago
en_AU
2 years ago
en_CA
2 years ago
en_GB
2 years ago
en_HK
2 years ago
en_IN
2 years ago
en_NG
2 years ago
en_NZ
2 years ago
en_PH
2 years ago
en_SG
2 years ago
en_UG
2 years ago
en_US
2 years ago
en_ZA
2 years ago
es_AR
2 years ago
es_ES
2 years ago
es_PE
2 years ago
es_VE
2 years ago
et_EE
2 years ago
fa_IR
2 years ago
fi_FI
2 years ago
fr_BE
2 years ago
fr_CA
2 years ago
fr_CH
2 years ago
fr_FR
2 years ago
he_IL
2 years ago
hr_HR
2 years ago
hu_HU
2 years ago
hy_AM
2 years ago
id_ID
2 years ago
is_IS
2 years ago
it_CH
2 years ago
it_IT
2 years ago
ja_JP
2 years ago
ka_GE
2 years ago
kk_KZ
2 years ago
ko_KR
2 years ago
lt_LT
2 years ago
lv_LV
2 years ago
me_ME
2 years ago
mn_MN
2 years ago
ms_MY
2 years ago
nb_NO
2 years ago
ne_NP
2 years ago
nl_BE
2 years ago
nl_NL
2 years ago
pl_PL
2 years ago
pt_BR
2 years ago
pt_PT
2 years ago
ro_MD
2 years ago
ro_RO
2 years ago
ru_RU
2 years ago
sk_SK
2 years ago
sl_SI
2 years ago
sr_Cyrl_RS
2 years ago
sr_Latn_RS
2 years ago
sr_RS
2 years ago
sv_SE
2 years ago
th_TH
2 years ago
tr_TR
2 years ago
uk_UA
2 years ago
vi_VN
2 years ago
zh_CN
2 years ago
zh_TW
2 years ago
Address.php
2 years ago
Barcode.php
2 years ago
Base.php
2 years ago
Biased.php
2 years ago
Color.php
2 years ago
Company.php
2 years ago
DateTime.php
2 years ago
File.php
2 years ago
HtmlLorem.php
2 years ago
Image.php
2 years ago
Internet.php
2 years ago
Lorem.php
2 years ago
Medical.php
2 years ago
Miscellaneous.php
2 years ago
Payment.php
2 years ago
Person.php
2 years ago
PhoneNumber.php
2 years ago
Text.php
2 years ago
UserAgent.php
2 years ago
Uuid.php
2 years ago
Barcode.php
114 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @license MIT |
| 4 | * |
| 5 | * Modified by impress-org on 23-January-2024 using Strauss. |
| 6 | * @see https://github.com/BrianHenryIE/strauss |
| 7 | */ |
| 8 | |
| 9 | namespace Give\Vendors\Faker\Provider; |
| 10 | |
| 11 | use Give\Vendors\Faker\Calculator\Ean; |
| 12 | use Give\Vendors\Faker\Calculator\Isbn; |
| 13 | |
| 14 | /** |
| 15 | * @see http://en.wikipedia.org/wiki/EAN-13 |
| 16 | * @see http://en.wikipedia.org/wiki/ISBN |
| 17 | */ |
| 18 | class Barcode extends Base |
| 19 | { |
| 20 | private function ean($length = 13) |
| 21 | { |
| 22 | $code = static::numerify(str_repeat('#', $length - 1)); |
| 23 | |
| 24 | return $code . Ean::checksum($code); |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Utility function for computing EAN checksums |
| 29 | * |
| 30 | * @deprecated Use \Faker\Calculator\Ean::checksum() instead |
| 31 | * |
| 32 | * @param string $input |
| 33 | * |
| 34 | * @return int |
| 35 | */ |
| 36 | protected static function eanChecksum($input) |
| 37 | { |
| 38 | return Ean::checksum($input); |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * ISBN-10 check digit |
| 43 | * |
| 44 | * @see http://en.wikipedia.org/wiki/International_Standard_Book_Number#ISBN-10_check_digits |
| 45 | * @deprecated Use \Faker\Calculator\Isbn::checksum() instead |
| 46 | * |
| 47 | * @param string $input ISBN without check-digit |
| 48 | * |
| 49 | * @throws \LengthException When wrong input length passed |
| 50 | * |
| 51 | * @return string |
| 52 | */ |
| 53 | protected static function isbnChecksum($input) |
| 54 | { |
| 55 | return Isbn::checksum($input); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Get a random EAN13 barcode. |
| 60 | * |
| 61 | * @return string |
| 62 | * |
| 63 | * @example '4006381333931' |
| 64 | */ |
| 65 | public function ean13() |
| 66 | { |
| 67 | return $this->ean(13); |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Get a random EAN8 barcode. |
| 72 | * |
| 73 | * @return string |
| 74 | * |
| 75 | * @example '73513537' |
| 76 | */ |
| 77 | public function ean8() |
| 78 | { |
| 79 | return $this->ean(8); |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Get a random ISBN-10 code |
| 84 | * |
| 85 | * @see http://en.wikipedia.org/wiki/International_Standard_Book_Number |
| 86 | * |
| 87 | * @return string |
| 88 | * |
| 89 | * @example '4881416324' |
| 90 | */ |
| 91 | public function isbn10() |
| 92 | { |
| 93 | $code = static::numerify(str_repeat('#', 9)); |
| 94 | |
| 95 | return $code . Isbn::checksum($code); |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Get a random ISBN-13 code |
| 100 | * |
| 101 | * @see http://en.wikipedia.org/wiki/International_Standard_Book_Number |
| 102 | * |
| 103 | * @return string |
| 104 | * |
| 105 | * @example '9790404436093' |
| 106 | */ |
| 107 | public function isbn13() |
| 108 | { |
| 109 | $code = '97' . self::numberBetween(8, 9) . static::numerify(str_repeat('#', 9)); |
| 110 | |
| 111 | return $code . Ean::checksum($code); |
| 112 | } |
| 113 | } |
| 114 |