PHP code example of maximaster / alterator
1. Go to this page and download the library: Download maximaster/alterator library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
maximaster / alterator example snippets
composer
// create the library classes manually or get them from your DI container.
$unusedSeeker = new AlteratorUnsusedSeeker(new PostfixIndexAlterator());
$copyName = $unusedSeeker->suggest(
// Old name.
'Document (5)',
// Your strategy to ensure that the suggested name is not already used.
static fn (string $alternativeName): bool => $database->exists('
SELECT 1 FROM documents WHERE NAME = ?
', [$alternativeName])
);
// This would be "Document (6)" unless your strategy found it already used.
return $copyName;