ILIAS  release_8 Revision v8.23
ShuffleTransformation.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...