christianberkman / sortable-book
Make the title and author sortable for use in a library inventory by moving the article and initials to the end of the string
Installs: 8
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/christianberkman/sortable-book
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.65
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^11.5
README
Make the title and author sortable for use in a library inventory by moving the article and initials to the end of the string.
This package contains does not contain a class but two helper functions sortableAuthor() and sortableTitle().sw
Installation
Via Composer
composer require chhristianberkman/sortable-book
The file sortable-book.php will be autoloaded.
Manually
require('src/sortable-book.php');
Usage
$author = sortableAuthor('C.S. Lewis'); // Lewis, C.S. $title = sortableTitle('The Last Battle'); // Last Battle, The
Function reference
sortableAuthor(?string $value): ?string
Make a book author sortable by moving initials to the end of the string, preceded by a comma and a space
string $valuestring to format
sortableTitle(?string $value, bool $makeSingleSpaces = true, ?string $articles = 'a|an|the' ): ?string
Make a book title sortable by moving tha article to the end of the string, preceded by a comma and a space.
string $valuestring to formatbool $makeSingleSpacesconvert all whitepaces to a single whitespacestring $articleslist of articles seperated by|, defaults to 'a|an|the'
Returns string or null