pssht  latest
SSH server library written in PHP
DEBUG.php
1 <?php
2 
3 /*
4 * This file is part of pssht.
5 *
6 * (c) François Poirotte <clicky@erebot.net>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11 
12 namespace fpoirotte\Pssht\Messages;
13 
17 class DEBUG implements MessageInterface
18 {
20  protected $alwaysDisplay;
21 
23  protected $message;
24 
26  protected $language;
27 
28 
44  {
45  if (!is_bool($alwaysDisplay)) {
46  throw new \InvalidArgumentException();
47  }
48  if (!is_string($message)) {
49  throw new \InvalidArgumentException();
50  }
51  if (!is_string($language)) {
52  throw new \InvalidArgumentException();
53  }
54 
55  $this->alwaysDisplay = $alwaysDisplay;
56  $this->message = $message;
57  $this->language = $language;
58  }
59 
60  public static function getMessageId()
61  {
62  return 4;
63  }
64 
65  public function serialize(\fpoirotte\Pssht\Wire\Encoder $encoder)
66  {
67  $encoder->encodeBoolean($this->alwaysDisplay);
68  $encoder->encodeString($this->message);
69  $encoder->encodeString($this->language);
70  return $this;
71  }
72 
73  public static function unserialize(\fpoirotte\Pssht\Wire\Decoder $decoder)
74  {
75  return new static(
76  $decoder->decodeBoolean(),
77  $decoder->decodeString(),
78  $decoder->decodeString()
79  );
80  }
81 
90  public function mustAlwaysDisplay()
91  {
92  return $this->alwaysDisplay;
93  }
94 
101  public function getMessage()
102  {
103  return $this->message;
104  }
105 
113  public function getLanguage()
114  {
115  return $this->language;
116  }
117 }
serialize(\fpoirotte\Pssht\Wire\Encoder $encoder)
Definition: DEBUG.php:65
$alwaysDisplay
Whether to always display the message or not.
Definition: DEBUG.php:20
__construct($alwaysDisplay, $message, $language)
Definition: DEBUG.php:43
$language
Language the debug message is written into (from RFC 3066).
Definition: DEBUG.php:26
static unserialize(\fpoirotte\Pssht\Wire\Decoder $decoder)
Definition: DEBUG.php:73
$message
Actual debug message.
Definition: DEBUG.php:23