File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed
Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -300,14 +300,16 @@ public static function parse(string $rawMessage): Message
300300 $ segments = Parser::parseSegments ($ rawMessage );
301301
302302 // Message header and footer must always be there, or something went badly wrong.
303- if (!($ segments [0 ] instanceof HNHBKv3)) {
304- throw new \InvalidArgumentException ("Expected first segment to be HNHBK: $ rawMessage " );
305- }
306- if (!($ segments [count ($ segments ) - 1 ] instanceof HNHBSv1)) {
307- throw new \InvalidArgumentException ("Expected last segment to be HNHBS: $ rawMessage " );
308- }
309303 $ result ->header = $ segments [0 ];
310304 $ result ->footer = $ segments [count ($ segments ) - 1 ];
305+ if (!($ result ->header instanceof HNHBKv3)) {
306+ $ actual = $ result ->header ->getName ();
307+ throw new \InvalidArgumentException ("Expected first segment to be HNHBK, but got $ actual: $ rawMessage " );
308+ }
309+ if (!($ result ->footer instanceof HNHBSv1)) {
310+ $ actual = $ result ->footer ->getName ();
311+ throw new \InvalidArgumentException ("Expected last segment to be HNHBS, but got $ actual: $ rawMessage " );
312+ }
311313
312314 // Check if there's an encryption header and "encrypted" data.
313315 // Section B.8 specifies that there are exactly 4 segments: HNHBK, HNVSK, HNVSD, HNHBS.
You can’t perform that action at this time.
0 commit comments