ArabicNumbers   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A transform() 0 9 3
1
<?php
2
3
namespace Maklad\ArabicNumbers\Http\Middleware;
4
5
use Illuminate\Foundation\Http\Middleware\TransformsRequest;
6
7
class ArabicNumbers extends TransformsRequest
8
{
9
    /**
10
     * The attributes that should not be trimmed.
11
     *
12
     * @var array
13
     */
14
    protected $except = [
15
        //
16
    ];
17
18
    /**
19
     * Transform the given value.
20
     *
21
     * @param  string $key
22
     * @param  mixed $value
23
     * @return mixed
24
     */
25 4
    protected function transform($key, $value)
26
    {
27 4
        if ((! is_string($value)) || in_array($key, $this->except, true)) {
28 2
            return $value;
29
        }
30
31 4
        $eastern = ['٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩'];
32 4
        $western = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
33 4
        return str_replace($eastern, $western, $value);
34 4
    }
35
}
36