Total Complexity | 4 |
Total Lines | 44 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
15 | trait FileHandlerTrait |
||
16 | { |
||
17 | /** |
||
18 | * @var string UTF8 | UTF16_BE | UTF16_LE | UTF32_BE | UTF32_LE |
||
19 | */ |
||
20 | protected $bomRegEx = '\xEF\xBB\xBF|\xFE\xFF|\xFF\xFE|\x00\x00\xFE\xFF|\xFF\xFE\x00\x00'; |
||
21 | |||
22 | /** |
||
23 | * @var resource|false|null |
||
24 | */ |
||
25 | protected $handle; |
||
26 | |||
27 | /** |
||
28 | * make sure we do not hold un-necessary handles |
||
29 | */ |
||
30 | public function __destruct() |
||
31 | { |
||
32 | $this->releaseHandle(); |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * @param $string |
||
37 | * |
||
38 | * @return string |
||
39 | */ |
||
40 | public function trimBom($string) |
||
41 | { |
||
42 | return preg_replace('`^' . $this->bomRegEx . '`', '', $string); |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * release handle |
||
47 | * |
||
48 | * @return $this |
||
49 | */ |
||
50 | public function releaseHandle() |
||
59 | } |
||
60 | } |
||
61 |