ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ShuffleTransformation.php
Go to the documentation of this file.
1<?php
2
19declare(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.