Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Spomky committed Sep 14, 2021
1 parent d0e655d commit b4efbec
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 42 deletions.
10 changes: 8 additions & 2 deletions src/AbstractCBORObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@

abstract class AbstractCBORObject implements CBORObject
{
protected int $additionalInformation;
private int $majorType;
/**
* @var int
*/
protected $additionalInformation;
/**
* @var int
*/
private $majorType;

public function __construct(int $majorType, int $additionalInformation)
{
Expand Down
11 changes: 9 additions & 2 deletions src/ByteStringObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ final class ByteStringObject extends AbstractCBORObject
{
private const MAJOR_TYPE = 0b010;

private string $value;
private ?int $length;
/**
* @var string
*/
private $value;

/**
* @var int|null
*/
private $length;

public function __construct(string $data)
{
Expand Down
3 changes: 3 additions & 0 deletions src/CBORObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@ public function getMajorType(): int;

public function getAdditionalInformation(): int;

/**
* @return mixed|null
*/
public function getNormalizedData(bool $ignoreTags = false);
}
11 changes: 9 additions & 2 deletions src/Decoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,15 @@

final class Decoder
{
private TagObjectManager $tagObjectManager;
private OtherObjectManager $otherTypeManager;
/**
* @var TagObjectManager
*/
private $tagObjectManager;

/**
* @var OtherObjectManager
*/
private $otherTypeManager;

public function __construct(TagObjectManager $tagObjectManager, OtherObjectManager $otherTypeManager)
{
Expand Down
2 changes: 1 addition & 1 deletion src/IndefiniteLengthByteStringObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class IndefiniteLengthByteStringObject extends AbstractCBORObject
/**
* @var ByteStringObject[]
*/
private array $chunks = [];
private $chunks = [];

public function __construct()
{
Expand Down
2 changes: 1 addition & 1 deletion src/IndefiniteLengthListObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class IndefiniteLengthListObject extends AbstractCBORObject implements Countable
/**
* @var CBORObject[]
*/
private array $data = [];
private $data = [];

public function __construct()
{
Expand Down
2 changes: 1 addition & 1 deletion src/IndefiniteLengthMapObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class IndefiniteLengthMapObject extends AbstractCBORObject implements Countable,
/**
* @var MapItem[]
*/
private array $data = [];
private $data = [];

public function __construct()
{
Expand Down
33 changes: 0 additions & 33 deletions src/Tag/EpochTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,9 @@

namespace CBOR\Tag;

<<<<<<< HEAD
use CBOR\CBORObject;
use CBOR\TagObject as Base;
use DateTimeImmutable;
use JetBrains\PhpStorm\Pure;

final class EpochTag extends Base
{
public static function getTagId(): int
{
return 0;
}

public static function createFromLoadedData(int $additionalInformation, ?string $data, CBORObject $object): Base
{
return new self($additionalInformation, $data, $object);
}

public static function create(CBORObject $object): Base
{
return new self(0, null, $object);
}

public function getNormalizedData(bool $ignoreTags = false)
{
if ($ignoreTags) {
return $this->object->getNormalizedData($ignoreTags);
}

return DateTimeImmutable::createFromFormat(DATE_RFC3339, $this->object->getNormalizedData($ignoreTags));
}
=======
/**
* @deprecated The class EpochTag is deprecated and will be removed in v3.0. Please use DatetimeTag instead
*/
final class EpochTag extends DatetimeTag
{
>>>>>>> v2.0
}

0 comments on commit b4efbec

Please sign in to comment.