@@ -30,8 +30,8 @@ public function __construct(
3030 protected Folder $ folder ,
3131 protected int $ uid ,
3232 protected array $ flags ,
33- protected string $ headers ,
34- protected string $ contents ,
33+ protected string $ head ,
34+ protected string $ body ,
3535 ) {}
3636
3737 /**
@@ -62,33 +62,33 @@ public function flags(): array
6262 /**
6363 * Get the message's raw headers.
6464 */
65- public function headers (): string
65+ public function head (): string
6666 {
67- return $ this ->headers ;
67+ return $ this ->head ;
6868 }
6969
7070 /**
7171 * Determine if the message has headers.
7272 */
73- public function hasHeaders (): bool
73+ public function hasHead (): bool
7474 {
75- return ! empty ($ this ->headers );
75+ return ! empty ($ this ->head );
7676 }
7777
7878 /**
79- * Get the message's raw contents .
79+ * Get the message's raw body .
8080 */
81- public function contents (): string
81+ public function body (): string
8282 {
83- return $ this ->contents ;
83+ return $ this ->body ;
8484 }
8585
8686 /**
8787 * Determine if the message has contents.
8888 */
89- public function hasContents (): bool
89+ public function hasBody (): bool
9090 {
91- return ! empty ($ this ->contents );
91+ return ! empty ($ this ->body );
9292 }
9393
9494 /**
@@ -297,6 +297,14 @@ public function hasFlag(BackedEnum|string $flag): bool
297297 return in_array (Str::prefix (Str::enum ($ flag ), '\\' ), $ this ->flags );
298298 }
299299
300+ /**
301+ * Get all headers from the message.
302+ */
303+ public function headers (): array
304+ {
305+ return $ this ->parse ()->getAllHeaders ();
306+ }
307+
300308 /**
301309 * Get a header from the message.
302310 */
@@ -483,7 +491,7 @@ public function restore(): void
483491 */
484492 public function parse (): MailMimeMessage
485493 {
486- if (! $ this ->hasHeaders () && ! $ this ->hasContents ()) {
494+ if (! $ this ->hasHead () && ! $ this ->hasBody ()) {
487495 throw new RuntimeException ('Cannot parse an empty message ' );
488496 }
489497
@@ -498,8 +506,8 @@ public function toArray(): array
498506 return [
499507 'uid ' => $ this ->uid ,
500508 'flags ' => $ this ->flags ,
501- 'headers ' => $ this ->headers ,
502- 'contents ' => $ this ->contents ,
509+ 'head ' => $ this ->head ,
510+ 'body ' => $ this ->body ,
503511 ];
504512 }
505513
@@ -509,8 +517,8 @@ public function toArray(): array
509517 public function __toString (): string
510518 {
511519 return implode ("\r\n\r\n" , array_filter ([
512- rtrim ($ this ->headers ),
513- ltrim ($ this ->contents ),
520+ rtrim ($ this ->head ),
521+ ltrim ($ this ->body ),
514522 ]));
515523 }
516524
0 commit comments