Length

Introduction

The length service is a simple class that converts a length of unit to another unit.

Supported Units

  • Meter (m)
  • Kilometer (km)
  • Decimeter (dm)
  • Centimeters (cm)
  • Millimeters (mm)
  • Degrees (deg)
  • Inches (in)
  • Feet (ft)
  • Yard (yd)
  • Miles (mi)

Basic Usage

You can use the length utility by using the \Anomaly\Streams\Platform\Support\Length class.

use \Anomaly\Streams\Platform\Support\Length;

$length = new Length(100, 'ft');

You can also include the unit in the length as a string.

use \Anomaly\Streams\Platform\Support\Length;

$length = new Length('10 ft');

Converting Length

Use the method that matches the above length you with to convert to.

use \Anomaly\Streams\Platform\Support\Length;

$length = new Length('10', 'ft');

echo $length->inches();
// 120

to

The to method converts the length to a provided unit.

use \Anomaly\Streams\Platform\Support\Length;

$length = new Length('10', 'ft');

echo $length->to('in');
// 120