Projekt

Obecné

Profil

Stáhnout (1.07 KB) Statistiky
| Větev: | Revize:
1 03c02899 vastja
<?php
2
3
namespace App\Utils;
4
5 70a3df53 vastja
/**
6
 * Class for static helper functions.
7
 */
8 03c02899 vastja
class Utils {
9 70a3df53 vastja
    /**
10
     * Transforms array of arrays in form [['display-name' => whatever, 'key-name' => whatever, ...], ...]
11
     * to simple array in form [dataset-display-name => dataset-key-name, ...].
12
     *
13
     * @param array of arrays for tranformation
14
     *
15
     * @return array in form [dataset-display-name => dataset-key-name, ...]
16
     */
17 03c02899 vastja
    public static function prepareDatasetsNames($datasets) {
18 3ae59f75 vastja
        $names = [];
19 03c02899 vastja
20
        foreach ($datasets as $key => $value) {
21 61ff7718 vastja
            if (false == array_key_exists($value['key-name'], $names)) {
22
                $names[$value['display-name']] = $value['key-name'];
23 4cc90563 vastja
            }
24 03c02899 vastja
        }
25
26
        return $names;
27
    }
28 2f227a6c ballakt
29
    public static function prepareDatasetsColors($datasets) {
30
        $colors = [];
31
        foreach ($datasets as $key => $value) {
32
            if (false == array_key_exists($value['key-name'], $colors)) {
33
                $colors[$value['key-name']] = $value['display-color'];
34
            }
35
        }
36
37
        return $colors;
38
    }
39 03c02899 vastja
}