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\Protocol;
12
13use FreeDSx\Asn1\Type\AbstractType;
14use FreeDSx\Ldap\Control\Control;
15use FreeDSx\Ldap\Operation\LdapResult;
16use FreeDSx\Ldap\Operation\Response\ResponseInterface;
17
18/**
19 * The LDAP Message envelope PDU. This represents a message as a response from LDAP.
20 *
21 * @see LdapMessage
22 * @author Chad Sikorra <Chad.Sikorra@gmail.com>
23 */
24class LdapMessageResponse extends LdapMessage
25{
26    /**
27     * @var ResponseInterface
28     */
29    protected $response;
30
31    /**
32     * @param int $messageId
33     * @param ResponseInterface $response
34     * @param Control ...$controls
35     */
36    public function __construct(int $messageId, ResponseInterface $response, Control ...$controls)
37    {
38        $this->response = $response;
39        parent::__construct($messageId, ...$controls);
40    }
41
42    /**
43     * @return ResponseInterface|LdapResult
44     */
45    public function getResponse(): ResponseInterface
46    {
47        return $this->response;
48    }
49
50    /**
51     * @return AbstractType
52     */
53    protected function getOperationAsn1(): AbstractType
54    {
55        return $this->response->toAsn1();
56    }
57}
58