Passed
Push — master ( a7cb98...edba21 )
by Fabrice
03:13
created

CharsetTransformerTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 6
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 6
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConvertClosure() 0 4 2
1
<?php
2
3
/*
4
 * This file is part of YaEtl
5
 *     (c) Fabrice de Stefanis / https://github.com/fab2s/YaEtl
6
 * This source file is licensed under the MIT license which you will
7
 * find in the LICENSE file or at https://opensource.org/licenses/MIT
8
 */
9
10
namespace fab2s\YaEtl\Transformers\Arrays;
11
12
use fab2s\Strings\Strings;
13
14
trait CharsetTransformerTrait
15
{
16
    public function getConvertClosure(?string $from = null, string $to = Strings::ENCODING): \Closure
17
    {
18
        return function ($value) use ($from, $to) {
19
            return is_string($value) ? Strings::convert($value, $from, $to) : $value;
20
        };
21
    }
22
}
23