| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace CBOR; |
| 6 | |
| 7 | use function chr; |
| 8 | |
| 9 | abstract class AbstractCBORObject implements CBORObject |
| 10 | { |
| 11 | public function __construct( |
| 12 | private int $majorType, |
| 13 | protected int $additionalInformation |
| 14 | ) { |
| 15 | } |
| 16 | |
| 17 | public function __toString(): string |
| 18 | { |
| 19 | return chr($this->majorType << 5 | $this->additionalInformation); |
| 20 | } |
| 21 | |
| 22 | public function getMajorType(): int |
| 23 | { |
| 24 | return $this->majorType; |
| 25 | } |
| 26 | |
| 27 | public function getAdditionalInformation(): int |
| 28 | { |
| 29 | return $this->additionalInformation; |
| 30 | } |
| 31 | } |