Total Complexity | 7 |
Total Lines | 64 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | trait UtilTrait |
||
11 | { |
||
12 | /** |
||
13 | * @var DriverInterface |
||
14 | */ |
||
15 | public $driver; |
||
16 | |||
17 | /** |
||
18 | * @var TranslatorInterface |
||
19 | */ |
||
20 | protected $trans; |
||
21 | |||
22 | /** |
||
23 | * @var InputInterface |
||
24 | */ |
||
25 | public $input; |
||
26 | |||
27 | /** |
||
28 | * Set the driver |
||
29 | * |
||
30 | * @param DriverInterface $driver |
||
31 | * |
||
32 | * @return void |
||
33 | */ |
||
34 | public function setDriver(DriverInterface $driver) |
||
35 | { |
||
36 | $this->driver = $driver; |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * @inheritDoc |
||
41 | */ |
||
42 | public function input(): InputInterface |
||
43 | { |
||
44 | return $this->input; |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @inheritDoc |
||
49 | */ |
||
50 | public function html($string): string |
||
51 | { |
||
52 | if(!$string) { |
||
53 | return ''; |
||
54 | } |
||
55 | $string = str_replace("\n", '<br>', $string); |
||
56 | return str_replace("\0", '�', htmlspecialchars($string, ENT_QUOTES, 'utf-8')); |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * @inheritDoc |
||
61 | */ |
||
62 | public function number(string $value): string |
||
63 | { |
||
64 | return preg_replace('~[^0-9]+~', '', $value); |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * @inheritDoc |
||
69 | */ |
||
70 | public function isUtf8(string $value): bool |
||
74 | } |
||
75 | } |
||
76 |