PHPackages                             coercive/app - 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. coercive/app

ActiveLibrary

coercive/app
============

Coercive App

0.0.47(7mo ago)11.1k1MITPHPPHP &gt;=7.4

Since Nov 12Pushed 7mo ago2 watchersCompare

[ Source](https://github.com/Coercive/App)[ Packagist](https://packagist.org/packages/coercive/app)[ Docs](http://coercive.fr)[ RSS](/packages/coercive-app/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (2)Versions (48)Used By (1)

Coercive App
============

[](#coercive-app)

!!! IN WORKS !!!

Get
---

[](#get)

```
composer require coercive/app

```

Usage
-----

[](#usage)

```
# in works ...
```

---

Currency
========

[](#currency)

Load class with basic config

```
$config = (new Config)
    ->setLanguage('fr_FR')
    ->setCurrency('EUR')
    ->setPriceDigits(2);

$currency = new Currency($config);
```

Detect decimal

```
$currency->hasDecimal(3.50)
# > true

$currency->hasDecimal(3.00)
# > false
```

Format

```
echo $currency->format(13.756)
# > 13,76 €

echo $currency->format(13.000, false)
# > 13,00

echo $currency->format(13.000, true, true)
# > 13 €

$currency->setTruncate(true);
echo $currency->format(13.000, false)
# > 13
```

---

Jason
=====

[](#jason)

JSON encode with float handler

```
$data = [528.56 * 100];

echo json_encode($data);
# > [52855.99999999999]

echo new Jason($data, JSON_NUMERIC_CHECK);
# > [52856]
```

Decimal option

```
$data = ['52855.99999999999', 52855.99, 52855.99999999999, 528.56 * 100];
$jason = new Jason($data, JSON_NUMERIC_CHECK);
$jason->setDecimals(2);

echo $jason;
# > [52855.99999999999,52855.99,52856,52856]
```

Truncate option

```
$data = ['52855.99999999999', 52855.99, 52855.99999999999, 528.56 * 100];
$jason = new Jason($data, JSON_NUMERIC_CHECK);
$jason->setTruncate(true);

echo $jason;
# > [52855.99999999999,52855.99,52855.99,52855.99]
```

---

Locale
======

[](#locale)

Load class with minimal config

```
$config = (new Config)
    ->setLanguage('fr_FR')
    ->setLanguages(['fr_FR', 'en_GB']);

$locale = new Locale($config);
```

StrfTime backward compatibility

```
$config->setLanguage('fr_FR');
echo $locale->strftime('2025-09-16 09:32:17');
# > mardi 16 septembre 2025 09:32:17

$config->setLanguage('en_GB');
echo $locale->strftime('2025-09-16 09:32:17');
# > Tuesday 16 September 2025 09:32:17

$locale->setLocale('fr_FR');
echo $locale->strftime('2025-09-16 09:32:17', '%c');
# > mardi 16 septembre 2025 à 09:32:17 temps universel coordonné

$locale->setLocale();
echo $locale->strftime('2025-09-16 09:32:17', '%x');
# > Tuesday, 16 September 2025

$locale->setLocale();
echo $locale->strftime('2025-09-16 09:32:17', '%X');
# > '09:32:17 Coordinated Universal Time
```

Use new system IntlDateFormatter with ICU format

```
$locale->setLocale();
echo $locale->format($example, 'EEEE');
# > Tuesday

$locale->setLocale('fr_FR');
echo $locale->format($example, 'EEE e dd ww');
# > mar. 2 16 38
```

Export array of day names

```
$locale->setLocale('fr_FR');
$days = $locale->getDayNames(1);
foreach ($days as $day) {
    echo $day['full'] . "\n\n";
}
```

Export array of month names

```
$locale->setLocale('fr_FR');
$months = $locale->getMonthNames();
foreach ($months as $month) {
    echo $month['full'] . "\n\n";
}
```

---

ReCaptcha handler
=================

[](#recaptcha-handler)

Load class and set your keys

```
$recaptcha = new ReCaptcha;

$recaptcha
   ->setPublicKey("RECAPTCHA_PUBLIC_KEY")
   ->setPrivateKey("RECAPTCHA_SECRET_KEY")
```

Check if your token is valid

```
if (!$recaptcha->validateAndPersist($_POST['inputTokenToCheck'])) {
    die('invalid');
}
```

Optional: by default is V2 ; set threshold if you wan't to use reCaptcha V3

```
$recaptcha->threshold(0.5)
```

Optional: use storage data to optimize your quota

```
$recaptcha->setStoreCallback(function($result) {
	/* your storage logic here */
})

$recaptcha->setRetrieveCallback(function() {
	/* your retrieve logic here */
})

/* use `validateAndPersist()` to trigger your callbacks */
$recaptcha->validateAndPersist($_POST['inputTokenToCheck'])
```

Full example with session storage logic

```
$recaptcha
   ->setPublicKey("RECAPTCHA_PUBLIC_KEY")
   ->setPrivateKey("RECAPTCHA_SECRET_KEY")
   ->threshold(0.5)
   ->setStoreCallback(function($result) {
         $_SESSION['recaptcha']['result'] = $result;
         $_SESSION['recaptcha']['timestamp'] = time();
   })
   ->setRetrieveCallback(function () {
         if(!isset($_SESSION['recaptcha'])) {
            return null;
         }
         if(($_SESSION['recaptcha']['timestamp'] ?? 0) + (24 * 60 * 60) < time()) {
            return null; # example 1 day in second before recheck
         }
         return $_SESSION['recaptcha']['result'] ?? false;
   });
```

---

SqlTableName handler
====================

[](#sqltablename-handler)

Load class and set your environment name, and the prefix/sufix options.

```
$table = new SqlTableName('prod', ['test' => 'TEST_'], ['prod' => '_PROD']);
```

Get your table name with backticks

```
echo $table->database('HELLO')->table('WORLD');
# => `HELLO_PROD`.`WORLD`
```

Change your environment

```
$table->env('test');

echo $table->database('HELLO')->table('WORLD');
# => `TEST_HELLO`.`WORLD`
```

Add an alias

```
$table->alias('happy');

echo $table->database('HELLO')->table('WORLD');
# => `TEST_HELLO`.`WORLD` as happy
```

You can deactivate backticks in constructor, or in separated method

```
$table->backtick(false);

echo $table->database('HELLO')->table('WORLD');
# => TEST_HELLO.WORLD
```

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance63

Regular maintenance activity

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity66

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~62 days

Total

47

Last Release

227d ago

PHP version history (2 changes)0.0.0PHP &gt;=7.0

0.0.30PHP &gt;=7.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/20288080?v=4)[Coercive](/maintainers/Coercive)[@Coercive](https://github.com/Coercive)

---

Top Contributors

[![Coercive](https://avatars.githubusercontent.com/u/20288080?v=4)](https://github.com/Coercive "Coercive (62 commits)")

---

Tags

appphp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/coercive-app/health.svg)

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

PHPackages © 2026

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