Initial xentral_oss_20.3.c9ffacf

This commit is contained in:
Alex
2021-05-21 08:49:41 +02:00
parent 5406e4a551
commit 34e5ac43d9
18884 changed files with 2109867 additions and 0 deletions
@@ -0,0 +1,32 @@
<?php
namespace Xentral\Modules\TransferSmartyTemplate\TemplateHelper;
use Xentral\Modules\TransferSmartyTemplate\Exception\InvalidArgumentException;
final class CsvHelper
{
/**
* Quotes and escapes an CSV value
*
* @param string $string
* @param string $enclosure
*
* @throws InvalidArgumentException
*
* @return string
*/
public function quoteCsv($string, $enclosure = '"')
{
if (!is_string($enclosure)) {
throw new InvalidArgumentException('Invalid argument. Enclosure need to be type string.');
}
if (strlen($enclosure) !== 1) {
throw new InvalidArgumentException('Invalid argument. Enclosure can only be a single character.');
}
$escapedString = (string)str_replace($enclosure, $enclosure . $enclosure, $string);
return $enclosure . $escapedString . $enclosure;
}
}