1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
<?php
namespace FluentMail\Includes\Request;
trait Cleaner { /** * Clean up the request data. * * @param array $data * @return array */ public function clean($data) { return $this->cleanArray($data); }
/** * Clean the data in the given array. * * @param array $data * @return array */ protected function cleanArray(array $data) { return array_map(function ($value) { return $this->cleanValue($value); }, $data); }
/** * Clean the given value. * * @param mixed $value * @return mixed */ protected function cleanValue($value) { if (is_array($value)) { return $this->cleanArray($value); }
return $this->transform($value); }
/** * Transform the given value. * * @param mixed $value * @return mixed */ protected function transform($value) { if (is_string($value)) { $value = trim($value);
if ($value === '') { $value = null; } }
return $value; } }
|