1<?php
2/**
3 * Copyright 2013-2017 Horde LLC (http://www.horde.org/)
4 *
5 * See the enclosed file COPYING for license information (LGPL). If you
6 * did not receive this file, see http://www.horde.org/licenses/lgpl21.
7 *
8 * @category  Horde
9 * @copyright 2013-2017 Horde LLC
10 * @license   http://www.horde.org/licenses/lgpl21 LGPL 2.1
11 * @package   Imap_Client
12 */
13
14/**
15 * An object representing a portion of an IMAP command that requires data
16 * sent in a continuation response (RFC 3501 [2.2.1]).
17 *
18 * @author    Michael Slusarz <slusarz@horde.org>
19 * @category  Horde
20 * @copyright 2013-2017 Horde LLC
21 * @license   http://www.horde.org/licenses/lgpl21 LGPL 2.1
22 * @package   Imap_Client
23 * @since     2.10.0
24 */
25class Horde_Imap_Client_Interaction_Command_Continuation
26{
27    /**
28     * Is this an optional continuation request?
29     *
30     * @since 2.13.0
31     * @var boolean
32     */
33    public $optional = false;
34
35    /**
36     * Closure function to run after continuation response.
37     *
38     * @var Closure
39     */
40    protected $_closure;
41
42    /**
43     * Constructor.
44     *
45     * @param Closure $closure  A function to run after the continuation
46     *                          response is received.  It receives one
47     *                          argument - a Continuation object - and should
48     *                          return a list of arguments to send to the
49     *                          server (via a
50     *                          Horde_Imap_Client_Data_Format_List object).
51     */
52    public function __construct($closure)
53    {
54        $this->_closure = $closure;
55    }
56
57    /**
58     * Calls the closure object.
59     *
60     * @param Horde_Imap_Client_Interaction_Server_Continuation $ob  Continuation
61     *                                                               object.
62     *
63     * @return Horde_Imap_Client_Data_Format_List  Further commands to issue
64     *                                             to the server.
65     */
66    public function getCommands(
67        Horde_Imap_Client_Interaction_Server_Continuation $ob
68    )
69    {
70        $closure = $this->_closure;
71        return $closure($ob);
72    }
73
74}
75