PHPackages                             sam0hack/dconverter - 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. sam0hack/dconverter

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

sam0hack/dconverter
===================

helper tool for converting and formatting Outputs into human readable format

8122.1k6[1 issues](https://github.com/sam0hack/laravel-DConverter/issues)PHP

Since Jul 10Pushed 6y ago2 watchersCompare

[ Source](https://github.com/sam0hack/laravel-DConverter)[ Packagist](https://packagist.org/packages/sam0hack/dconverter)[ RSS](/packages/sam0hack-dconverter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![Total Downloads](https://camo.githubusercontent.com/ab09dcb46ffdf181575070c047ff8f5b06b55be405f06469bc47130f9589e816/68747470733a2f2f706f7365722e707567782e6f72672f73616d306861636b2f64636f6e7665727465722f646f776e6c6f616473)](https://packagist.org/packages/sam0hack/dconverter)[![Monthly Downloads](https://camo.githubusercontent.com/2bad702d97db59b4ba1715e73e42932fcdfafd6f34ce6fef96a83ed3fa372fee/68747470733a2f2f706f7365722e707567782e6f72672f73616d306861636b2f64636f6e7665727465722f642f6d6f6e74686c79)](https://packagist.org/packages/sam0hack/dconverter)[![Daily Downloads](https://camo.githubusercontent.com/d65e2be504f1fe19ced59867ddc8c9b7377fd407958a00d0dedb253c275872db/68747470733a2f2f706f7365722e707567782e6f72672f73616d306861636b2f64636f6e7665727465722f642f6461696c79)](https://packagist.org/packages/sam0hack/dconverter)[![License](https://camo.githubusercontent.com/7c3bc708106b44abeb2bae13ca05e7c38c19973a0e4211516b436f71db127a73/68747470733a2f2f706f7365722e707567782e6f72672f73616d306861636b2f64636f6e7665727465722f6c6963656e7365)](https://packagist.org/packages/sam0hack/dconverter)

laravel-DConverter
==================

[](#laravel-dconverter)

A helper tool for converting and formatting Outputs into human readable format.

Integration in Laravel
======================

[](#integration-in-laravel)

Install using Composer
----------------------

[](#install-using-composer)

Run `composer require sam0hack/dconverter  dev-master`

After you have installed dconverter , open your Laravel config file config/app.php and add the following lines in the $aliases array.

`'DConverter' => sam0hack\dconverter\DC::class,`

Tools
=====

[](#tools)

**SizeFormat --- SizeFormat convert's the laravel getSize() Or bytes data into kb, mb and gb****Hours --- Calculate Hours betweens Two dates****Percentage --- Calculate Percentage****MakeColors --- Simply generate hex color****DistanceMatrix --- Calculate Time and distance between two locations using google distance API**

### Example of SizeFormat()

[](#example-of-sizeformat)

`DC::SizeFormat($attachment->file_size)`

##### In blade tamplate

[](#in-blade-tamplate)

`{{\sam0hack\dconverter\DC::SizeFormat($attachment->file_size)}}`

##### Output examples

[](#output-examples)

- 99.24 kB
- 100 Mb
- 1 GB

### Example of Hours()

[](#example-of-hours)

`DC::Hours($date,$date2)`

##### In blade tamplate

[](#in-blade-tamplate-1)

`{{\sam0hack\dconverter\DC::Hours($date,$date2)}}`

\#####Output examples

- 240
- 1
- 60

### Example of Percentage()

[](#example-of-percentage)

```
DC::Percentage($current,$total)

```

calculate percentage using hours

```
$totalhours = DC::Hours($start_date,$end_date);

$currentHours = DC::Hours($start_date,$now_date);

$percentage = DC::Percentage($currentHours,$totalhours);

```

##### Output examples

[](#output-examples-1)

- 25
- 33.0
- -150

### Example of MakeColors()

[](#example-of-makecolors)

`DC::MakeColors()`

##### In blade tamplate

[](#in-blade-tamplate-2)

`{{\sam0hack\dconverter\DC::MakeColors()}}`

##### Output examples

[](#output-examples-2)

- "#0951e7"
- "#071377"
- "#cdda5d"

### Example of DistanceMatrix()

[](#example-of-distancematrix)

For Setup DistanceMatrix you need to add google API into config/services.php

'google'=&gt;\[ 'GOOGLE\_API\_KEY' =&gt; env('GOOGLE\_MAP\_API\_KEY') \], OR without using env google'=&gt;\[ 'GOOGLE\_API\_KEY' =&gt; 'paste you google map api key here' \],

> @Note Config key should be ***GOOGLE\_API\_KEY***

```
DC::DistanceMatrix('New York Ave, El Paso, TX 79902, USA','86 W Houston St, New York, NY 10012, USA')
$distance = $dist['distance'];
$time	    = $dist['time'];

```

##### Output examples

[](#output-examples-3)

- "2,184 mi"
- "1 day 8 hours"

***DistanceMatrix Modes - Optionals***For the calculation of distances, you may specify the transportation mode to use. By default, distances are

calculated for driving mode. The following travel modes are supported: **driving** (default) indicates distance calculation using the road network. **walking** requests distance calculation for walking via pedestrian paths &amp; sidewalks (where available). **bicycling** requests distance calculation for bicycling via bicycle paths &amp; preferred streets (where available).

```
DC::DistanceMatrix($origin, $destination,'walking');

```

packagist
=========

[](#packagist)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/df4fd648ee26ac70b9aa91e7777ab60668f7b33d635b6738b0b661b29d246dd8?d=identicon)[sam0hack](/maintainers/sam0hack)

---

Top Contributors

[![sam0hack](https://avatars.githubusercontent.com/u/5379650?v=4)](https://github.com/sam0hack "sam0hack (164 commits)")

---

Tags

distancedistance-calculationdistancematrixhelpershourlaravellaravel-dconverterpercentagephprequests-distance-calculation

### Embed Badge

![Health badge](/badges/sam0hack-dconverter/health.svg)

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

###  Alternatives

[delight-im/base64

Simple and convenient Base64 encoding and decoding for PHP

15158.1k6](/packages/delight-im-base64)

PHPackages © 2026

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