Oihana PHP Standards

MeasureCode uses ConstantsTrait

UN/CEFACT Unit of Measure Codes Enumeration Class (Recommendation 20).

This class provides an extended selection of the most commonly used codes across various commercial and logistical contexts.

For an exhaustive list and official documentation, please consult:

Tags
see
https://unece.org/trade/uncefact/cl-recommendations
example
<?php
$logger->info( MeasureCode::PERCENT ) ; // 'PC1'
$logger->info( MeasureCode::getName( UnitCodes::PERCENT ) ) ; // 'Percent'
$logger->info( MeasureCode::getSymbol( UnitCodes::PERCENT ) ) ; // '%'
$logger->info( json_encode( MeasureCode::get( UnitCodes::PERCENT ) ) ); // {"name":"Percent","unitCode":"PC1","unitText":"%"}
$logger->info( MeasureCode::getFromName( UnitNames::PERCENT ) ) ; // 'PC1'
$logger->info( MeasureCode::getFromSymbol( UnitSymbols::PERCENT ) ) ; // 'PC1'

Table of Contents

Constants

ACRE  : string = 'ACR'
ACRE_FOOT  : string = 'AFK'
AMPERE  : string = 'AMP'
ANGULAR  : string = 'DD'
BAR  : string = 'BAR'
BARREL  : string = 'BLL'
BECQUEREL  : string = 'BQL'
BIT  : string = 'BIT'
BYTE  : string = 'BTE'
CALORIE  : string = 'CAL'
CARAT  : string = 'CTM'
CELSIUS  : string = 'CEL'
CENTILITRE  : string = 'CLT'
CENTIMETER  : string = 'CMT'
COULOMB  : string = 'CLB'
COUNT  : string = 'CBR'
CUBIC_CENTIMETER  : string = 'CMQ'
CUBIC_DECIMETER  : string = 'DMQ'
CUBIC_FOOT  : string = 'FTQ'
CUBIC_METER  : string = 'MTQ'
DAY  : string = 'DAY'
DECIBEL  : string = 'DB'
DOZEN  : string = 'DZN'
FAHRENHEIT  : string = 'FAH'
FARAD  : string = 'FAR'
FOOT  : string = 'FOT'
GIGABYTE  : string = 'GB'
GRAM  : string = 'GRM'
GRAY  : string = 'GRY'
GROSS  : string = 'GRO'
HECTARE  : string = 'HAR'
HECTOMETER  : string = 'HMT'
HENRY  : string = 'HNH'
HERTZ  : string = 'HTZ'
HOUR  : string = 'HUR'
HUNDRED  : string = 'CEN'
IMPERIAL_GALLON  : string = 'GLI'
INCH  : string = 'INH'
JOULE  : string = 'JOU'
KELVIN  : string = 'KEL'
KILOBYTE  : string = 'KB'
KILOCALORIE  : string = 'KCC'
KILOGRAM  : string = 'KGM'
KILOHERTZ  : string = 'KHZ'
KILOJOULE  : string = 'KJO'
KILOMETER  : string = 'KMT'
KILOWATT  : string = 'KWT'
KILOWATT_HOUR  : string = 'KWH'
LITER  : string = 'LTR'
LUMEN  : string = 'LUM'
LUX  : string = 'LUX'
MEGABYTE  : string = 'MB'
MEGAHERTZ  : string = 'MHZ'
METER  : string = 'MTR'
METRIC_TON  : string = 'TNE'
MILE  : string = 'SMI'
MILLIBAR  : string = 'MBR'
MILLIGRAM  : string = 'MGM'
MILLILITER  : string = 'MLT'
MILLIMETER  : string = 'MMT'
MINUTE  : string = 'MIN'
MONTH  : string = 'MON'
NEWTON  : string = 'NEW'
NUMBER  : string = 'NMB'
OHM  : string = 'OHM'
OUNCE  : string = 'OZA'
PAIR  : string = 'PR'
PARTS_PER_MILLION  : string = 'PPM'
PASCAL  : string = 'PAL'
PER_THOUSAND  : string = 'PER'
PERCENT  : string = 'PC1'
PIECE  : string = 'PCE'
POINT  : string = 'PT'
POUND  : string = 'LBR'
POUND_FORCE  : string = 'LBF'
POUND_PER_SQUARE_INCH  : string = 'PSI'
RADIAN  : string = 'RAD'
RATIO  : string = 'RTO'
REVOLUTION_PER_MINUTE  : string = 'RPM'
SCORE  : string = 'SCO'
SECOND  : string = 'SEC'
SIEMENS  : string = 'SIE'
SIEVERT  : string = 'SVT'
SQUARE_CENTIMETER  : string = 'CMK'
SQUARE_DECIMETER  : string = 'DMK'
SQUARE_FOOT  : string = 'FTK'
SQUARE_INCH  : string = 'INK'
SQUARE_KILOMETER  : string = 'KMK'
SQUARE_METER  : string = 'MTK'
SQUARE_MILE  : string = 'SMK'
SQUARE_MILLIMETER  : string = 'MMK'
SQUARE_YARD  : string = 'YKM'
TEN_PAIRS  : string = 'DPA'
TESLA  : string = 'TSL'
THOUSAND  : string = 'THM'
UNIT  : string = 'C62'
UNIT_OF_CAPITAL  : string = 'UC'
US_GALLON  : string = 'GLD'
VOLT  : string = 'VLT'
WATT  : string = 'WTT'
WEBER  : string = 'WEB'
WEEK  : string = 'WEE'
YARD  : string = 'YRD'
YEAR  : string = 'ANN'

Properties

$NAMES  : array<string|int, mixed>|null
$SYMBOLS  : array<string|int, mixed>|null

Methods

getFromName()  : string|null
Returns the code with a specific unit code name.
getFromSymbol()  : string|null
Returns the code from a specific unit code symbol.
getName()  : string|null
Returns the official UN/CEFACT name for a given code.
getSymbol()  : string|null
Returns the official UN/CEFACT symbol for a given code.
resetCaches()  : void
Reset the internal cache of the static methods.

Constants

CUBIC_CENTIMETER

public string CUBIC_CENTIMETER = 'CMQ'

CUBIC_DECIMETER

public string CUBIC_DECIMETER = 'DMQ'

IMPERIAL_GALLON

public string IMPERIAL_GALLON = 'GLI'

PARTS_PER_MILLION

public string PARTS_PER_MILLION = 'PPM'

POUND_PER_SQUARE_INCH

public string POUND_PER_SQUARE_INCH = 'PSI'

REVOLUTION_PER_MINUTE

public string REVOLUTION_PER_MINUTE = 'RPM'

SQUARE_CENTIMETER

public string SQUARE_CENTIMETER = 'CMK'

SQUARE_DECIMETER

public string SQUARE_DECIMETER = 'DMK'

SQUARE_KILOMETER

public string SQUARE_KILOMETER = 'KMK'

SQUARE_MILLIMETER

public string SQUARE_MILLIMETER = 'MMK'

UNIT_OF_CAPITAL

public string UNIT_OF_CAPITAL = 'UC'

Properties

$NAMES

private static array<string|int, mixed>|null $NAMES = null

$SYMBOLS

private static array<string|int, mixed>|null $SYMBOLS = null

Methods

getFromName()

Returns the code with a specific unit code name.

public static getFromName(string $name) : string|null
Parameters
$name : string
Return values
string|null

getFromSymbol()

Returns the code from a specific unit code symbol.

public static getFromSymbol(string $symbol) : string|null
Parameters
$symbol : string
Return values
string|null

getName()

Returns the official UN/CEFACT name for a given code.

public static getName(string $code) : string|null
Parameters
$code : string
Return values
string|null

The UN/CEFACT name or null if not found.

getSymbol()

Returns the official UN/CEFACT symbol for a given code.

public static getSymbol(string $code) : string|null
Parameters
$code : string
Return values
string|null

The UN/CEFACT code (e.g., 'KGM') or null if not found.

resetCaches()

Reset the internal cache of the static methods.

public static resetCaches() : void
On this page

Search results