TypeUtils   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 32
ccs 7
cts 7
cp 1
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A castTypesByMap() 0 10 3
1
<?php
2
namespace Aoe\Imgix\Utils;
3
4
/***************************************************************
5
 *  Copyright notice
6
 *
7
 *  (c) 2018 AOE GmbH <[email protected]>
8
 *
9
 *  All rights reserved
10
 *
11
 *  This script is part of the TYPO3 project. The TYPO3 project is
12
 *  free software; you can redistribute it and/or modify
13
 *  it under the terms of the GNU General Public License as published by
14
 *  the Free Software Foundation; either version 3 of the License, or
15
 *  (at your option) any later version.
16
 *
17
 *  The GNU General Public License can be found at
18
 *  http://www.gnu.org/copyleft/gpl.html.
19
 *
20
 *  This script is distributed in the hope that it will be useful,
21
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 *  GNU General Public License for more details.
24
 *
25
 *  This copyright notice MUST APPEAR in all copies of the script!
26
 ***************************************************************/
27
28
class TypeUtils
29
{
30
    /**
31
     * @var string
32
     */
33
    const TYPE_STRING = 'string';
34
35
    /**
36
     * @var string
37
     */
38
    const TYPE_INTEGER = 'integer';
39
40
    /**
41
     * @var string
42
     */
43
    const TYPE_BOOLEAN = 'boolean';
44
45
    /**
46
     * @param array $map
47
     * @param array $target
48
     * @return array
49
     */
50 5
    public static function castTypesByMap(array $map, array $target)
51
    {
52 5
        $casted = array();
53 5
        foreach ($target as $key => $value) {
54 5
            if (isset($map[$key])) {
55 4
                settype($value, $map[$key]);
56
            }
57 5
            $casted[$key] = $value;
58
        }
59 5
        return $casted;
60
    }
61
}
62