ILIAS  release_7 Revision v7.30-3-g800a261c036
RowFactory.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
2
3/* Copyright (c) 2020 Nils Haagen <nils.haagen@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
6
8
9class RowFactory implements T\RowFactory
10{
15
16 public function __construct(array $cell_transformations)
17 {
18 $this->cell_transformations = $cell_transformations;
19 }
20
21 public function map(array $record) : array
22 {
23 $row = [];
24 foreach (array_keys($this->cell_transformations) as $id) {
25 $row[$id] = '';
26 if (array_key_exists($id, $record)) {
27 foreach ($this->cell_transformations[$id] as $trafo) {
28 $row[$id] = $trafo($record[$id]);
29 }
30 }
31 }
32 return $row;
33 }
34}
An exception for terminatinating execution or to throw for unit testing.