summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generate-sample-gig-data.php38
1 files changed, 26 insertions, 12 deletions
diff --git a/generate-sample-gig-data.php b/generate-sample-gig-data.php
index 4ed9ac8..ecbf67a 100644
--- a/generate-sample-gig-data.php
+++ b/generate-sample-gig-data.php
@@ -1,9 +1,14 @@
<?php
-
-// SPDX-FileCopyrightText: 2021 Andrea Chirulescu <andrea.chirulescu@gmail.com>
-// SPDX-FileCopyrightText: 2021 Harald Eilertsen <haraldei@anduin.net>
-//
-// SPDX-License-Identifier: AGPL-3.0-or-later
+/**
+ * Tool to generate random concert entries for importing into giglogadmin.
+ *
+ * @package giglogadmin
+ *
+ * SPDX-FileCopyrightText: 2021 Andrea Chirulescu <andrea.chirulescu@gmail.com>
+ * SPDX-FileCopyrightText: 2021 Harald Eilertsen <haraldei@anduin.net>
+ *
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
/**
* Abstract base class for a generator.
@@ -195,16 +200,24 @@ class LinkGenerator extends GeneratorBase {
*/
class CityGenerator extends GeneratorBase {
+ /**
+ * A few cities, so we can test filtering for cities.
+ *
+ * @var array $cities The cities.
+ */
private array $cities = array(
- "Oslo",
- "Trondheim",
- "Støren",
- "Velstandsbygd",
- "Sommerhytta"
+ 'Oslo',
+ 'Trondheim',
+ 'Støren',
+ 'Velstandsbygd',
+ 'Sommerhytta',
);
- function get() : string {
- return $this-pick( $cities );
+ /**
+ * Return a random city.
+ */
+ public function get() : string {
+ return $this->pick( $this->cities );
}
}
@@ -220,5 +233,6 @@ $num = intval( array_shift( $argv ) ) ?? 10;
for ( $i = 0; $i < $num; $i++ ) {
$date->add( new DateInterval( 'P' . random_int( 0, 60 ) . 'D' ) );
+ // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
echo implode( "\t", array( $band->get(), $venue->get(), $city->get(), $date->format( 'Y-m-d' ), $links->get(), $links->get() ) ) . "\n";
}