*/ class PageMetaCollection extends LookupCollection { /** @inheritdoc */ public function __construct(string $subject, ?AbstractIndex $pageIndex = null) { $clean = self::cleanName($subject); parent::__construct( $pageIndex ?? 'page', $clean . '_w', $clean . '_i', $clean . '_p' ); } /** * Clean a name for use as a file name * * Romanizes non-latin characters, then strips away anything that's * not a letter, number, or underscore. * * @param string $name * @return string */ public static function cleanName(string $name): string { $name = Clean::romanize(trim($name)); $name = preg_replace('#[ \./\\:-]+#', '_', $name); $name = preg_replace('/[^A-Za-z0-9_]/', '', $name); return strtolower($name); } }