PHPackages                             vsmoraes/helpers - 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. vsmoraes/helpers

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

vsmoraes/helpers
================

Little helpers to your daily tasks

010PHP

Since Apr 1Pushed 11y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Common Helpers
--------------

[](#common-helpers)

[![Build Status](https://camo.githubusercontent.com/cd5fb610f35d9de08d5046b708d479da2a95ec7572df7f9e0f8c81d87e0302d6/68747470733a2f2f6170692e7472617669732d63692e6f72672f76736d6f726165732f68656c706572732e737667)](https://travis-ci.org/vsmoraes/helpers)[![Total Downloads](https://camo.githubusercontent.com/51a4f20d535e091080cca1155a32c67c0ce677877072381df6e8c161d48d615f/68747470733a2f2f706f7365722e707567782e6f72672f76736d6f726165732f68656c706572732f646f776e6c6f6164732e737667)](https://packagist.org/packages/vsmoraes/helpers)[![License](https://camo.githubusercontent.com/d6c8bb451936ac72d3963ee41324bc9ed9492576f63b28657f449192b26fb0f4/68747470733a2f2f706f7365722e707567782e6f72672f76736d6f726165732f68656c706572732f6c6963656e73652e737667)](https://packagist.org/packages/vsmoraes/helpers)

> > **Note:** This repository contains a set of functions that may help us, Brazilians, with common tasks, such date conversion and string masks. So, for now on, this documentation will be written in portuguese (pt\_BR)

Esse repositório disponibiliza um conjunto de funções para algumas tarefas simples que passamos em todo novo projeto: conversão de datas, formatação de strings, etc...

Instalação
----------

[](#instalação)

Utilizaremos o [composer](http://getcomposer.org/) para a instalação desse pacote.

Basta adicionar a linha abaixo ao seu arquivo `composer.json`:

```
"vsmoraes/helpers": "dev-master"

```

Ou executar:

```
composer require vsmoraes/helpers

```

Funções disponívels
-------------------

[](#funções-disponívels)

#### str\_mask($string, $mask)

[](#str_maskstring-mask)

Aplica uma máscara à uma string

```
$telefone = str_mask('11999999999', '(##) #####-###'); // Resultado: (11) 99999-9999
```

#### format\_cpf($cpf)

[](#format_cpfcpf)

Retorna a string formatada como CPF

```
$cpf = format_cpf('99999999999'); // Resultado: 999.999.999-99
```

#### format\_cnpj($cnpj)

[](#format_cnpjcnpj)

Retorna a string formatada como CNPJ

```
$cnpj = format_cnpj('99999999999999'); // Resultado: 99.999.999/9999-99
```

#### format\_cep($cep)

[](#format_cepcep)

Retorna a string formatada como CEP

```
$cep = format_cep('99999999'); // Resultado: 99999-999
```

#### format\_telefone($telefone)

[](#format_telefonetelefone)

Retorna a string formatada como telefone

```
$telefone = format_telefone('99999999999'); // Resultado: (99) 99999-9999
```

#### format\_data($date, \[$from\_format = 'Y-m-d'\], \[$to\_format = 'd/m/Y'\])

[](#format_datadate-from_format--y-m-d-to_format--dmy)

Converte o formato da data

```
$date = '2015-04-01';
$date = format_data($date); // Resultado: 01/04/2015
```

Você pode fazer a conversão inversa também (ou usar qualquer outro formato)

```
$date = '01/04/2015';
$date = format_data($date, 'd/m/Y', 'Y-m-d'); // Resultado: 2015-04-01
```

#### filesize\_format($bytes, \[$precision = 2\])

[](#filesize_formatbytes-precision--2)

Converte de bytes pra KB, MB, GB out TB

```
$bytes = 230 * 1024; //
$filesize = filesize_format($bytes); // Resultado: 230KB
```

Testes
------

[](#testes)

```
php vendor/bin/phpunit
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 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/e0d31ff1cc89f7f000ad3dbc397a935f1fff20c64e8ff29926555af4150015a9?d=identicon)[vsmoraes](/maintainers/vsmoraes)

---

Top Contributors

[![vsmoraes](https://avatars.githubusercontent.com/u/617445?v=4)](https://github.com/vsmoraes "vsmoraes (1 commits)")

### Embed Badge

![Health badge](/badges/vsmoraes-helpers/health.svg)

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

###  Alternatives

[openbuildings/monetary

Useful tool for formatting and converting currencies

10207.6k1](/packages/openbuildings-monetary)[saeedvaziry/ip2location

IP to Location database

322.2k](/packages/saeedvaziry-ip2location)

PHPackages © 2026

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