Download the PHP package nmarfurt/measurements without Composer

On this page you can find all versions of the php package nmarfurt/measurements. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package measurements

Measurements & Units

Build Status Latest Stable Version License

About

This is a PHP library for representing and converting dimensional units of measure. This is inspired by the Measurement API in the Apple Foundation Framework.

Installation

The package can be installed via Composer:

Library Classes

Unit

Unit is the abstract superclass of units. Each instance of an Unit subclass consists of a symbol, which can be used to create string representations of Measurement objects.

Dimension

Dimension is an abstract subclass of Unit that represents unit families or a dimensional unit of measure, which can be converted into different units of the same type. Each instance of an Dimension subclass has a converter, which is used to represent the unit in terms of the dimension's base unit provided by the baseUnit() method.

The library provides concrete subclasses for many of the most common types of physical units (listed below). If you need a custom unit type to represent a custom or derived unit, you can subclass Dimension. If you need to represent dimensionless units, subclass Unit directly.

UnitConverter

A UnitConverter describes how to convert a unit to and from the base unit of its dimension. UnitConverterLinear is a UnitConverter subclass for converting between units using a linear equation. You can define your own converters if needed.

Measurement

A Measurement object represents a measured quantity, using a unit of measure and a value. The Measurement class provides a programmatic interface to converting measurements into different units, as well as calculating the sum or difference between two measurements.

Measurement objects are initialized with a Unit object and double value. They are immutable and cannot be changed after being created.

The library provides specific subclasses (so called Quantities) for measurements that correspond to the provided units (see the list below).

Provided Units & Quantities

The library provides concrete subclasses for many of the most common types of physical units:

Dimension Subclass Description Base Unit Measurement Subclass
UnitAcceleration Unit of measure for acceleration meters per second squared m/s² Acceleration
UnitAngle Unit of measure for planar angle and rotation degrees ° Angle
UnitArea Unit of measure for area square meters Area
UnitConcentrationMass Unit of measure for concentration of mass milligrams per deciliter mg/dL ConcentrationMass
UnitDispersion Unit of measure for dispersion parts per million ppm Dispersion
UnitDuration Unit of measure for duration seconds sec Duration
UnitElectricCharge Unit of measure for electric charge coulombs C ElectricCharge
UnitElectricCurrent Unit of measure for electric current amperes A ElectricCurrent
UnitElectricPotentialDifference Unit of measure for electric potential difference volts V ElectricPotentialDifference
UnitElectricResistance Unit of measure for electric resistance ohms Ω ElectricResistance
UnitEnergy Unit of measure for energy joules J Energy
UnitFrequency Unit of measure for frequency hertz Hz Frequency
UnitFuelEfficiency Unit of measure for fuel consumption liters per 100 kilometers L/100km FuelEfficiency
UnitIlluminance Unit of measure for illuminance lux lx Illuminance
UnitLength Unit of measure for length meters m Length
UnitMass Unit of measure for mass kilograms kg Mass
UnitPower Unit of measure for power watts W Power
UnitPressure Unit of measure for pressure newtons per square meter N/m² Pressure
UnitRadioactivity Unit of measure for radioactivity becquerel Bq Radioactivity
UnitSpeed Unit of measure for speed meters per second m/s Speed
UnitTemperature Unit of measure for temperature kelvin K Temperature
UnitVolume Unit of measure for volume liters L Volume

Usage

Using Measurements

You can define measurements as follows:

You may want to enforce the unit type of a measurement by using the provided measurement subclasses (aka Quantities):

The Quantities objects also provide the benefit of an expressive syntax to create measurements. They make use of the __callStatic() magic-method to create a new instance by resolving the derived dimension.

Some of the Measurement subclasses expose convenience methods to easily create instances from other measurements.

Converting Measurements

Measurement objects of the same dimension can be converted from one unit of measure to another.

Measurements created as Quantities objects also provide a short syntax to convert them. They make use of the __call() magic-method to resolve the derived dimension.

Making Arithmetic Operations

Measurement objects support different operations, including add (+), subtract (-), multiply (*) and divide (/). Since Measurement objects are immutable, new instances are returned.

Conversions are automatically applied while making operations on measurements with different units. The returned measurement is defined in the base unit.

It is also possible to make arithmetic operations on a measurement using values.

Working with Custom Units

In addition to provided units, you can define custom units. Custom units can be initialized from a symbol and converter of an existing type or implemented as a class method of an existing type for additional convenience. You can also define your own Dimension subclass to represent an entirely new unit dimension.

Initializing a Custom Unit with a Specified Symbol and Definition

The simplest way to define a custom unit is to create a new instance of an existing Dimension subclass.

For example, let define a jump as a custom, nonstandard unit of length (1 jump = 1.82 m). You can create a new instance of UnitLength as follows:

Extending Existing Dimension Subclasses

Alternatively, you can extend an existing Dimension subclass to define a new unit.

For example, let define our new jump unit as custom subclass:

Creating a Custom Dimension Subclass

You can create a new subclass of Dimension to describe a new unit dimension.

For example, let define units for digital data. In computing and telecommunications, a unit of information is the capacity of some standard data storage system or communication channel, used to measure the capacities of other systems and channels. Bytes, or multiples thereof, are common units used to specify the sizes of computer files and the capacity of storage units.

You can implement a UnitDigitalData class that defines units of digital information as follows:

Generating API Documentation

License

This library is open-sourced software licensed under the MIT license.


All versions of measurements with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2 | ^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package nmarfurt/measurements contains the following files

Loading the files please wait ....