PHPackages                             traderinteractive/filter-bools - 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. traderinteractive/filter-bools

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

traderinteractive/filter-bools
==============================

A collection of boolean filters.

v4.0.0(3y ago)1102.4k↓51.6%12MITPHPPHP ^7.3 || ^8.0CI failing

Since Mar 6Pushed 3y ago7 watchersCompare

[ Source](https://github.com/traderinteractive/filter-bools-php)[ Packagist](https://packagist.org/packages/traderinteractive/filter-bools)[ RSS](/packages/traderinteractive-filter-bools/feed)WikiDiscussions master Synced yesterday

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

filter-bools-php
================

[](#filter-bools-php)

[![Build Status](https://camo.githubusercontent.com/e00b5f86cc36f531f34d0fa388919145e16d44d95a5dd43d31b17d0794f7b8d7/68747470733a2f2f7472617669732d63692e6f72672f747261646572696e7465726163746976652f66696c7465722d626f6f6c732d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/traderinteractive/filter-bools-php)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/06b170b47d70352aa50bfdb0e26ee2df6997eb8833c6bedc9328b6dda2928841/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f747261646572696e7465726163746976652f66696c7465722d626f6f6c732d7068702f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/traderinteractive/filter-bools-php/?branch=master)[![Coverage Status](https://camo.githubusercontent.com/a2a017f06dea3359ae95a1d5ec034c88bd75aec88eb637787791697a7d360b56/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f747261646572696e7465726163746976652f66696c7465722d626f6f6c732d7068702f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/traderinteractive/filter-bools-php?branch=master)

[![Latest Stable Version](https://camo.githubusercontent.com/4d7e1bd6ddf1f345f48a99b3378126c61a0aefeaff35407c690cf6088e48a309/68747470733a2f2f706f7365722e707567782e6f72672f747261646572696e7465726163746976652f66696c7465722d626f6f6c732f762f737461626c65)](https://packagist.org/packages/traderinteractive/filter-bools)[![Latest Unstable Version](https://camo.githubusercontent.com/2eb8daf36c34a7ce9ed9753f6582210378f82e37cb604a2cbfc52c63369c05db/68747470733a2f2f706f7365722e707567782e6f72672f747261646572696e7465726163746976652f66696c7465722d626f6f6c732f762f756e737461626c65)](https://packagist.org/packages/traderinteractive/filter-bools)[![License](https://camo.githubusercontent.com/49e845be5fa3dcb4a4f9eea19e8c866fad98882ec0e90d800cb0164e9c74756b/68747470733a2f2f706f7365722e707567782e6f72672f747261646572696e7465726163746976652f66696c7465722d626f6f6c732f6c6963656e7365)](https://packagist.org/packages/traderinteractive/filter-bools)

[![Total Downloads](https://camo.githubusercontent.com/5107e958b99d4a32e4cb3b7d93aa9711d17352bee5ec5f8150eb7af55642f804/68747470733a2f2f706f7365722e707567782e6f72672f747261646572696e7465726163746976652f66696c7465722d626f6f6c732f646f776e6c6f616473)](https://packagist.org/packages/traderinteractive/filter-bools)[![Daily Downloads](https://camo.githubusercontent.com/ba59af16f3c31dd08c2046a11199a06fea382498ff341136731cadea6c6651d7/68747470733a2f2f706f7365722e707567782e6f72672f747261646572696e7465726163746976652f66696c7465722d626f6f6c732f642f6461696c79)](https://packagist.org/packages/traderinteractive/filter-bools)[![Monthly Downloads](https://camo.githubusercontent.com/7e6bded647fd32e920b3749379d6a0517710371f47e05ea6ea2873545e1a13e1/68747470733a2f2f706f7365722e707567782e6f72672f747261646572696e7465726163746976652f66696c7465722d626f6f6c732f642f6d6f6e74686c79)](https://packagist.org/packages/traderinteractive/filter-bools)

A filtering implementation for verifying correct data and performing typical modifications to data.

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

[](#requirements)

Requires PHP 7.0 or newer and uses composer to install further PHP dependencies. See the [composer specification](composer.json) for more details.

Composer
--------

[](#composer)

To add the library as a local, per-project dependency use [Composer](http://getcomposer.org)! Simply add a dependency on `traderinteractive/filter-bools` to your project's `composer.json` file such as:

```
composer require traderinteractive/filter-bools
```

### Functionality

[](#functionality)

#### Booleans::filter

[](#booleansfilter)

This filter verifies that the argument is a boolean value or a string that maps to one. The second parameter can be set to `true` to allow null values through without an error (they will stay null and not get converted to false). The last parameters are lists of strings for true values and false values. By default, the strings "true" and "false" map to their boolean counterparts.

The following example converts `$value` to a boolean allowing the strings "on" and "of".

```
$enabled = \TraderInteractive\Filter\Booleans::filter($value, false, ['on'], ['off']);
```

#### Booleans::convert

[](#booleansconvert)

This filter will convert a given boolean value into the provided true or false conditions. By default the return values are the strings 'true' and 'false'

The following converts the boolean `$value` to either 'yes' or 'no'

```
$answer = \TraderInteractive\Filter\Booleans::convert($value, 'yes', 'no');
```

Contact
-------

[](#contact)

Developers may be contacted at:

- [Pull Requests](https://github.com/traderinteractive/filter-bools-php/pulls)
- [Issues](https://github.com/traderinteractive/filter-bools-php/issues)

Project Build
-------------

[](#project-build)

With a checkout of the code get [Composer](http://getcomposer.org) in your PATH and run:

```
composer install
./vendor/bin/phpcs
./vendor/bin/phpunit
```

For more information on our build process, read through out our [Contribution Guidelines](CONTRIBUTING.md).

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% 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 ~1665 days

Total

2

Last Release

1375d ago

Major Versions

v3.0.0 → v4.0.02022-09-27

PHP version history (2 changes)v3.0.0PHP ^7.0

v4.0.0PHP ^7.3 || ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/29952359?v=4)[Trader Interactive](/maintainers/traderinteractive)[@traderinteractive](https://github.com/traderinteractive)

---

Top Contributors

[![chrisryan](https://avatars.githubusercontent.com/u/704326?v=4)](https://github.com/chrisryan "chrisryan (4 commits)")[![chadicus](https://avatars.githubusercontent.com/u/1182337?v=4)](https://github.com/chadicus "chadicus (2 commits)")

---

Tags

booleanbool

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/traderinteractive-filter-bools/health.svg)

```
[![Health](https://phpackages.com/badges/traderinteractive-filter-bools/health.svg)](https://phpackages.com/packages/traderinteractive-filter-bools)
```

###  Alternatives

[tenancy/tenancy

Creating multi tenant saas from your Laravel app with ease

1.3k46.2k](/packages/tenancy-tenancy)[sebastiaanluca/laravel-boolean-dates

Automatically convert Eloquent model boolean attributes to dates (and back).

40116.9k1](/packages/sebastiaanluca-laravel-boolean-dates)

PHPackages © 2026

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