PHPackages                             robier/probability-checker - 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. robier/probability-checker

ActiveLibrary

robier/probability-checker
==========================

Probability Checker is a simple library that helps you to check the probability of an event.

v1.0.2(1y ago)06MITPHPPHP &gt;=8.0

Since May 16Pushed 1y ago1 watchersCompare

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

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

[![codecov](https://camo.githubusercontent.com/440d7f427a9a6be60d32b18f860c63b6d4a38690c682a717d7e01fa7d68a9ed6/68747470733a2f2f636f6465636f762e696f2f6769746875622f726f626965722f70726f626162696c6974792d636865636b65722f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d46424e304e3057435050)](https://codecov.io/github/robier/probability-checker)

---

ProbabilityChecker
==================

[](#probabilitychecker)

Pretty simple probability implementation that can be used for A/B testing. If you have some feature that you want to run on 20% of the requests. This is right tool for you as you do not need to define how many requests there will be in total.

If you provide 0 as a parameter, it will always return false, if you provide 100, it will always return true. Everything in between will be around the number you provided.

**Note:** This method is not exact but approximation, so if you want 20%, you will get 21%, 23% maybe 18%, but at the end it will be around 20% (the greater number of request, more accurate will be the percentage).

### Installation

[](#installation)

This library can be installed via composer:

```
composer require robier/probability-checker
```

### Sample usage

[](#sample-usage)

```
