2017 © Pedro Peláez
 

library redenvelope

PHP library for red envelopes which are popular among Chinese

image

limen/redenvelope

PHP library for red envelopes which are popular among Chinese

  • Friday, April 7, 2017
  • by limen
  • Repository
  • 0 Watchers
  • 2 Stars
  • 17 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 6 % Grown

The README.md

PHP library for red envelope (红包) what is popular among Chinese.

Build Status Packagist, (*1)

Features

  • Amount is assigned randomly.
  • Minimum value of each assignment is settable.
  • Amount precision is settable.
  • Variance factor is settable which would influence the variance of the assignment sequence.

Installation

Recommend to install via composer., (*2)

composer require "limen/redenvelope"

Usage

use Limen\RedEnvelope\Envelope;

$id = '123';                    // unique id
$remain = 212.23;               // envelope remain amount
$dividend = 10;                 // how many fragments to divide amount into
$minAssignment = 10.1;          // minimum value of each assignment
$precision = 2;                 // assignment precision

$varianceFactor = 1.0;          // Appropriate value should between 0.5 and 1.5, 1.0 may be the best.
                                // The greater this value, the greater the variance of the divided sequence is.

$envelope = new Envelope($id);

$envelope->setRemain($remain)
    ->setDividend($dividend);
    ->setPrecision($precision)
    ->setMinAssignment($minAssignment)
    ->setVarianceFactor($varianceFactor);

$assignment = $envelope->open();

Development

Test

$ phpunit --bootstrap tests/bootstrap.php tests/
PHPUnit 5.7.15 by Sebastian Bergmann and contributors.

..
Total amount: 214.4
Dividend: 20
Minimum Assignment: 0.86
Variance factor: 0.7
Precision: 2
Assignment value: 10.72
..
Total amount: 64
Dividend: 4
Minimum Assignment: 7
Variance factor: 1.5
Precision: 0
Assignments: 
No.0: 19.000000
No.1: 15.000000
No.2: 7.000000
No.3: 23.000000
.                                                               5 / 5 (100%)

Time: 165 ms, Memory: 13.25MB

OK (5 tests, 36 assertions)

The Versions

07/04 2017

dev-master

9999999-dev https://github.com/limen/redenvelope

PHP library for red envelopes which are popular among Chinese

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

envelope red 红包

05/04 2017

v0.1.5

0.1.5.0 https://github.com/limen/redenvelope

PHP library for red envelopes which are popular among Chinese

  Sources   Download

MIT

The Requires

 

The Development Requires

envelope red 红包

10/03 2017

v0.1.4

0.1.4.0 https://github.com/limen/redenvelope

PHP library for red envelopes which are popular among Chinese

  Sources   Download

MIT

The Requires

 

The Development Requires

envelope red 红包

08/03 2017

v0.1.3

0.1.3.0 https://github.com/limen/redenvelope

PHP library for red envelopes which are popular among Chinese

  Sources   Download

MIT

The Requires

 

The Development Requires

envelope red 红包

06/03 2017

0.1.2

0.1.2.0 https://github.com/limen/redenvelope

PHP library for red envelopes which are popular among Chinese

  Sources   Download

MIT

The Requires

 

The Development Requires

envelope red 红包

03/03 2017

0.1.1

0.1.1.0 https://github.com/limen/redenvelope

PHP library for red envelopes which are popular among Chinese

  Sources   Download

MIT

The Requires

 

The Development Requires

envelope red 红包

03/03 2017

0.1.0

0.1.0.0 https://github.com/limen/redenvelope

PHP library for red envelopes which are popular among Chinese

  Sources   Download

MIT

The Requires

 

The Development Requires

envelope red 红包