1<?php 2 3/** 4 * This file is part of the FreeDSx LDAP package. 5 * 6 * (c) Chad Sikorra <Chad.Sikorra@gmail.com> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12namespace FreeDSx\Ldap\Operation\Request; 13 14use FreeDSx\Asn1\Asn1; 15use FreeDSx\Asn1\Type\AbstractType; 16use FreeDSx\Asn1\Type\NullType; 17use FreeDSx\Ldap\Exception\ProtocolException; 18 19/** 20 * A request to unbind. RFC 4511, 4.3 21 * 22 * UnbindRequest ::= [APPLICATION 2] NULL 23 * 24 * @author Chad Sikorra <Chad.Sikorra@gmail.com> 25 */ 26class UnbindRequest implements RequestInterface 27{ 28 protected const APP_TAG = 2; 29 30 /** 31 * {@inheritDoc} 32 * @return self 33 */ 34 public static function fromAsn1(AbstractType $type) 35 { 36 if (!$type instanceof NullType) { 37 throw new ProtocolException('The unbind request is invalid'); 38 } 39 40 return new self(); 41 } 42 43 /** 44 * {@inheritdoc} 45 */ 46 public function toAsn1(): AbstractType 47 { 48 return Asn1::application(self::APP_TAG, Asn1::null()); 49 } 50} 51