1. Go to this page and download the library: Download nedwors/pluralize 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/ */
pluralize('Dog', $dogs)() // Invoke
pluralize('Dog', $dogs)->go() // Call the go() method
(string) pluralize('Dog', $dogs) // Cast the type
Pluralize::this(...)->from(...)->as(...)->or(...)
pluralize('this', 'from', 'or', 'as')
pluralize(...)->from(...)->as(...)->or(...)
// The first argument to the helper function
pluralize('Rocket')
// The second argument to the helper function
pluralize('Rocket', $rockets)
// Or, as a method
pluralize('Rocket')->from($rockets)
// The third argument to the helper function
pluralize('Rocket', $rockets, '...')
// Or, as a method
pluralize('Rocket', $rockets)->or('...')
pluralize('Rocket', $rockets)
->or(fn($plural) => "Oops, $plural is not defined")
// Oops, Rockets is not defined
// The fourth argument to the helper function
pluralize('Rocket', $rockets, '...', fn($plural, $count) => "$plural: $count")
// Or, probably more usefully, as a method
pluralize('Rocket', $rockets)->as(fn($plural, $count) => "$plural: $count")
// Rockets: 10
pluralize('Rocket', $rockets)
->as(fn($plural, $count) => "There is|are $count $plural")
// There is 1 Rocket
// There are 2 Rockets
pluralize('Rocket', $rockets)
->as('Not sure how many, but you have some Rockets')
// Now sure how many, but you have some Rockets
// In your service provider's boot() method
Pluralize::bind()
->output(fn($plural, $count) => "$plural: $count")
->fallback('...')
// In your view
pluralize('Car', $cars)
// When $cars = null, ...
// When $cars = 10, Cars: 10
// In your service provider's boot() method
Pluralize::bind('Hotdog')
->output(fn($plural, $count) => "Yum, $count hotdogs!")
// In your view
pluralize('Car', $cars) // 10 Cars
pluralize('Hotdog', $hotdogs) // Yum, 10 hotdogs!
// In your service provider's boot() method
Pluralize::bind('ye-olde')
->fallback(fn($plural) => "Thou hath not declared $plural")
// In your view
pluralize('Robot', null) // -
pluralize('DeLorean', null)->or('ye-olde') // Thou hath not declared DeLoreans
public function run(string $string, $count): string
{
return Str::plural($string, $count);
}
Pluralize::driver(NewDriver::class)
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.