- md5
- 4904ff7b6fb48de45f35665ce6735a4b
- sha1
- 13ece164442a9073d2312602eca6b095e5cd3784
- sha256
- 842c300f9065b9cfe470612e15c3c02ed656f1b4587d473c997e6a609ebcedb2
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
<?php
declare(strict_types=1);
/*
* The MIT License (MIT)
*
* Copyright (c) 2018 Spomky-Labs
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
namespace CBOR;
use InvalidArgumentException;
final class ByteStringWithChunkObject extends AbstractCBORObject
{
private const MAJOR_TYPE = 0b010;
private const ADDITIONAL_INFORMATION = 0b00011111;
/**
* @var ByteStringObject[]
*/
private $chunks = [];
public function __construct()
{
parent::__construct(self::MAJOR_TYPE, self::ADDITIONAL_INFORMATION);
}
public function add(ByteStringObject $chunk): void
{
$this->chunks[] = $chunk;
}
public function append(string $chunk): void
{
$this->add(new ByteStringObject($chunk));
}
public function getValue(): string
{
$result = '';
foreach ($this->chunks as $chunk) {
$result .= $chunk->getValue();
}
return $result;
}
public function getLength(): int
{
$length = 0;
foreach ($this->chunks as $chunk) {
$length += $chunk->getLength();
}
return $length;
}
public function getNormalizedData(bool $ignoreTags = false): string
{
$result = '';
foreach ($this->chunks as $chunk) {
$result .= $chunk->getNormalizedData($ignoreTags);
}
return $result;
}
public function __toString(): string
{
$result = parent::__toString();
foreach ($this->chunks as $chunk) {
$result .= (string) $chunk;
}
$bin = hex2bin('FF');
if (false === $bin) {
throw new InvalidArgumentException('Unable to convert the data');
}
$result .= $bin;
return $result;
}
}
The same content is in 3 releases, Joomla 4.0.0-beta to 4.0.0-beta3. See them all, or every version of this file.