Unit
Phuture\Coherence\Enum\Unit
enum Unit
Enumeration of all supported measurement units for unit conversion.
Each case represents a specific unit of measurement. Use these cases with \Phuture\Coherence\Numbers::convert() to convert a value from one unit to another within the same measurement category (for example, from Celsius to Fahrenheit, or from Kilometer to Mile).
The units are organized into the following categories:
- Temperature: Celsius, Fahrenheit, Kelvin, Rankine
- Distance: Meter, Millimeter, Centimeter, Decimeter, Kilometer, Inch, Foot, Yard, Mile, NauticalMile
- Mass: Kilogram, Gram, Milligram, Microgram, MetricTon, Pound, Ounce, Stone, UsTon, ImperialTon
- Volume: Liter, Milliliter, CubicMeter, GallonUs, QuartUs, PintUs, CupUs, FluidOunceUs, Tablespoon, Teaspoon
- Time: Second, Millisecond, Microsecond, Nanosecond, Minute, Hour, Day, Week
- Area: SquareMeter, SquareKilometer, Hectare, Acre, SquareFoot, SquareYard, SquareMile, SquareInch
- Speed: MeterPerSecond, KilometerPerHour, MilePerHour, Knot, FootPerSecond
- Pressure: Pascal, Kilopascal, Bar, Millibar, Atmosphere, Psi, Mmhg
- Energy: Joule, Kilojoule, Calorie, Kilocalorie, WattHour, KilowattHour, Btu, Electronvolt
- Power: Watt, Kilowatt, Megawatt, HorsepowerMechanical, HorsepowerMetric
- Force: Newton, Kilonewton, Dyne, PoundForce, KilogramForce
- Electric Potential: Volt, Millivolt, Kilovolt, Megavolt
- Electric Current: Ampere, Milliampere, Microampere, Kiloampere
- Luminous Intensity: Candela, Millicandela, Kilocandela
Example:
1use Phuture\Coherence\Enum\Unit;
2use Phuture\Coherence\Numbers;
3
4$fahrenheit = Numbers::convert(100, Unit::Celsius, Unit::Fahrenheit);
5// Returns: '212.0000000000'
6
7$miles = Numbers::convert(1, Unit::Kilometer, Unit::Mile);
8// Returns: '0.6213711922'
Cases
Acre
case Acre
Acre, an imperial unit of area equal to approximately 4046.8564224 square meters.
Ampere
case Ampere
Ampere, the base SI unit of electric current.
Atmosphere
case Atmosphere
Standard atmosphere, a reference pressure equal to 101325 pascals.
Bar
case Bar
Bar, a metric unit of pressure equal to 100000 pascals.
Btu
case Btu
British thermal unit (BTU), approximately 1055.06 joules.
Calorie
case Calorie
Calorie (thermochemical), approximately 4.184 joules.
Candela
case Candela
Candela, the base SI unit of luminous intensity.
Celsius
case Celsius
Degrees Celsius, the standard metric temperature scale where water freezes at 0 and boils at 100.
Centimeter
case Centimeter
Centimeter, one hundredth of a meter (0.01 meters).
CubicMeter
case CubicMeter
Cubic meter, a metric unit of volume equal to 1000 liters.
CupUs
case CupUs
US cup, one sixteenth of a US gallon (approximately 0.2365882365 liters).
Day
case Day
Day, 86400 seconds (24 hours).
Decimeter
case Decimeter
Decimeter, one tenth of a meter (0.1 meters).
Dyne
case Dyne
Dyne, a CGS unit of force equal to 0.00001 newtons.
Electronvolt
case Electronvolt
Electronvolt, a tiny unit of energy used in particle physics (approximately 1.602e-19 joules).
Fahrenheit
case Fahrenheit
Degrees Fahrenheit, the temperature scale where water freezes at 32 and boils at 212.
FluidOunceUs
case FluidOunceUs
US fluid ounce, a US unit of volume equal to approximately 0.029573529 liters.
Foot
case Foot
Foot, an imperial unit of length equal to exactly 12 inches (0.3048 meters).
FootPerSecond
case FootPerSecond
Feet per second, an imperial speed unit equal to exactly 0.3048 meters per second.
GallonUs
case GallonUs
US gallon, a US customary unit of volume equal to approximately 3.785411784 liters.
Gram
case Gram
Gram, one thousandth of a kilogram (0.001 kilograms).
Hectare
case Hectare
Hectare, a metric unit of area equal to 10000 square meters.
HorsepowerMechanical
case HorsepowerMechanical
Mechanical horsepower, an imperial power unit equal to approximately 745.7 watts.
HorsepowerMetric
case HorsepowerMetric
Metric horsepower (PS), equal to approximately 735.499 watts.
Hour
case Hour
Hour, 3600 seconds (60 minutes).
ImperialTon
case ImperialTon
Imperial ton (long ton), equal to 2240 pounds (approximately 1016.0469088 kilograms).
Inch
case Inch
Inch, an imperial unit of length equal to exactly 0.0254 meters.
Joule
case Joule
Joule, the base SI unit of energy.
Kelvin
case Kelvin
Kelvin, the absolute temperature scale starting at absolute zero (-273.15 degrees Celsius).
Kiloampere
case Kiloampere
Kiloampere, one thousand amperes.
Kilocalorie
case Kilocalorie
Kilocalorie (food calorie), approximately 4184 joules.
Kilocandela
case Kilocandela
Kilocandela, one thousand candelas.
Kilogram
case Kilogram
Kilogram, the base unit of mass in the metric system.
KilogramForce
case KilogramForce
Kilogram-force, a gravitational metric unit of force equal to approximately 9.80665 newtons.
Kilojoule
case Kilojoule
Kilojoule, one thousand joules.
Kilometer
case Kilometer
Kilometer, one thousand meters (1000 meters).
KilometerPerHour
case KilometerPerHour
Kilometers per hour, a metric speed unit equal to approximately 0.277778 meters per second.
Kilonewton
case Kilonewton
Kilonewton, one thousand newtons.
Kilopascal
case Kilopascal
Kilopascal, one thousand pascals.
Kilovolt
case Kilovolt
Kilovolt, one thousand volts.
Kilowatt
case Kilowatt
Kilowatt, one thousand watts.
KilowattHour
case KilowattHour
Kilowatt-hour, a unit of energy equal to 3600000 joules.
Knot
case Knot
Knot, a speed unit equal to one nautical mile per hour (approximately 0.514444 meters per second).
Liter
case Liter
Liter, the base metric unit of volume.
Megavolt
case Megavolt
Megavolt, one million volts.
Megawatt
case Megawatt
Megawatt, one million watts.
Meter
case Meter
Meter, the base unit of length in the metric system.
MeterPerSecond
case MeterPerSecond
Meters per second, the base metric unit of speed.
MetricTon
case MetricTon
Metric ton, one thousand kilograms.
Microampere
case Microampere
Microampere, one millionth of an ampere (0.000001 amperes).
Microgram
case Microgram
Microgram, one millionth of a gram (0.000000001 kilograms).
Microsecond
case Microsecond
Microsecond, one millionth of a second (0.000001 seconds).
Mile
case Mile
Mile, an imperial unit of distance equal to 5280 feet (1609.344 meters).
MilePerHour
case MilePerHour
Miles per hour, an imperial speed unit equal to approximately 0.44704 meters per second.
Milliampere
case Milliampere
Milliampere, one thousandth of an ampere (0.001 amperes).
Millibar
case Millibar
Millibar, one thousandth of a bar (100 pascals).
Millicandela
case Millicandela
Millicandela, one thousandth of a candela (0.001 candelas).
Milligram
case Milligram
Milligram, one thousandth of a gram (0.000001 kilograms).
Milliliter
case Milliliter
Milliliter, one thousandth of a liter (0.001 liters).
Millimeter
case Millimeter
Millimeter, one thousandth of a meter (0.001 meters).
Millisecond
case Millisecond
Millisecond, one thousandth of a second (0.001 seconds).
Millivolt
case Millivolt
Millivolt, one thousandth of a volt (0.001 volts).
Minute
case Minute
Minute, 60 seconds.
Mmhg
case Mmhg
Millimeters of mercury (mmHg), a pressure unit equal to approximately 133.322 pascals.
Nanosecond
case Nanosecond
Nanosecond, one billionth of a second (0.000000001 seconds).
NauticalMile
case NauticalMile
Nautical mile, a unit used in air and sea navigation equal to exactly 1852 meters.
Newton
case Newton
Newton, the base SI unit of force.
Ounce
case Ounce
Ounce, an imperial unit of mass equal to approximately 0.028349523 kilograms (1/16 of a pound).
Pascal
case Pascal
Pascal, the base SI unit of pressure (one newton per square meter).
PintUs
case PintUs
US pint, one eighth of a US gallon (approximately 0.473176473 liters).
Pound
case Pound
Pound, an imperial unit of mass equal to approximately 0.45359237 kilograms.
PoundForce
case PoundForce
Pound-force, an imperial unit of force equal to approximately 4.448222 newtons.
Psi
case Psi
Pounds per square inch (PSI), an imperial pressure unit equal to approximately 6894.757 pascals.
QuartUs
case QuartUs
US quart, one fourth of a US gallon (approximately 0.946352946 liters).
Rankine
case Rankine
Degrees Rankine, an absolute temperature scale where zero is absolute zero and each degree equals one degree Fahrenheit.
Second
case Second
Second, the base unit of time.
SquareFoot
case SquareFoot
Square foot, an imperial unit of area equal to approximately 0.09290304 square meters.
SquareInch
case SquareInch
Square inch, an imperial unit of area equal to approximately 0.00064516 square meters.
SquareKilometer
case SquareKilometer
Square kilometer, one million square meters.
SquareMeter
case SquareMeter
Square meter, the base metric unit of area.
SquareMile
case SquareMile
Square mile, an imperial unit of area equal to approximately 2589988.110336 square meters.
SquareYard
case SquareYard
Square yard, an imperial unit of area equal to approximately 0.83612736 square meters.
Stone
case Stone
Stone, an imperial unit of mass equal to 14 pounds (approximately 6.350293 kilograms).
Tablespoon
case Tablespoon
Tablespoon, a culinary unit of volume equal to approximately 0.014786764 liters.
Teaspoon
case Teaspoon
Teaspoon, a culinary unit of volume equal to approximately 0.004928921 liters.
UsTon
case UsTon
US ton (short ton), equal to 2000 pounds (approximately 907.18474 kilograms).
Volt
case Volt
Volt, the base SI unit of electric potential.
Watt
case Watt
Watt, the base SI unit of power (one joule per second).
WattHour
case WattHour
Watt-hour, a unit of energy equal to 3600 joules.
Week
case Week
Week, 604800 seconds (7 days).
Yard
case Yard
Yard, an imperial unit of length equal to exactly 3 feet (0.9144 meters).
Methods
category()
public function category(): string
Returns the measurement category this unit belongs to.
Each unit belongs to exactly one category such as 'temperature', 'distance', or 'mass'. Conversions are only valid between units in the same category.
Example:
1use Phuture\Coherence\Enum\Unit;
2
3Unit::Celsius->category(); // 'temperature'
4Unit::Kilometer->category(); // 'distance'
5Unit::Kilogram->category(); // 'mass'
Returns string — The category name
factor()
public function factor(): string
Returns the multiplication factor to convert this unit to the base unit of its category.
The factor is a numeric string suitable for use with BCMath functions. Multiplying a value in this unit by the factor produces the equivalent value in the base unit of the category. For temperature units, this factor is not used because temperature conversion requires offset-based formulas handled separately by \Phuture\Coherence\Numbers::convertTemperature().
Example:
1use Phuture\Coherence\Enum\Unit;
2
3Unit::Kilometer->factor(); // '1000' (1 km = 1000 meters)
4Unit::Gram->factor(); // '0.001' (1 g = 0.001 kilograms)
5Unit::Hour->factor(); // '3600' (1 hour = 3600 seconds)
Returns string — The conversion factor as a BCMath-compatible numeric string