Console   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A convertEncoding() 0 10 3
1
<?php
2
3
namespace console\components\helpers;
4
5
/**
6
 * Class Console
7
 * @package console\components\helpers
8
 */
9
class Console extends \yii\helpers\Console
10
{
11
    /**
12
     * Convert string encode to
13
     *
14
     * @param array|string $string
15
     * @param string $code
16
     * @param string $to
17
     * @return array|string
18
     */
19
    public static function convertEncoding($string, $code = 'UTF-8', $to = 'auto')
20
    {
21
        if (is_array($string)) {
22
            $strings = [];
23
            foreach ($string as $key => $value) {
24
                $strings[$key] = mb_convert_encoding($value, $code, $to);
25
            }
26
            return $strings;
27
        }
28
        return mb_convert_encoding($string, $code, $to);
29
    }
30
}
31