1<?php 2/** 3 * This file is part of the FreeDSx LDAP package. 4 * 5 * (c) Chad Sikorra <Chad.Sikorra@gmail.com> 6 * 7 * For the full copyright and license information, please view the LICENSE 8 * file that was distributed with this source code. 9 */ 10 11namespace FreeDSx\Ldap\Operation\Request; 12 13use FreeDSx\Asn1\Asn1; 14use FreeDSx\Asn1\Type\AbstractType; 15use FreeDSx\Asn1\Type\IntegerType; 16use FreeDSx\Ldap\Exception\ProtocolException; 17 18/** 19 * RFC 4511, 4.11. 20 * 21 * AbandonRequest ::= [APPLICATION 16] MessageID 22 * 23 * @author Chad Sikorra <Chad.Sikorra@gmail.com> 24 */ 25class AbandonRequest implements RequestInterface 26{ 27 protected const APP_TAG = 16; 28 29 /** 30 * @var int 31 */ 32 protected $messageID; 33 34 /** 35 * @param int $messageID 36 */ 37 public function __construct(int $messageID) 38 { 39 $this->messageID = $messageID; 40 } 41 42 /** 43 * @param int $messageID 44 * @return $this 45 */ 46 public function setMessageId(int $messageID) 47 { 48 $this->messageID = $messageID; 49 50 return $this; 51 } 52 53 /** 54 * @return int 55 */ 56 public function getMessageId(): int 57 { 58 return $this->messageID; 59 } 60 61 /** 62 * {@inheritdoc} 63 */ 64 public static function fromAsn1(AbstractType $type) 65 { 66 if (!$type instanceof IntegerType) { 67 throw new ProtocolException('The abandon request is malformed'); 68 } 69 70 return new self($type->getValue()); 71 } 72 73 /** 74 * {@inheritdoc} 75 */ 76 public function toAsn1(): AbstractType 77 { 78 return Asn1::application(self::APP_TAG, Asn1::integer($this->messageID)); 79 } 80} 81