Skip to content

Commit

Permalink
docs: Update documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Dec 6, 2020
1 parent d06aebc commit e518492
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion docs/pages/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1287,11 +1287,13 @@ random
~~~~~~

It returns a random item from the collection.

An optional integer can be passed to random to specify how many items you would like to randomly retrieve.
An optional seed can be passed as well.

Interface: `Randomable`_

Signature: ``Collection::random(int $size = 1);``
Signature: ``Collection::random(int $size = 1, ?int $seed = null);``

.. code-block:: php
Expand Down Expand Up @@ -1464,6 +1466,23 @@ Signature: ``Collection::scanRight1(callable $callback);``
Collection::fromIterable([12])
->scanRight1($callback); // [12]
shuffle
~~~~~~~

Shuffle a collection.

Interface: `Shuffleable`_

Signature: ``Collection::shuffle(?int $seed = null);``

.. code-block:: php
$collection = Collection::fromIterable(['4', '5', '6'])
->random(); // ['6', '4', '5']
$collection = Collection::fromIterable(['4', '5', '6'])
->random(); // ['5', '6', '5']
since
~~~~~

Expand Down Expand Up @@ -2049,6 +2068,7 @@ Signature: ``Collection::zip(iterable ...$iterables);``
.. _ScanLeft1able: https://github.com/loophp/collection/blob/master/src/Contract/Operation/ScanLeft1able.php
.. _ScanRightable: https://github.com/loophp/collection/blob/master/src/Contract/Operation/ScanRightable.php
.. _ScanRight1able: https://github.com/loophp/collection/blob/master/src/Contract/Operation/ScanRight1able.php
.. _Shuffleable: https://github.com/loophp/collection/blob/master/src/Contract/Operation/Shuffleable.php
.. _Sinceable: https://github.com/loophp/collection/blob/master/src/Contract/Operation/Sinceable.php
.. _Sliceable: https://github.com/loophp/collection/blob/master/src/Contract/Operation/Sliceable.php
.. _Sortable: https://github.com/loophp/collection/blob/master/src/Contract/Operation/Sortable.php
Expand Down

0 comments on commit e518492

Please sign in to comment.