ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ShuffleTransformation.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
28 
37 {
40 
41  private Seed $seed;
42 
43  public function __construct(Seed $seed)
44  {
45  $this->seed = $seed;
46  }
47 
48  public function transform($from): array
49  {
50  if (!is_array($from)) {
51  throw new ConstraintViolationException('not an array', 'no_array');
52  }
53  $this->seed->seedRandomGenerator();
54  shuffle($from);
55 
56  return $from;
57  }
58 }
A transformation is a function from one datatype to another.