@@ -36,6 +36,7 @@ class Packet implements IDatabaseObject, JsonSerializable
3636
3737 // Maximum SQL field lengths, alter as appropriate
3838 const MAX_APPLICATION_LAYER_ID = 0x7FFFFFFFFFFFFFFF ;
39+ const MAX_BRIEF = 191 ;
3940 const MAX_DIRECTION = 0x7FFFFFFFFFFFFFFF ;
4041 const MAX_EDITED_COUNT = 0x7FFFFFFFFFFFFFFF ;
4142 const MAX_FORMAT = 0xFFFF ;
@@ -57,6 +58,7 @@ class Packet implements IDatabaseObject, JsonSerializable
5758 private $ _id ;
5859
5960 protected $ application_layer_id ;
61+ protected $ brief ;
6062 protected $ created_datetime ;
6163 protected $ direction ;
6264 protected $ edited_count ;
@@ -110,6 +112,7 @@ public function allocate()
110112 }
111113
112114 $ this ->setApplicationLayerId (self ::DEFAULT_APPLICATION_LAYER_ID );
115+ $ this ->setBrief ('' );
113116 $ this ->setCreatedDateTime (new DateTime ('now ' ));
114117 $ this ->setDirection (self ::DEFAULT_DIRECTION );
115118 $ this ->setEditedCount (0 );
@@ -136,6 +139,7 @@ public function allocate()
136139 `id`,
137140 `options_bitmask`,
138141 `packet_application_layer_id`,
142+ `packet_brief`,
139143 `packet_direction_id`,
140144 `packet_format`,
141145 `packet_id`,
@@ -188,6 +192,7 @@ protected function allocateObject(StdClass $value)
188192 $ tz = new DateTimeZone (self ::TZ_SQL );
189193
190194 $ this ->setApplicationLayerId ($ value ->packet_application_layer_id );
195+ $ this ->setBrief ($ value ->packet_brief );
191196 $ this ->setCreatedDateTime (new DateTime ($ value ->created_datetime , $ tz ));
192197 $ this ->setDirection ($ value ->packet_direction_id );
193198 $ this ->setEditedCount ($ value ->edited_count );
@@ -223,6 +228,7 @@ public function commit()
223228 `id`,
224229 `options_bitmask`,
225230 `packet_application_layer_id`,
231+ `packet_brief`,
226232 `packet_direction_id`,
227233 `packet_format`,
228234 `packet_id`,
@@ -231,14 +237,15 @@ public function commit()
231237 `packet_transport_layer_id`,
232238 `user_id`
233239 ) VALUES (
234- :c_dt, :e_c, :e_dt, :id, :opts, :app_id, :d, :f, :pid, :n, :r, :tr_id, :uid
240+ :c_dt, :e_c, :e_dt, :id, :opts, :app_id, :b, : d, :f, :pid, :n, :r, :tr_id, :uid
235241 ) ON DUPLICATE KEY UPDATE
236242 `created_datetime` = :c_dt,
237243 `edited_count` = :e_c,
238244 `edited_datetime` = :e_dt,
239245 `id` = :id,
240246 `options_bitmask` = :opts,
241247 `packet_application_layer_id` = :app_id,
248+ `packet_brief` = :b,
242249 `packet_direction_id` = :d,
243250 `packet_format` = :f,
244251 `packet_id` = :pid,
@@ -255,6 +262,7 @@ public function commit()
255262 );
256263
257264 $ q ->bindParam (':app_id ' , $ this ->application_layer_id , PDO ::PARAM_INT );
265+ $ q ->bindParam (':b ' , $ this ->brief , (is_null ($ this ->brief ) ? PDO ::PARAM_NULL : PDO ::PARAM_STR ));
258266 $ q ->bindParam (':c_dt ' , $ created_datetime , PDO ::PARAM_STR );
259267 $ q ->bindParam (':d ' , $ this ->direction , PDO ::PARAM_INT );
260268 $ q ->bindParam (':e_c ' , $ this ->edited_count , PDO ::PARAM_INT );
@@ -389,6 +397,17 @@ public function getApplicationLayerId()
389397 return $ this ->application_layer_id ;
390398 }
391399
400+ public function getBrief (bool $ format )
401+ {
402+ if (!($ format && $ this ->getOption (self ::OPTION_MARKDOWN )))
403+ {
404+ return $ this ->brief ;
405+ }
406+
407+ $ md = new Parsedown ();
408+ return $ md ->text ($ this ->brief );
409+ }
410+
392411 public function getCreatedDateTime ()
393412 {
394413 return $ this ->created_datetime ;
@@ -626,6 +645,7 @@ public function jsonSerialize()
626645 'id ' => $ this ->getId (),
627646 'options_bitmask ' => $ this ->getOptions (),
628647 'packet_application_layer_id ' => $ this ->getApplicationLayerId (),
648+ 'packet_brief ' => $ this ->getBrief (false ),
629649 'packet_direction_id ' => $ this ->getDirection (),
630650 'packet_format ' => $ this ->getFormat (),
631651 'packet_id ' => $ this ->getPacketId (),
@@ -653,6 +673,23 @@ public function setApplicationLayerId(int $value)
653673 $ this ->application_layer_id = $ value ;
654674 }
655675
676+ /**
677+ * Sets the brief description of this packet.
678+ *
679+ * @param string $value The brief description.
680+ */
681+ public function setBrief (string $ value )
682+ {
683+ if (strlen ($ value ) > self ::MAX_BRIEF )
684+ {
685+ throw new OutOfBoundsException (sprintf (
686+ 'value must be between 0-%d characters ' , self ::MAX_BRIEF
687+ ));
688+ }
689+
690+ $ this ->brief = $ value ;
691+ }
692+
656693 /**
657694 * Sets the Date and Time this Packet was created.
658695 *
0 commit comments