Update Composer packages

This commit is contained in:
Paul Nicoué 2024-12-20 12:37:52 +01:00
parent 9252d9ce90
commit 134266af8a
176 changed files with 7930 additions and 2262 deletions

View file

@ -93,10 +93,14 @@ class Txt extends Handler
throw new InvalidArgumentException('Invalid TXT data; please pass a string');
}
// remove BOM
$string = str_replace("\xEF\xBB\xBF", '', $string);
// remove Unicode BOM at the beginning of the file
if (Str::startsWith($string, "\xEF\xBB\xBF") === true) {
$string = substr($string, 3);
}
// explode all fields by the line separator
$fields = preg_split('!\n----\s*\n*!', $string);
// start the data array
$data = [];

View file

@ -0,0 +1,43 @@
<?php
namespace Kirby\Data;
use Kirby\Exception\InvalidArgumentException;
use Spyc;
/**
* Simple Wrapper around the Spyc YAML class
*
* @package Kirby Data
* @author Bastian Allgeier <bastian@getkirby.com>
* @link https://getkirby.com
* @copyright Bastian Allgeier
* @license https://opensource.org/licenses/MIT
*/
class YamlSpyc
{
/**
* Converts an array to an encoded YAML string
*/
public static function encode($data): string
{
// $data, $indent, $wordwrap, $no_opening_dashes
return Spyc::YAMLDump($data, false, false, true);
}
/**
* Parses an encoded YAML string and returns a multi-dimensional array
*/
public static function decode($string): array
{
$result = Spyc::YAMLLoadString($string);
if (is_array($result) === true) {
return $result;
}
// apparently Spyc always returns an array, even for invalid YAML syntax
// so this Exception should currently never be thrown
throw new InvalidArgumentException('The YAML data cannot be parsed'); // @codeCoverageIgnore
}
}

View file

@ -0,0 +1,44 @@
<?php
namespace Kirby\Data;
use Kirby\Cms\App;
use Kirby\Toolkit\A;
use Symfony\Component\Yaml\Yaml as Symfony;
/**
* Simple Wrapper around the Symfony YAML class
*
* @package Kirby Data
* @author Nico Hoffmann <nico@getkirby.com>
* @link https://getkirby.com
* @copyright Bastian Allgeier
* @license https://opensource.org/licenses/MIT
*/
class YamlSymfony
{
/**
* Converts an array to an encoded YAML string
*/
public static function encode($data): string
{
$kirby = App::instance(null, true);
return Symfony::dump(
$data,
$kirby?->option('yaml.params.inline') ?? 9999,
$kirby?->option('yaml.params.indent') ?? 2,
Symfony::DUMP_MULTI_LINE_LITERAL_BLOCK | Symfony::DUMP_EMPTY_ARRAY_AS_SEQUENCE
);
}
/**
* Parses an encoded YAML string and returns a multi-dimensional array
*/
public static function decode($string): array
{
$result = Symfony::parse($string);
$result = A::wrap($result);
return $result;
}
}