PHPackages                             xynnn/unicorn - 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. xynnn/unicorn

ActiveLibrary

xynnn/unicorn
=============

A framework agnostic PHP library to convert several units

1.0.1(9y ago)901GNU LGPL v3.0PHPPHP &gt;=7.0

Since Nov 7Pushed 2y ago3 watchersCompare

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

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

Unicorn
=======

[](#unicorn)

[![Code Coverage](https://camo.githubusercontent.com/8c19159bf86cccc9c031ca996421aeb80c373eb6f4ff0e63def84009551752a1/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f78794e4e4e2f756e69636f726e2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/xyNNN/unicorn/?branch=master)[![Build Status](https://camo.githubusercontent.com/c0f2142d3d1cf339f702f1334e548090cdc5618e850ec12a8ec9fa335b838197/68747470733a2f2f7472617669732d63692e6f72672f78794e4e4e2f756e69636f726e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/xyNNN/unicorn)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/a9dc50256ca6d30c48d4d10d9594388460d621f1e491ba5b2523bf137e410ae2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f78794e4e4e2f756e69636f726e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/xyNNN/unicorn/?branch=master)[![License](https://camo.githubusercontent.com/72b330c9530b579f9c5e720a42d9b68a8d5a379a698c61a021170055e389c16e/68747470733a2f2f706f7365722e707567782e6f72672f78796e6e6e2f756e69636f726e2f6c6963656e7365)](https://github.com/xyNNN/unicorn/blob/master/LICENSE.md)

[![Unicorn Logo](https://github.com/xynnn/unicorn/raw/master/unicorn.png?raw=true)](https://github.com/xynnn/unicorn/blob/master/unicorn.png?raw=true)

A PHP based framework agnostic library to convert several units

- [Unicorn on Packagist](https://packagist.org/packages/xynnn/unicorn)
- [Unicorn on GitHub](https://github.com/xynnn/unicorn)

Documentation
-------------

[](#documentation)

Conversion example
------------------

[](#conversion-example)

Here is a quick example that shows how to convert `110 centimeters` to `meters`:

```
$converter = new LengthConverter();

try {
    $result = $converter->convert(
        new ConvertibleValue('110', $converter::$centimeter),
        $converter::$meter
    );

    $result->getValue(); // '1.10...' with 999 decimals
    $result->getFloatValue(); // 1.1
    $result->getUnit()->getAbbreviation(); // 'm'
    $result->getUnit()->getName(); // 'meter'
} catch (UnsupportedUnitException $e) {
    // Unit might not be present in the converters units array
} catch (InvalidArgumentException $e) {
    // Something is wrong with the provided ConvertibleValue or Unit
}
```

Requirements
------------

[](#requirements)

- PHP 7.0 or higher
- BCMath extension installed and enabled

Installation
------------

[](#installation)

Open a command console, enter your project directory and execute the following command to download the latest stable version of unicorn:

```
composer require xynnn/unicorn
```

This command requires you to have Composer installed globally, as explained in the [installation chapter](https://getcomposer.org/doc/00-intro.md)of the Composer documentation.

Authors
-------

[](#authors)

**Philipp Bräutigam**

- [github/xyNNN](https://github.com/xyNNN)
- [twitter/xyNNN](http://twitter.com/xyNNN)

**Steffen Brand**

- [github/steffenbrand](https://github.com/steffenbrand)

License
-------

[](#license)

Copyright (c) 2016 Philipp Bräutigam, Steffen Brand and contributors.
This repository is released under the GNU LGPL v3.0 license.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.2% 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 ~79 days

Total

2

Last Release

3391d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/45e22e78145872f5e2c8abca2efba7f17a4209a180217522dbfd785f8b87b32b?d=identicon)[xyNNN](/maintainers/xyNNN)

---

Top Contributors

[![steffenbrand](https://avatars.githubusercontent.com/u/5013806?v=4)](https://github.com/steffenbrand "steffenbrand (165 commits)")[![xyNNN](https://avatars.githubusercontent.com/u/1929750?v=4)](https://github.com/xyNNN "xyNNN (3 commits)")

---

Tags

converterunitsformats

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/xynnn-unicorn/health.svg)

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

###  Alternatives

[mark-gerarts/auto-mapper-plus

An AutoMapper for PHP

5623.2M21](/packages/mark-gerarts-auto-mapper-plus)[iamcal/php-emoji

This is a PHP library for dealing with Emoji, allowing you to convert between various native formats and displaying them using HTML.

1.3k481.1k](/packages/iamcal-php-emoji)[matthiasmullie/path-converter

Relative path converter

10229.6M7](/packages/matthiasmullie-path-converter)[goetas-webservices/xsd2php

Convert XSD (XML Schema) definitions into PHP classes and JMS metadata

2411.6M36](/packages/goetas-webservices-xsd2php)[ncjoes/office-converter

PHP Wrapper for LibreOffice

2431.2M4](/packages/ncjoes-office-converter)[gabrielelana/byte-units

Library to parse, format and convert byte units

1672.2M19](/packages/gabrielelana-byte-units)

PHPackages © 2026

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