forked from picqer/php-barcode-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate-examples.php
26 lines (20 loc) · 883 Bytes
/
generate-examples.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
function getSaveFilename($value) {
return preg_replace('/[^a-zA-Z0-9_ \-+]/s', '-', $value);
}
require('vendor/autoload.php');
require(__DIR__ . '/tests/VerifiedBarcodeTest.php');
$verifiedFiles = VerifiedBarcodeTest::$supportedBarcodes;
$result = [];
$result[] = '# Examples of supported barcodes';
$result[] = 'These are examples of supported barcodes with this library.';
$result[] = '';
foreach ($verifiedFiles as $verifiedFile) {
$result[] = '### ' . $verifiedFile['type'];
foreach ($verifiedFile['barcodes'] as $barcode) {
$result[] = sprintf('![Barcode %s as %s](tests/verified-files/%s.svg)', $barcode, $verifiedFile['type'], getSaveFilename($verifiedFile['type'] . '-' . $barcode));
}
}
$result[] = '';
$result[] = '*This file is generated by generate-examples.php*';
file_put_contents('examples.md', implode(PHP_EOL . PHP_EOL, $result));