Download the PHP package jpuck/peer-value-distributer without Composer
On this page you can find all versions of the php package jpuck/peer-value-distributer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jpuck/peer-value-distributer
More information about jpuck/peer-value-distributer
Files in jpuck/peer-value-distributer
Package peer-value-distributer
Short Description Given an array, return a new array with the same keys and values randomly distributed evenly amongst the peers in the specified batch quantity.
License GPL-3.0+
Informations about the package peer-value-distributer
Peer Value Distributer
Given an array, return a new array with the same keys and values distributed randomly and evenly amongst the peers in the specified batch quantity.
For example, say you have a group of 15 book authors. You want each author to review 3 of their peers' work. This function will randomly assign each author 3 of its peers to read.
- Every book is reviewed exactly 3 times.
- No one will review any book more than once.
- No one will review their own book.
The natural maximum distribution count is n-1
so if you specify a count larger than that,
it will be ignored and the largest possible count will be used instead.
e.g. if you distribute those 15 books with a count of 20, it will be ignored and instead every author will be assigned the maximum of 14 peer books to review.
Registered on packagist for easy installation using composer.
composer require jpuck/peer-value-distributer
Example
Output:
Array ( [Jena] => Array ( [John] => The Book of John [Jeff] => Readings from Jeff [Jane] => A Work by Jane ) [John] => Array ( [Jeff] => Readings from Jeff [Jane] => A Work by Jane [Jose] => Words of Jose ) [Jeff] => Array ( [Jane] => A Work by Jane [Jose] => Words of Jose [Jena] => Writing with Jena ) [Jane] => Array ( [Jose] => Words of Jose [Jena] => Writing with Jena [John] => The Book of John ) [Jose] => Array ( [Jena] => Writing with Jena [John] => The Book of John [Jeff] => Readings from Jeff ) )