wiki.techinc.nl/tests/phpunit/includes/api/generateRandomImages.php
Thiemo Kreuz 62d45967c0 Replace some more isset() with shorter ?? syntax
Change-Id: Ie119167bc2584f047e29174f95c39b65f99a64a6
2021-11-02 10:39:38 +01:00

44 lines
945 B
PHP

<?php
/**
* Bootstrapping for test image file generation
*
* @file
*/
// Start up MediaWiki in command-line mode
require_once __DIR__ . "/../../../../maintenance/Maintenance.php";
require_once __DIR__ . "/RandomImageGenerator.php";
class GenerateRandomImages extends Maintenance {
public function getDbType() {
return Maintenance::DB_NONE;
}
public function execute() {
$getOptSpec = [
'minWidth::',
'maxWidth::',
'minHeight::',
'maxHeight::',
'shapesToDraw::',
'shape::',
'number::',
'format::'
];
$options = getopt( null, $getOptSpec );
$format = $options['format'] ?? 'jpg';
unset( $options['format'] );
$number = (int)( $options['number'] ?? 10 );
unset( $options['number'] );
$randomImageGenerator = new RandomImageGenerator( $options );
$randomImageGenerator->writeImages( $number, $format );
}
}
$maintClass = GenerateRandomImages::class;
require_once RUN_MAINTENANCE_IF_MAIN;