GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

SanitizePrices   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 36
rs 10
c 1
b 0
f 0
wmc 3
lcom 1
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A transform() 0 16 3
1
<?php
2
3
namespace App\Http\Middleware;
4
5
use Illuminate\Foundation\Http\Middleware\TransformsRequest;
6
7
class SanitizePrices extends TransformsRequest
8
{
9
    /**
10
     * The attributes that should be sanitized.
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
     *
24
     * @return mixed
25
     */
26
    protected function transform($key, $value)
27
    {
28
        if (in_array($key, $this->except, true)) {
29
            return $value;
30
        }
31
32
        preg_match('/[1-9]\d*(\,\d+)?/', $value, $matches);
33
34
        if (count($matches) == 1) {
35
            $value = str_replace(',', '.', $value);
36
37
            return $value;
38
        }
39
40
        return $value;
41
    }
42
}
43