Skip to content
Snippets Groups Projects
Commit 1aa5f9b7 authored by James R Glasgow's avatar James R Glasgow
Browse files

Merge remote-tracking branch...

Merge remote-tracking branch 'csv_serialization-3429690/project-update-bot-only' into 3429690-automated-drupal-11

# Conflicts:
#	csv_serialization.info.yml
parents 48219859 9aa70e17
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,6 @@
"type": "drupal-module",
"homepage": "https://www.drupal.org/project/csv_serialization",
"license": "GPL-2.0-or-later",
"minimum-stability": "dev",
"authors": [
{
"name": "Matthew Grasmick"
......
......@@ -15,27 +15,6 @@ use Symfony\Component\Serializer\Encoder\EncoderInterface;
*/
class CsvEncoder implements EncoderInterface, DecoderInterface {
/**
* Indicates the character used to delimit fields. Defaults to ",".
*
* @var string
*/
protected $delimiter;
/**
* Indicates the character used for field enclosure. Defaults to '"'.
*
* @var string
*/
protected $enclosure;
/**
* Indicates the character used for escaping. Defaults to "\".
*
* @var string
*/
protected $escapeChar;
/**
* Indicates the character used for new line. Defaults to "\n".
*
......@@ -43,20 +22,6 @@ class CsvEncoder implements EncoderInterface, DecoderInterface {
*/
protected $newline;
/**
* Whether to strip tags from values or not. Defaults to TRUE.
*
* @var bool
*/
protected $stripTags;
/**
* Whether to trim values or not. Defaults to TRUE.
*
* @var bool
*/
protected $trimValues;
/**
* The format that this encoder supports.
*
......@@ -85,19 +50,20 @@ class CsvEncoder implements EncoderInterface, DecoderInterface {
* Indicates the character used to delimit fields. Defaults to ",".
* @param string $enclosure
* Indicates the character used for field enclosure. Defaults to '"'.
* @param string $escape_char
* @param string $escapeChar
* Indicates the character used for escaping. Defaults to "\".
* @param bool $strip_tags
* @param bool $stripTags
* Whether to strip tags from values or not. Defaults to TRUE.
* @param bool $trim_values
* @param bool $trimValues
* Whether to trim values or not. Defaults to TRUE.
*/
public function __construct($delimiter = ",", $enclosure = '"', $escape_char = "\\", $strip_tags = TRUE, $trim_values = TRUE) {
$this->delimiter = $delimiter;
$this->enclosure = $enclosure;
$this->escapeChar = $escape_char;
$this->stripTags = $strip_tags;
$this->trimValues = $trim_values;
public function __construct(
protected string $delimiter = ",",
protected string $enclosure = '"',
protected string $escapeChar = "\\",
protected bool $stripTags = TRUE,
protected bool $trimValues = TRUE,
) {
}
/**
......@@ -119,7 +85,7 @@ class CsvEncoder implements EncoderInterface, DecoderInterface {
*
* Uses HTML-safe strings, with several characters escaped.
*/
public function encode($data, string $format, array $context = []):string {
public function encode(mixed $data, string $format, array $context = []): string {
switch (gettype($data)) {
case "array":
break;
......@@ -294,7 +260,7 @@ class CsvEncoder implements EncoderInterface, DecoderInterface {
* @throws \League\Csv\Exception
* @throws \League\Csv\Exception
*/
public function decode($data, string $format, array $context = []) {
public function decode(string $data, string $format, array $context = []): mixed {
$csv = Reader::createFromString($data);
$csv->setDelimiter($this->delimiter);
$csv->setEnclosure($this->enclosure);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment