diff --git a/MIGRATION.md b/MIGRATION.md index 2f9d554..cca4bbc 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -24,7 +24,7 @@ None ### Other Changes -None +- Some code is now generated from CLDR data, such as `Units` getters and methods. diff --git a/Makefile b/Makefile index fb0ec81..802bc9d 100644 --- a/Makefile +++ b/Makefile @@ -47,3 +47,24 @@ test-container-82: .PHONY: lint lint: @XDEBUG_MODE=off vendor/bin/phpstan + +# +# Generate +# + +GENERATE=./generator/generate + +.PHONY=generate +generate: \ + lib/LocaleId.php \ + lib/Units/SequenceCompanion.php \ + lib/Units/UnitsCompanion.php + +lib/LocaleId.php: + $(GENERATE) locale-id >$@ + +lib/Units/SequenceCompanion.php: + $(GENERATE) sequence-companion >$@ + +lib/Units/UnitsCompanion.php: + $(GENERATE) units-companion >$@ diff --git a/docs/General.md b/docs/General.md index 5d2f48a..a9999cd 100644 --- a/docs/General.md +++ b/docs/General.md @@ -28,7 +28,7 @@ units. [Many units are available](https://www.unicode.org/reports/tr35/tr35-66/t ```php locales['en']->units; diff --git a/generator/.editorconfig b/generator/.editorconfig new file mode 100644 index 0000000..88e9125 --- /dev/null +++ b/generator/.editorconfig @@ -0,0 +1,5 @@ +[*] +indent_style = space + +[*.json] +indent_size = 2 diff --git a/generator/.gitignore b/generator/.gitignore new file mode 100644 index 0000000..2659611 --- /dev/null +++ b/generator/.gitignore @@ -0,0 +1 @@ +composer.lock diff --git a/generator/Dockerfile b/generator/Dockerfile new file mode 100644 index 0000000..8b85457 --- /dev/null +++ b/generator/Dockerfile @@ -0,0 +1,28 @@ +ARG PHP_VERSION=8.1 +FROM php:${PHP_VERSION}-cli-buster + +RUN apt-get update && \ + apt-get install -y autoconf pkg-config && \ + pecl channel-update pecl.php.net && \ + pecl install xdebug && \ + docker-php-ext-enable opcache xdebug + +RUN echo '\ +xdebug.client_host=host.docker.internal\n\ +xdebug.mode=develop\n\ +xdebug.start_with_request=yes\n\ +' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini + +RUN echo '\ +display_errors=On\n\ +error_reporting=E_ALL\n\ +date.timezone=UTC\n\ +' >> /usr/local/etc/php/conf.d/php.ini + +ENV COMPOSER_ALLOW_SUPERUSER 1 + +RUN apt-get update && \ + apt-get install unzip && \ + curl -s https://raw.githubusercontent.com/composer/getcomposer.org/76a7060ccb93902cd7576b67264ad91c8a2700e2/web/installer | php -- --quiet && \ + mv composer.phar /usr/local/bin/composer && \ + echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"\n' >> /root/.bashrc diff --git a/generator/composer.json b/generator/composer.json new file mode 100644 index 0000000..be3c64a --- /dev/null +++ b/generator/composer.json @@ -0,0 +1,31 @@ +{ + "name": "icanboogie/cldr-generator", + "description": "Generates CLDR classes", + "type": "project", + "license": "BSD-3-Clause", + "authors": [ + { + "name": "Olivier Laviale", + "email": "olivier.laviale@gmail.com", + "homepage": "https://olvlvl.com/", + "role": "Developer" + } + ], + "config": { + "sort-packages": true + }, + "minimum-stability": "dev", + "prefer-stable": true, + "require": { + "php": ">=8.1", + "icanboogie/accessor": "^6.0", + "symfony/console": "^6.3", + "symfony/dependency-injection": "^6.3" + }, + "autoload": { + "psr-4": { + "ICanBoogie\\CLDR\\": "../lib", + "ICanBoogie\\CLDR\\Generator\\": "src" + } + } +} diff --git a/generator/docker-compose.yaml b/generator/docker-compose.yaml new file mode 100644 index 0000000..058edcc --- /dev/null +++ b/generator/docker-compose.yaml @@ -0,0 +1,15 @@ +--- +version: "3.2" +services: + app81: + build: + context: . + dockerfile: Dockerfile + args: + PHP_VERSION: '8.1' + environment: + PHP_IDE_CONFIG: 'serverName=icanboogie-cldr-generator' + volumes: + - .:/app:delegated + - ~/.composer:/root/.composer:delegated + working_dir: /app diff --git a/generator/generate b/generator/generate new file mode 100755 index 0000000..5a776f4 --- /dev/null +++ b/generator/generate @@ -0,0 +1,23 @@ +#!/usr/bin/env php +get('console.command_loader'); + +$console = new Application(); +$console->setCommandLoader($command_loader); +$console->run(); diff --git a/generator/src/Command/LocaleIdCommand.php b/generator/src/Command/LocaleIdCommand.php new file mode 100644 index 0000000..7a5e1ca --- /dev/null +++ b/generator/src/Command/LocaleIdCommand.php @@ -0,0 +1,53 @@ +repository->available_locales; + $cases = []; + + foreach ($available_locales as $locale) { + $case = strtr($locale, [ '-' => '_' ]); + + $cases[] = << $cases ]); + + return self::SUCCESS; + } +} diff --git a/generator/src/Command/SequenceCompanionCommand.php b/generator/src/Command/SequenceCompanionCommand.php new file mode 100644 index 0000000..ccf48ff --- /dev/null +++ b/generator/src/Command/SequenceCompanionCommand.php @@ -0,0 +1,73 @@ +repository->locales['en-001']['units']['long']; + $methods = []; + + foreach ($units as $name => $unit) { + if (empty($unit['unitPattern-count-one'])) { + continue; + } + + $normalized = strtr($name, [ '-' => '_' ]); + + $methods[] = <<sequence["$name"] = \$number; + + return \$this; + } + + PHP; + } + + echo strtr(self::TEMPLATE, [ + '#METHODS#' => implode("\n", $methods), + ]); + + return self::SUCCESS; + } +} diff --git a/generator/src/Command/UnitsCompanionCommand.php b/generator/src/Command/UnitsCompanionCommand.php new file mode 100644 index 0000000..99d001a --- /dev/null +++ b/generator/src/Command/UnitsCompanionCommand.php @@ -0,0 +1,78 @@ +repository->locales['en-001']['units']['long']; + $properties = []; + $methods = []; + + foreach ($units as $name => $unit) { + if (empty($unit['unitPattern-count-one'])) { + continue; + } + + $normalized = strtr($name, [ '-' => '_' ]); + + $properties[] = << implode("\n", $properties), + '#METHODS#' => implode("\n", $methods), + ]); + + return self::SUCCESS; + } +} diff --git a/generator/src/ContainerProvider.php b/generator/src/ContainerProvider.php new file mode 100644 index 0000000..92ce57d --- /dev/null +++ b/generator/src/ContainerProvider.php @@ -0,0 +1,57 @@ +addCompilerPass(new AddConsoleCommandPass()); + + $container->register(Repository::class) + ->setFactory([ self::class, 'repository_factory' ]); + + foreach (self::COMMANDS as $command) { + $container + ->register( $command) + ->addTag('console.command') + ->setAutowired(true); + } + + $container->compile(); + + return $container; + } + + public static function repository_factory(): Repository + { + $provider = new Provider\CachedProvider( + new Provider\WebProvider(), + new CacheCollection([ + new RuntimeCache(), + new FileCache(CACHE) + ]) + ); + + return new Repository($provider); + } +} diff --git a/lib/LocaleId.php b/lib/LocaleId.php new file mode 100644 index 0000000..1eb68a5 --- /dev/null +++ b/lib/LocaleId.php @@ -0,0 +1,386 @@ +sequence = new Sequence($this); } - public function __call(string $name, array $arguments): NumberWithUnit - { - $unit = strtr($name, '_', '-'); - - if (empty($this->data[self::DEFAULT_LENGTH->value][$unit])) { - throw new BadMethodCallException("No such unit: $unit"); - } - - $n = count($arguments); - - if ($n !== 1) { - throw new BadMethodCallException("$name() expects one argument, got $n"); - } - - $number = $arguments[0]; - - return new NumberWithUnit($number + 0, $unit, $this); - } - /** * @var array * Where _key_ is a unit name. diff --git a/lib/Units/Sequence.php b/lib/Units/Sequence.php index 619ea81..c41450c 100644 --- a/lib/Units/Sequence.php +++ b/lib/Units/Sequence.php @@ -24,132 +24,12 @@ * @property-read string $as_short Short string representation. * @property-read string $as_narrow Narrow string representation. * - * @method $this acceleration_g_force(mixed $number) - * @method $this acceleration_meter_per_second_squared(mixed $number) - * @method $this angle_arc_minute(mixed $number) - * @method $this angle_arc_second(mixed $number) - * @method $this angle_degree(mixed $number) - * @method $this angle_radian(mixed $number) - * @method $this area_acre(mixed $number) - * @method $this area_hectare(mixed $number) - * @method $this area_square_centimeter(mixed $number) - * @method $this area_square_foot(mixed $number) - * @method $this area_square_inch(mixed $number) - * @method $this area_square_kilometer(mixed $number) - * @method $this area_square_meter(mixed $number) - * @method $this area_square_mile(mixed $number) - * @method $this area_square_yard(mixed $number) - * @method $this consumption_liter_per_kilometer(mixed $number) - * @method $this consumption_mile_per_gallon(mixed $number) - * @method $this digital_bit(mixed $number) - * @method $this digital_byte(mixed $number) - * @method $this digital_gigabit(mixed $number) - * @method $this digital_gigabyte(mixed $number) - * @method $this digital_kilobit(mixed $number) - * @method $this digital_kilobyte(mixed $number) - * @method $this digital_megabit(mixed $number) - * @method $this digital_megabyte(mixed $number) - * @method $this digital_terabit(mixed $number) - * @method $this digital_terabyte(mixed $number) - * @method $this duration_day(mixed $number) - * @method $this duration_hour(mixed $number) - * @method $this duration_microsecond(mixed $number) - * @method $this duration_millisecond(mixed $number) - * @method $this duration_minute(mixed $number) - * @method $this duration_month(mixed $number) - * @method $this duration_nanosecond(mixed $number) - * @method $this duration_second(mixed $number) - * @method $this duration_week(mixed $number) - * @method $this duration_year(mixed $number) - * @method $this electric_ampere(mixed $number) - * @method $this electric_milliampere(mixed $number) - * @method $this electric_ohm(mixed $number) - * @method $this electric_volt(mixed $number) - * @method $this energy_calorie(mixed $number) - * @method $this energy_foodcalorie(mixed $number) - * @method $this energy_joule(mixed $number) - * @method $this energy_kilocalorie(mixed $number) - * @method $this energy_kilojoule(mixed $number) - * @method $this energy_kilowatt_hour(mixed $number) - * @method $this frequency_gigahertz(mixed $number) - * @method $this frequency_hertz(mixed $number) - * @method $this frequency_kilohertz(mixed $number) - * @method $this frequency_megahertz(mixed $number) - * @method $this length_astronomical_unit(mixed $number) - * @method $this length_centimeter(mixed $number) - * @method $this length_decimeter(mixed $number) - * @method $this length_fathom(mixed $number) - * @method $this length_foot(mixed $number) - * @method $this length_furlong(mixed $number) - * @method $this length_inch(mixed $number) - * @method $this length_kilometer(mixed $number) - * @method $this length_light_year(mixed $number) - * @method $this length_meter(mixed $number) - * @method $this length_micrometer(mixed $number) - * @method $this length_mile(mixed $number) - * @method $this length_millimeter(mixed $number) - * @method $this length_nanometer(mixed $number) - * @method $this length_nautical_mile(mixed $number) - * @method $this length_parsec(mixed $number) - * @method $this length_picometer(mixed $number) - * @method $this length_yard(mixed $number) - * @method $this light_lux(mixed $number) - * @method $this mass_carat(mixed $number) - * @method $this mass_gram(mixed $number) - * @method $this mass_kilogram(mixed $number) - * @method $this mass_metric_ton(mixed $number) - * @method $this mass_microgram(mixed $number) - * @method $this mass_milligram(mixed $number) - * @method $this mass_ounce(mixed $number) - * @method $this mass_ounce_troy(mixed $number) - * @method $this mass_pound(mixed $number) - * @method $this mass_stone(mixed $number) - * @method $this mass_ton(mixed $number) - * @method $this power_gigawatt(mixed $number) - * @method $this power_horsepower(mixed $number) - * @method $this power_kilowatt(mixed $number) - * @method $this power_megawatt(mixed $number) - * @method $this power_milliwatt(mixed $number) - * @method $this power_watt(mixed $number) - * @method $this pressure_hectopascal(mixed $number) - * @method $this pressure_inch_hg(mixed $number) - * @method $this pressure_millibar(mixed $number) - * @method $this pressure_millimeter_of_mercury(mixed $number) - * @method $this pressure_pound_per_square_inch(mixed $number) - * @method $this proportion_karat(mixed $number) - * @method $this speed_kilometer_per_hour(mixed $number) - * @method $this speed_meter_per_second(mixed $number) - * @method $this speed_mile_per_hour(mixed $number) - * @method $this temperature_celsius(mixed $number) - * @method $this temperature_fahrenheit(mixed $number) - * @method $this temperature_kelvin(mixed $number) - * @method $this volume_acre_foot(mixed $number) - * @method $this volume_bushel(mixed $number) - * @method $this volume_centiliter(mixed $number) - * @method $this volume_cubic_centimeter(mixed $number) - * @method $this volume_cubic_foot(mixed $number) - * @method $this volume_cubic_inch(mixed $number) - * @method $this volume_cubic_kilometer(mixed $number) - * @method $this volume_cubic_meter(mixed $number) - * @method $this volume_cubic_mile(mixed $number) - * @method $this volume_cubic_yard(mixed $number) - * @method $this volume_cup(mixed $number) - * @method $this volume_deciliter(mixed $number) - * @method $this volume_fluid_ounce(mixed $number) - * @method $this volume_gallon(mixed $number) - * @method $this volume_hectoliter(mixed $number) - * @method $this volume_liter(mixed $number) - * @method $this volume_megaliter(mixed $number) - * @method $this volume_milliliter(mixed $number) - * @method $this volume_pint(mixed $number) - * @method $this volume_quart(mixed $number) - * @method $this volume_tablespoon(mixed $number) - * @method $this volume_teaspoon(mixed $number) - * * @see http://unicode.org/reports/tr35/tr35-general.html#Unit_Sequences */ final class Sequence { + use SequenceCompanion; + /** * @uses get_as_long * @uses get_as_short @@ -167,15 +47,6 @@ public function __construct( ) { } - public function __call(string $name, array $arguments): self - { - $unit = strtr($name, '_', '-'); - $this->units->assert_is_unit($unit); - $this->sequence[$unit] = $arguments[0]; - - return $this; - } - public function __toString(): string { return $this->format(); diff --git a/lib/Units/SequenceCompanion.php b/lib/Units/SequenceCompanion.php new file mode 100644 index 0000000..ff56368 --- /dev/null +++ b/lib/Units/SequenceCompanion.php @@ -0,0 +1,2184 @@ +sequence["acceleration-g-force"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function acceleration_meter_per_square_second(float|int|string $number): self + { + $this->sequence["acceleration-meter-per-square-second"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function angle_revolution(float|int|string $number): self + { + $this->sequence["angle-revolution"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function angle_radian(float|int|string $number): self + { + $this->sequence["angle-radian"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function angle_degree(float|int|string $number): self + { + $this->sequence["angle-degree"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function angle_arc_minute(float|int|string $number): self + { + $this->sequence["angle-arc-minute"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function angle_arc_second(float|int|string $number): self + { + $this->sequence["angle-arc-second"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function area_square_kilometer(float|int|string $number): self + { + $this->sequence["area-square-kilometer"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function area_hectare(float|int|string $number): self + { + $this->sequence["area-hectare"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function area_square_meter(float|int|string $number): self + { + $this->sequence["area-square-meter"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function area_square_centimeter(float|int|string $number): self + { + $this->sequence["area-square-centimeter"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function area_square_mile(float|int|string $number): self + { + $this->sequence["area-square-mile"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function area_acre(float|int|string $number): self + { + $this->sequence["area-acre"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function area_square_yard(float|int|string $number): self + { + $this->sequence["area-square-yard"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function area_square_foot(float|int|string $number): self + { + $this->sequence["area-square-foot"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function area_square_inch(float|int|string $number): self + { + $this->sequence["area-square-inch"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function area_dunam(float|int|string $number): self + { + $this->sequence["area-dunam"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function concentr_karat(float|int|string $number): self + { + $this->sequence["concentr-karat"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function concentr_milligram_ofglucose_per_deciliter(float|int|string $number): self + { + $this->sequence["concentr-milligram-ofglucose-per-deciliter"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function concentr_millimole_per_liter(float|int|string $number): self + { + $this->sequence["concentr-millimole-per-liter"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function concentr_item(float|int|string $number): self + { + $this->sequence["concentr-item"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function concentr_permillion(float|int|string $number): self + { + $this->sequence["concentr-permillion"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function concentr_percent(float|int|string $number): self + { + $this->sequence["concentr-percent"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function concentr_permille(float|int|string $number): self + { + $this->sequence["concentr-permille"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function concentr_permyriad(float|int|string $number): self + { + $this->sequence["concentr-permyriad"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function concentr_mole(float|int|string $number): self + { + $this->sequence["concentr-mole"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function consumption_liter_per_kilometer(float|int|string $number): self + { + $this->sequence["consumption-liter-per-kilometer"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function consumption_liter_per_100_kilometer(float|int|string $number): self + { + $this->sequence["consumption-liter-per-100-kilometer"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function consumption_mile_per_gallon(float|int|string $number): self + { + $this->sequence["consumption-mile-per-gallon"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function consumption_mile_per_gallon_imperial(float|int|string $number): self + { + $this->sequence["consumption-mile-per-gallon-imperial"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function digital_petabyte(float|int|string $number): self + { + $this->sequence["digital-petabyte"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function digital_terabyte(float|int|string $number): self + { + $this->sequence["digital-terabyte"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function digital_terabit(float|int|string $number): self + { + $this->sequence["digital-terabit"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function digital_gigabyte(float|int|string $number): self + { + $this->sequence["digital-gigabyte"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function digital_gigabit(float|int|string $number): self + { + $this->sequence["digital-gigabit"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function digital_megabyte(float|int|string $number): self + { + $this->sequence["digital-megabyte"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function digital_megabit(float|int|string $number): self + { + $this->sequence["digital-megabit"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function digital_kilobyte(float|int|string $number): self + { + $this->sequence["digital-kilobyte"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function digital_kilobit(float|int|string $number): self + { + $this->sequence["digital-kilobit"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function digital_byte(float|int|string $number): self + { + $this->sequence["digital-byte"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function digital_bit(float|int|string $number): self + { + $this->sequence["digital-bit"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function duration_century(float|int|string $number): self + { + $this->sequence["duration-century"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function duration_decade(float|int|string $number): self + { + $this->sequence["duration-decade"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function duration_year(float|int|string $number): self + { + $this->sequence["duration-year"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function duration_month(float|int|string $number): self + { + $this->sequence["duration-month"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function duration_week(float|int|string $number): self + { + $this->sequence["duration-week"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function duration_day(float|int|string $number): self + { + $this->sequence["duration-day"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function duration_hour(float|int|string $number): self + { + $this->sequence["duration-hour"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function duration_minute(float|int|string $number): self + { + $this->sequence["duration-minute"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function duration_second(float|int|string $number): self + { + $this->sequence["duration-second"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function duration_millisecond(float|int|string $number): self + { + $this->sequence["duration-millisecond"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function duration_microsecond(float|int|string $number): self + { + $this->sequence["duration-microsecond"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function duration_nanosecond(float|int|string $number): self + { + $this->sequence["duration-nanosecond"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function electric_ampere(float|int|string $number): self + { + $this->sequence["electric-ampere"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function electric_milliampere(float|int|string $number): self + { + $this->sequence["electric-milliampere"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function electric_ohm(float|int|string $number): self + { + $this->sequence["electric-ohm"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function electric_volt(float|int|string $number): self + { + $this->sequence["electric-volt"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function energy_kilocalorie(float|int|string $number): self + { + $this->sequence["energy-kilocalorie"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function energy_calorie(float|int|string $number): self + { + $this->sequence["energy-calorie"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function energy_foodcalorie(float|int|string $number): self + { + $this->sequence["energy-foodcalorie"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function energy_kilojoule(float|int|string $number): self + { + $this->sequence["energy-kilojoule"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function energy_joule(float|int|string $number): self + { + $this->sequence["energy-joule"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function energy_kilowatt_hour(float|int|string $number): self + { + $this->sequence["energy-kilowatt-hour"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function energy_electronvolt(float|int|string $number): self + { + $this->sequence["energy-electronvolt"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function energy_british_thermal_unit(float|int|string $number): self + { + $this->sequence["energy-british-thermal-unit"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function energy_therm_us(float|int|string $number): self + { + $this->sequence["energy-therm-us"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function force_pound_force(float|int|string $number): self + { + $this->sequence["force-pound-force"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function force_newton(float|int|string $number): self + { + $this->sequence["force-newton"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function force_kilowatt_hour_per_100_kilometer(float|int|string $number): self + { + $this->sequence["force-kilowatt-hour-per-100-kilometer"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function frequency_gigahertz(float|int|string $number): self + { + $this->sequence["frequency-gigahertz"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function frequency_megahertz(float|int|string $number): self + { + $this->sequence["frequency-megahertz"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function frequency_kilohertz(float|int|string $number): self + { + $this->sequence["frequency-kilohertz"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function frequency_hertz(float|int|string $number): self + { + $this->sequence["frequency-hertz"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function graphics_em(float|int|string $number): self + { + $this->sequence["graphics-em"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function graphics_pixel(float|int|string $number): self + { + $this->sequence["graphics-pixel"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function graphics_megapixel(float|int|string $number): self + { + $this->sequence["graphics-megapixel"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function graphics_pixel_per_centimeter(float|int|string $number): self + { + $this->sequence["graphics-pixel-per-centimeter"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function graphics_pixel_per_inch(float|int|string $number): self + { + $this->sequence["graphics-pixel-per-inch"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function graphics_dot_per_centimeter(float|int|string $number): self + { + $this->sequence["graphics-dot-per-centimeter"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function graphics_dot_per_inch(float|int|string $number): self + { + $this->sequence["graphics-dot-per-inch"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function graphics_dot(float|int|string $number): self + { + $this->sequence["graphics-dot"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function length_earth_radius(float|int|string $number): self + { + $this->sequence["length-earth-radius"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function length_kilometer(float|int|string $number): self + { + $this->sequence["length-kilometer"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function length_meter(float|int|string $number): self + { + $this->sequence["length-meter"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function length_decimeter(float|int|string $number): self + { + $this->sequence["length-decimeter"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function length_centimeter(float|int|string $number): self + { + $this->sequence["length-centimeter"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function length_millimeter(float|int|string $number): self + { + $this->sequence["length-millimeter"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function length_micrometer(float|int|string $number): self + { + $this->sequence["length-micrometer"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function length_nanometer(float|int|string $number): self + { + $this->sequence["length-nanometer"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function length_picometer(float|int|string $number): self + { + $this->sequence["length-picometer"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function length_mile(float|int|string $number): self + { + $this->sequence["length-mile"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function length_yard(float|int|string $number): self + { + $this->sequence["length-yard"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function length_foot(float|int|string $number): self + { + $this->sequence["length-foot"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function length_inch(float|int|string $number): self + { + $this->sequence["length-inch"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function length_parsec(float|int|string $number): self + { + $this->sequence["length-parsec"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function length_light_year(float|int|string $number): self + { + $this->sequence["length-light-year"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function length_astronomical_unit(float|int|string $number): self + { + $this->sequence["length-astronomical-unit"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function length_furlong(float|int|string $number): self + { + $this->sequence["length-furlong"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function length_fathom(float|int|string $number): self + { + $this->sequence["length-fathom"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function length_nautical_mile(float|int|string $number): self + { + $this->sequence["length-nautical-mile"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function length_mile_scandinavian(float|int|string $number): self + { + $this->sequence["length-mile-scandinavian"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function length_point(float|int|string $number): self + { + $this->sequence["length-point"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function length_solar_radius(float|int|string $number): self + { + $this->sequence["length-solar-radius"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function light_lux(float|int|string $number): self + { + $this->sequence["light-lux"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function light_candela(float|int|string $number): self + { + $this->sequence["light-candela"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function light_lumen(float|int|string $number): self + { + $this->sequence["light-lumen"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function light_solar_luminosity(float|int|string $number): self + { + $this->sequence["light-solar-luminosity"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function mass_metric_ton(float|int|string $number): self + { + $this->sequence["mass-metric-ton"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function mass_kilogram(float|int|string $number): self + { + $this->sequence["mass-kilogram"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function mass_gram(float|int|string $number): self + { + $this->sequence["mass-gram"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function mass_milligram(float|int|string $number): self + { + $this->sequence["mass-milligram"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function mass_microgram(float|int|string $number): self + { + $this->sequence["mass-microgram"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function mass_ton(float|int|string $number): self + { + $this->sequence["mass-ton"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function mass_stone(float|int|string $number): self + { + $this->sequence["mass-stone"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function mass_pound(float|int|string $number): self + { + $this->sequence["mass-pound"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function mass_ounce(float|int|string $number): self + { + $this->sequence["mass-ounce"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function mass_ounce_troy(float|int|string $number): self + { + $this->sequence["mass-ounce-troy"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function mass_carat(float|int|string $number): self + { + $this->sequence["mass-carat"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function mass_dalton(float|int|string $number): self + { + $this->sequence["mass-dalton"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function mass_earth_mass(float|int|string $number): self + { + $this->sequence["mass-earth-mass"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function mass_solar_mass(float|int|string $number): self + { + $this->sequence["mass-solar-mass"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function mass_grain(float|int|string $number): self + { + $this->sequence["mass-grain"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function power_gigawatt(float|int|string $number): self + { + $this->sequence["power-gigawatt"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function power_megawatt(float|int|string $number): self + { + $this->sequence["power-megawatt"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function power_kilowatt(float|int|string $number): self + { + $this->sequence["power-kilowatt"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function power_watt(float|int|string $number): self + { + $this->sequence["power-watt"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function power_milliwatt(float|int|string $number): self + { + $this->sequence["power-milliwatt"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function power_horsepower(float|int|string $number): self + { + $this->sequence["power-horsepower"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function pressure_millimeter_ofhg(float|int|string $number): self + { + $this->sequence["pressure-millimeter-ofhg"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function pressure_pound_force_per_square_inch(float|int|string $number): self + { + $this->sequence["pressure-pound-force-per-square-inch"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function pressure_inch_ofhg(float|int|string $number): self + { + $this->sequence["pressure-inch-ofhg"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function pressure_bar(float|int|string $number): self + { + $this->sequence["pressure-bar"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function pressure_millibar(float|int|string $number): self + { + $this->sequence["pressure-millibar"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function pressure_atmosphere(float|int|string $number): self + { + $this->sequence["pressure-atmosphere"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function pressure_pascal(float|int|string $number): self + { + $this->sequence["pressure-pascal"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function pressure_hectopascal(float|int|string $number): self + { + $this->sequence["pressure-hectopascal"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function pressure_kilopascal(float|int|string $number): self + { + $this->sequence["pressure-kilopascal"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function pressure_megapascal(float|int|string $number): self + { + $this->sequence["pressure-megapascal"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function speed_kilometer_per_hour(float|int|string $number): self + { + $this->sequence["speed-kilometer-per-hour"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function speed_meter_per_second(float|int|string $number): self + { + $this->sequence["speed-meter-per-second"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function speed_mile_per_hour(float|int|string $number): self + { + $this->sequence["speed-mile-per-hour"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function speed_knot(float|int|string $number): self + { + $this->sequence["speed-knot"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function temperature_celsius(float|int|string $number): self + { + $this->sequence["temperature-celsius"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function temperature_fahrenheit(float|int|string $number): self + { + $this->sequence["temperature-fahrenheit"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function temperature_kelvin(float|int|string $number): self + { + $this->sequence["temperature-kelvin"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function torque_pound_force_foot(float|int|string $number): self + { + $this->sequence["torque-pound-force-foot"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function torque_newton_meter(float|int|string $number): self + { + $this->sequence["torque-newton-meter"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_cubic_kilometer(float|int|string $number): self + { + $this->sequence["volume-cubic-kilometer"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_cubic_meter(float|int|string $number): self + { + $this->sequence["volume-cubic-meter"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_cubic_centimeter(float|int|string $number): self + { + $this->sequence["volume-cubic-centimeter"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_cubic_mile(float|int|string $number): self + { + $this->sequence["volume-cubic-mile"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_cubic_yard(float|int|string $number): self + { + $this->sequence["volume-cubic-yard"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_cubic_foot(float|int|string $number): self + { + $this->sequence["volume-cubic-foot"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_cubic_inch(float|int|string $number): self + { + $this->sequence["volume-cubic-inch"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_megaliter(float|int|string $number): self + { + $this->sequence["volume-megaliter"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_hectoliter(float|int|string $number): self + { + $this->sequence["volume-hectoliter"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_liter(float|int|string $number): self + { + $this->sequence["volume-liter"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_deciliter(float|int|string $number): self + { + $this->sequence["volume-deciliter"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_centiliter(float|int|string $number): self + { + $this->sequence["volume-centiliter"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_milliliter(float|int|string $number): self + { + $this->sequence["volume-milliliter"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_pint_metric(float|int|string $number): self + { + $this->sequence["volume-pint-metric"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_cup_metric(float|int|string $number): self + { + $this->sequence["volume-cup-metric"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_acre_foot(float|int|string $number): self + { + $this->sequence["volume-acre-foot"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_bushel(float|int|string $number): self + { + $this->sequence["volume-bushel"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_gallon(float|int|string $number): self + { + $this->sequence["volume-gallon"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_gallon_imperial(float|int|string $number): self + { + $this->sequence["volume-gallon-imperial"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_quart(float|int|string $number): self + { + $this->sequence["volume-quart"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_pint(float|int|string $number): self + { + $this->sequence["volume-pint"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_cup(float|int|string $number): self + { + $this->sequence["volume-cup"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_fluid_ounce(float|int|string $number): self + { + $this->sequence["volume-fluid-ounce"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_fluid_ounce_imperial(float|int|string $number): self + { + $this->sequence["volume-fluid-ounce-imperial"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_tablespoon(float|int|string $number): self + { + $this->sequence["volume-tablespoon"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_teaspoon(float|int|string $number): self + { + $this->sequence["volume-teaspoon"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_barrel(float|int|string $number): self + { + $this->sequence["volume-barrel"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_dessert_spoon(float|int|string $number): self + { + $this->sequence["volume-dessert-spoon"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_dessert_spoon_imperial(float|int|string $number): self + { + $this->sequence["volume-dessert-spoon-imperial"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_drop(float|int|string $number): self + { + $this->sequence["volume-drop"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_dram(float|int|string $number): self + { + $this->sequence["volume-dram"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_jigger(float|int|string $number): self + { + $this->sequence["volume-jigger"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_pinch(float|int|string $number): self + { + $this->sequence["volume-pinch"] = $number; + + return $this; + } + + /** + * @param float|int|numeric-string $number + * + * @return $this + */ + public function volume_quart_imperial(float|int|string $number): self + { + $this->sequence["volume-quart-imperial"] = $number; + + return $this; + } + +} diff --git a/lib/Units/UnitsCompanion.php b/lib/Units/UnitsCompanion.php new file mode 100644 index 0000000..592ef59 --- /dev/null +++ b/lib/Units/UnitsCompanion.php @@ -0,0 +1,1643 @@ +getMockBuilder(Units::class) - ->onlyMethods([ 'assert_is_unit', 'format_sequence' ]) + ->onlyMethods([ 'format_sequence' ]) ->disableOriginalConstructor() ->getMock(); - $units - ->expects($this->once()) - ->method('assert_is_unit') - ->with($unit); $units ->expects($this->once()) ->method('format_sequence') @@ -52,13 +48,9 @@ public function test_to_string(): void $length = Units::DEFAULT_LENGTH; $units = $this->getMockBuilder(Units::class) - ->onlyMethods([ 'assert_is_unit', 'format_sequence' ]) + ->onlyMethods([ 'format_sequence' ]) ->disableOriginalConstructor() ->getMock(); - $units - ->expects($this->once()) - ->method('assert_is_unit') - ->with($unit); $units ->expects($this->once()) ->method('format_sequence') diff --git a/tests/UnitsTest.php b/tests/UnitsTest.php index 017c659..c16a8bc 100644 --- a/tests/UnitsTest.php +++ b/tests/UnitsTest.php @@ -49,7 +49,7 @@ public static function provide_test_cases(): array [ 'fr', - 'acceleration-g-force', + 'acceleration_g_force', 123.4504, UnitLength::LONG, "123,45 fois l’accélération de pesanteur terrestre" @@ -270,22 +270,6 @@ public function test_getter(): void $this->assertSame($unit, $units->angle_degree); } - #[Test] - public function should_fail_with_undefined_unit(): void - { - $this->expectExceptionMessage("No such unit: undefined-unit"); - $this->expectException(BadMethodCallException::class); - $this->units_for('fr')->{'undefined_unit'}(); - } - - public function test_unit_method_requires_one_argument(): void - { - $this->expectExceptionMessage("acceleration_g_force() expects one argument, got 0"); - $this->expectException(BadMethodCallException::class); - - $this->units_for('en')->acceleration_g_force(); // @phpstan-ignore-line - } - private function units_for(string $locale): Units { return new Units(self::$locales[$locale]); // @phpstan-ignore-line