Skip to content

Commit 57b3237

Browse files
committed
$fetch_option setter added
1 parent 91f045e commit 57b3237

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/IMAP/Message.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ public function __construct($uid, $msglist, Client $client, $fetch_options = nul
131131
$this->uid = $uid;
132132
$this->msglist = $msglist;
133133
$this->client = $client;
134-
$this->fetch_options = ($fetch_options) ? $fetch_options : config('imap.options.fetch', FT_UID);
135134

135+
$this->setFetchOption($fetch_options);
136136
$this->parseHeader();
137137
$this->parseBody();
138138
}
@@ -442,6 +442,24 @@ protected function fetchAttachment($structure, $partNumber){
442442
}
443443
}
444444

445+
/**
446+
* Fail proof setter for $fetch_option
447+
*
448+
* @param $option
449+
*
450+
* @return $this
451+
*/
452+
public function setFetchOption($option){
453+
if(is_long($option) == true){
454+
$this->fetch_options = $option;
455+
}elseif(is_null($option) == true){
456+
$config = config('imap.options.fetch', FT_UID);
457+
$this->fetch_options = is_long($config) ? $config : 1;
458+
}
459+
460+
return $this;
461+
}
462+
445463
/**
446464
* Decode a given string
447465
*

0 commit comments

Comments
 (0)