[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 declare(strict_types=1); 4 5 /* 6 * The MIT License (MIT) 7 * 8 * Copyright (c) 2018-2020 Spomky-Labs 9 * 10 * This software may be modified and distributed under the terms 11 * of the MIT license. See the LICENSE file for details. 12 */ 13 14 namespace CBOR\Tag; 15 16 use CBOR\CBORObject; 17 use CBOR\OtherObject\DoublePrecisionFloatObject; 18 use CBOR\OtherObject\HalfPrecisionFloatObject; 19 use CBOR\OtherObject\SinglePrecisionFloatObject; 20 use CBOR\TagObject as Base; 21 use CBOR\UnsignedIntegerObject; 22 use DateTimeImmutable; 23 use InvalidArgumentException; 24 use function strval; 25 26 final class TimestampTag extends Base 27 { 28 public static function getTagId(): int 29 { 30 return 1; 31 } 32 33 public static function createFromLoadedData(int $additionalInformation, ?string $data, CBORObject $object): Base 34 { 35 return new self($additionalInformation, $data, $object); 36 } 37 38 public static function create(CBORObject $object): Base 39 { 40 if (!$object instanceof UnsignedIntegerObject && !$object instanceof HalfPrecisionFloatObject && !$object instanceof SinglePrecisionFloatObject && !$object instanceof DoublePrecisionFloatObject) { 41 throw new InvalidArgumentException('This tag only accepts a Byte String object.'); 42 } 43 44 return new self(1, null, $object); 45 } 46 47 public function getNormalizedData(bool $ignoreTags = false) 48 { 49 if ($ignoreTags) { 50 return $this->object->getNormalizedData($ignoreTags); 51 } 52 switch (true) { 53 case $this->object instanceof UnsignedIntegerObject: 54 return DateTimeImmutable::createFromFormat('U', strval($this->object->getNormalizedData($ignoreTags))); 55 case $this->object instanceof HalfPrecisionFloatObject: 56 case $this->object instanceof SinglePrecisionFloatObject: 57 case $this->object instanceof DoublePrecisionFloatObject: 58 return DateTimeImmutable::createFromFormat('U.u', strval($this->object->getNormalizedData($ignoreTags))); 59 default: 60 return $this->object->getNormalizedData($ignoreTags); 61 } 62 } 63 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |