1 | <?php |
||
28 | class RFC4180Field extends php_user_filter |
||
29 | { |
||
30 | use ValidatorTrait; |
||
31 | |||
32 | const STREAM_FILTERNAME = 'rfc4180.league.csv'; |
||
33 | |||
34 | /** |
||
35 | * The value being search for |
||
36 | * |
||
37 | * @var string |
||
38 | */ |
||
39 | protected $search; |
||
40 | |||
41 | /** |
||
42 | * The replacement value that replace found $search values |
||
43 | * |
||
44 | * @var string |
||
45 | */ |
||
46 | protected $replace; |
||
47 | |||
48 | /** |
||
49 | * Static method to add the stream filter to a Writer object |
||
50 | * |
||
51 | * @param AbstractCsv $csv |
||
52 | */ |
||
53 | 2 | public static function addTo(AbstractCsv $csv) |
|
54 | { |
||
55 | 2 | if (!in_array(self::STREAM_FILTERNAME, stream_get_filters())) { |
|
56 | 2 | stream_filter_register(self::STREAM_FILTERNAME, __CLASS__); |
|
57 | } |
||
58 | |||
59 | 2 | $csv->addStreamFilter(self::STREAM_FILTERNAME, [ |
|
60 | 2 | 'enclosure' => $csv->getEnclosure(), |
|
61 | 2 | 'escape' => $csv->getEscape(), |
|
62 | ]); |
||
63 | 2 | } |
|
64 | |||
65 | /** |
||
66 | * @inheritdoc |
||
67 | */ |
||
68 | 6 | public function onCreate() |
|
86 | |||
87 | /** |
||
88 | * @inheritdoc |
||
89 | */ |
||
90 | 2 | public function filter($in, $out, &$consumed, $closing) |
|
100 | } |
||
101 |