Skip to content

Commit 29b04b2

Browse files
committed
Refactor decode method and replace   to space.
1 parent 9dab9c1 commit 29b04b2

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/Transformers/DataTransformer.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ protected function buildColumnByCollection(array $row, Collection $columns, $ty
4444
$title = $column['title'];
4545
$data = array_get($row, $column['data']);
4646
if ($type == 'exportable') {
47-
$data = html_entity_decode(strip_tags($data), ENT_QUOTES, 'UTF-8');
48-
$title = html_entity_decode(strip_tags($title), ENT_QUOTES, 'UTF-8');
47+
$data = $this->decodeContent($data);
48+
$title = $this->decodeContent($title);
4949
}
5050

5151
$results[$title] = $data;
@@ -54,4 +54,17 @@ protected function buildColumnByCollection(array $row, Collection $columns, $ty
5454

5555
return $results;
5656
}
57+
58+
/**
59+
* Decode content to a readable text value.
60+
*
61+
* @param string $data
62+
* @return string
63+
*/
64+
protected function decodeContent($data)
65+
{
66+
$decoded = html_entity_decode(strip_tags($data), ENT_QUOTES, 'UTF-8');
67+
68+
return str_replace("\xc2\xa0", ' ', $decoded);
69+
}
5770
}

0 commit comments

Comments
 (0)