PHPackages                             mibo/properties - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mibo/properties

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mibo/properties
===============

PHP Library for generic and/or custom properties

1.2.0(1y ago)04.4k[2 issues](https://github.com/4513/properties/issues)1MITPHPPHP ^8.2

Since Jun 4Pushed 1y ago2 watchersCompare

[ Source](https://github.com/4513/properties)[ Packagist](https://packagist.org/packages/mibo/properties)[ GitHub Sponsors](https://github.com/4513)[ RSS](/packages/mibo-properties/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (9)Versions (10)Used By (1)

Properties
==========

[](#properties)

[![codecov](https://camo.githubusercontent.com/e50d83708caee481de24b0e35db951fa5bc5495e38b43594c7faeb5efb3c37df/68747470733a2f2f636f6465636f762e696f2f67682f343531332f70726f706572746965732f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d5739434359494f52464e)](https://codecov.io/gh/4513/properties)

*Yep. This is a calculator.*

The main purpose, however, is not to calculate, but to help developers to get more accurate results when calculating with floating point numbers. Furthermore, the library comes with several functions:

1. Calculating properties
    - Adding, subtracting, multiplying and dividing numbers
    - More accurate result
        - by trying to use integer instead of floats
        - by trying not to divide numbers when not really necessary *\[1\]*
2. Quantities
    - Quantities such as a length, a time, etc. are provided (more to come)
    - Multiplying and dividing quantities generates a new quantity (length \* length = area)
3. SI and Units
    - SI Prefixes (Centi, Deci, Kilo,...)
    - One can use different Unit of a Quantity and to not worry about the conversion. The units can be automatically converted to the base unit of the quantity *\[2\]*
4. Converting
    - Converting between different units of a quantity
    - One does not have to worry about converting. The properties implement `convertToUnit` method which converts the quantity to the given unit. Developer does not have to convert the property before calculating with it, because the converting is done automatically.

\[1\] *The library tries to avoid dividing numbers when not really necessary. For example, when calculating the multiple numbers, and a dividing action is called, the library stores the value of the division and uses it as a multiplier for the next number. Only in the end, when the true result is called, the numbers are divided.*\[2\] *When adding a meter on 100 Centi meters, the result is 200 Centi meters. The original unit is preserved.*

All units are calculated and have its value based on the default SI units. SI Units are multiplied by 1 by default.

The library does not take a coverage on non-SI units. (They (non-SI) are there just for the sake of completeness.)

---

### Installation

[](#installation)

```
composer require mibo/properties
```

### Usage

[](#usage)

```
$length = new Length(10, Meter::get());
$length->add(...);
$length->getValue();
```

---

### Logic of the library

[](#logic-of-the-library)

Because the library contains a few different functionalities, it is important to understand the logic behind it.

Each functionality is separated from each other and so each class has its own responsibility.

#### Calculators

[](#calculators)

Calculator does any kind of calculation. It can be a simple addition, or a more complex calculation with multiplying, dividing, etc. The calculator is responsible for calculating the result. It does not care about the units, or the quantity of the numbers. It just calculates the result.

**Math**
The Math is only a class-representation of PHP native Math functions. The only point of the class is not to call the public functions and rather to use a static class.

**PropertyCalc**
The Property Calculator is responsible for calculating with properties. Its most complex function is the division and multiplication of two or more properties, because it must generate a new property of a different quantity. For example, when multiplying a length with a length, the result is an area. The Property Calculator is responsible for generating the area property.
One can override the Property Calculator by setting different Quantities into its public property of quantities.

**UnitConvertor**
Some units, or rather quantities, are not so easy to convert. Converting a length sounds easy, because all units share the same 0 value. Like... zero is a zero right? Well, lets see the temperature. 0 Celsius is not the same as 0 Fahrenheit. So, the Unit Convertor is responsible for converting the units. *Some units are not only about a coefficient that is applied to the value.*

UnitConvertor can be extended by custom convertor closure, for specified quantities.

#### Quantities

[](#quantities)

Quantities are the representation of a quantity. Each quantity should have its own class. The quantity class then contains information about its default unit to be used (by PropertyCalc), and property to be created.

Some Quantities are derived (such as speed), and so they come with `DerivedQuantity` interface, which makes them implement a method to retrieve the equation that is used to calculate the property from another properties. The equations are used by PropertyCalc.

#### Units

[](#units)

Units are the representation of a unit, and are grouped by their quantity. Some units might be used across multiple quantities, however, one must use the correct unit that belongs to the required quantity.

Units usually stores its name, symbol.

Units are created only once - they are singletons.

#### Properties

[](#properties-1)

Properties store its true value (integer, or float) - in case of NumericalProperty.
They do store its quantity and a unit.
One can say, their main purpose is to store the value which would normally be stored within a variable.

**The properties are the main objects that should be used by developers.** They do come with common methods to use mathematical operations on them.

#### Value

[](#value)

Perhaps the most complex and important part of the library, that is not supposed to be commonly used outside the library, is class Value. The Value is, in fact, the wrapper of the value within a property, meaning, the property does not store the 'value' of the integer or float, but rather the Value object, and only that stores the true value.
The Value (capital V to be distinguished from the value) is responsible for storing the value. It can be set up to be an integer (only integers are allowed), or doubles (truly double floating point number), or float (which is a normal float, no restriction), or, actually, any decimal number. One can specify the precision of the number.
Furthermore, the Value can be set to be a different base. By default, of course, decimal is used. But any other base can be used.
The Value is responsible to optimize the calculations and at the same time, tries to avoid using floats. One must understand, that because of trying to avoiding floats, the Value might be slower than using floats directly.

One must understand, that some tests DO fail because the Value is more accurate. For example, when doing 1/3\*3 in that order, on an integer property, the result is 0 (1/3 is 0, and 0\*3 is 0). However, when using the Value, the Value stores the first divider (3) into a "store", and one realizing that a multiplication of the same value is required, the Value removes the divider and does not multiply, which results in integer 1. *(That is a very simple example, but it shows the point)*

---

### What to expect to be added in the future?

[](#what-to-expect-to-be-added-in-the-future)

The library will provide more quantities and units. The goal is to add all main quantities that are specified by SI.

The library will have multiple extensions (or rather library dependents) that will provide more quantities (such as prices).

---

### Changes, updates, etc.

[](#changes-updates-etc)

The library does not cover that all calculations that do result in an integer now, will result in integer in the future. We do must meet the requirements of the speed and precision somehow.

The library does not cover non-SI units and their conversions.

The library does not cover speed of the calculations.

The library does not cover using non-decimal bases. It is a nice feature, but it is not a priority. If bugs are found, they will be fixed, but other parts of the library are prioritized.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~74 days

Recently: every ~102 days

Total

8

Last Release

598d ago

PHP version history (2 changes)1.0.0PHP ^8.1

1.1.4PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/0866c3280ed62cfc74feb086241ec9ee56bab89b4fa2b8c8a3dbd62508761b6a?d=identicon)[MiBo](/maintainers/MiBo)

---

Top Contributors

[![4513](https://avatars.githubusercontent.com/u/25705559?v=4)](https://github.com/4513 "4513 (72 commits)")

---

Tags

phppackagelibraryisomathematicsmathpropertycalculationpropertiesspeedunitsweightdistanceheightwidthtemperaturearealengthpressurevolumeSIlibforcemeasurementsmathematicalquantityMiBopowercapacitymassaccelerationphysicssi unitsquantitiesPhysical QuantitiesenergysurfaceUnits of MeasurementvelocitydepthUnits of MeasureMetric SystemInternational System of UnitsInternational SystemSI SystemSI Base UnitsSI Derived UnitsSI PrefixesSI PrefixSI Prefixes SymbolsImplemented SI PrefixesImperial SystemImperial UnitsImperial System of UnitsImperial Units of MeasurementUS Customary UnitsUS Customary SystemUS Customary Units of MeasurementCustomary UnitsCustomary SystemCustomary Units of MeasurementUS UnitsPhysicalLengthsElectric CurrentElectric ChargeElectric PotentialElectric ResistanceElectric Conductance

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/mibo-properties/health.svg)

```
[![Health](https://phpackages.com/badges/mibo-properties/health.svg)](https://phpackages.com/packages/mibo-properties)
```

###  Alternatives

[jbzoo/simpletypes

The universal PHP library to convert any values and measures

621.8k1](/packages/jbzoo-simpletypes)[mjaschen/phpgeo

Simple Yet Powerful Geo Library

1.6k9.1M27](/packages/mjaschen-phpgeo)[cartalyst/converter

A framework agnostic measurement conversion and formatting package featuring multiple types of measurements and currency conversion.

88471.0k7](/packages/cartalyst-converter)[niiknow/bayes

a machine learning lib

6954.1k](/packages/niiknow-bayes)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
