PHPackages                             ayeo/temperature - 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. ayeo/temperature

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

ayeo/temperature
================

Simple library to handle temperature scales

0.1.1(11y ago)036MITPHPPHP &gt;=5.4.0

Since Dec 19Pushed 11y ago2 watchersCompare

[ Source](https://github.com/ayeo/temperature)[ Packagist](https://packagist.org/packages/ayeo/temperature)[ Docs](https://github.com/ayeo/temperature)[ RSS](/packages/ayeo-temperature/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

[![Build Status](https://camo.githubusercontent.com/264c728fa8b7c4d9611e641387cccef47830ced06a5aea3468c2663facf10428/687474703a2f2f696d672e736869656c64732e696f2f7472617669732f6179656f2f74656d70657261747572652e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/ayeo/temperature)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/80a79e58e5e35c985de8e71e322382872869f7c07f652adfd9197dbe4fc76eea/687474703a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6179656f2f74656d70657261747572652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/ayeo/temperature/build-status/master)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](license.md)[![Packagist Version](https://camo.githubusercontent.com/48c0b8d896c77bdae586f483a2b6ea534d48229d253ed25a3bd3a77e70995e7b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6179656f2f74656d70657261747572652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ayeo/temperature)[![Code Coverage](https://camo.githubusercontent.com/710735848acd900494c27ff85b5699a8951f393b7feb4da3e228924370647ff5/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6179656f2f74656d70657261747572652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/ayeo/temperature/?branch=master)Temperature
================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#temperature)

Simple library to handle temperature scales. Features:

- Display formatted tempteratue (e.g 100 °C)
- Simple convert beetwen different scales

### Supported temperature scales

[](#supported-temperature-scales)

- Celsius (C)
- Kelvin (K)
- Farenheit (F)
- Rankine (R)
- Reaumur (Re)

### Install using Composer

[](#install-using-composer)

```
require: {
	"ayeo/temperature": "~0.1"
}

```

### Basic usage

[](#basic-usage)

```
use Temperature\Factory\DefaultFactory as TemperatureFactory;

$factory = new TemperatureFactory();
$temperature = $factory->build(63, 'F');

$temperature; //63 °F
$temperature->convert('C'); //17.2222222222 °C
$temperature->convert('C')->setPrecision(2); //17.22 °C
```

### Auto conversion

[](#auto-conversion)

You can set Factory to autoconvert temperatures to given scale

```
use Temperature\Factory\DefaultFactory as TemperatureFactory;

$factory = new TemperatureFactory;
$factory->setAutoconvertTo('C');
$factory->getFormatter()->setPrecision(2);

$factory->build(100, 'F'); //37.78 °C

```

### Custom formatter

[](#custom-formatter)

As default formatter is build by your locale settings. You can adjust it to your needs.

```
use Temperature\Formatter\StandardFormatter;

$formatter = new StandardFormatter();
$formatter->setDecimalSeperator(",");
$formatter->setPrecision(2);
$formatter->setShowSymbolMode(false);

$factory->setFormatter($formatter);

$factory->build(10.50, 'C'); //10,50
$factory->build(100, 'K'); //100
```

You can write your own Formatter. I must implemetnts FormatterInterface.

### Custom temperature scale

[](#custom-temperature-scale)

Assume you need new temperature scale. For purpose of this example let say C2 = 2 \* Celsius

```
use \Temperature\Scales\Scale\AbstractScale;

class C2Scale extends AbstractScale
{
	const SYMBOL = "C2";

	/**
	 * @return float
	 */
	function getValueInCelsius()
	{
		return $this->value / 2;
	}

	/**
	 * @param $celsius
	 */
	function setValueInCelsius($celsius)
	{
		$this->value = $celsius * 2;
	}
}

$factory->getSupportedScales()->addSupportedType('C2', 'C2Scale');
$factory->build(100, 'C')->convert('C2'); //200 C2
$factory->build(50, 'K')->convert('C2'); //-446 C2
```

License
-------

[](#license)

The MIT License (MIT). Please see [the license file](license.md) for more information.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% 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

Unknown

Total

1

Last Release

4168d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9e19f24a709e451d9017d8748a8f42a03a3974a9ab065aeda950ec96b229d7f4?d=identicon)[ayeo](/maintainers/ayeo)

---

Top Contributors

[![ayeo](https://avatars.githubusercontent.com/u/60191?v=4)](https://github.com/ayeo "ayeo (4 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ayeo-temperature/health.svg)

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

###  Alternatives

[akaunting/laravel-money

Currency formatting and conversion package for Laravel

7825.3M18](/packages/akaunting-laravel-money)[symfony/polyfill-php54

Symfony polyfill backporting some PHP 5.4+ features to lower PHP versions

9630.8M5](/packages/symfony-polyfill-php54)[kartik-v/yii2-widget-colorinput

An enhanced Yii 2 widget encapsulating the HTML 5 color input (sub repo split from yii2-widgets)

324.8M10](/packages/kartik-v-yii2-widget-colorinput)[kartik-v/yii2-widget-affix

A scrollspy and affixed enhanced navigation to highlight page sections (sub repo split from yii2-widgets)

153.8M3](/packages/kartik-v-yii2-widget-affix)[flow-php/array-dot

PHP ETL - Array Dot functions

14374.1k3](/packages/flow-php-array-dot)

PHPackages © 2026

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