-
-
Notifications
You must be signed in to change notification settings - Fork 178
/
custom_message_mask.php
49 lines (38 loc) · 1.18 KB
/
custom_message_mask.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/*
* File: custom_message_mask.php
* Category: Example
* Author: M.Goldenbaum
* Created: 14.03.19 18:47
* Updated: -
*
* Description:
* -
*/
class CustomMessageMask extends \Webklex\PHPIMAP\Support\Masks\MessageMask {
/**
* New custom method which can be called through a mask
* @return string
*/
public function my_token(){
return implode('-', [$this->message_id, $this->uid, $this->message_no]);
}
/**
* Get number of message attachments
* @return integer
*/
public function getAttachmentCount() {
return $this->getAttachments()->count();
}
}
/** @var \Webklex\PHPIMAP\Client $oClient */
$oClient = \Webklex\IMAP\Facades\Client::account('default');
$oClient->connect();
/** @var \Webklex\PHPIMAP\Folder $folder */
$folder = $oClient->getFolder('INBOX');
/** @var \Webklex\PHPIMAP\Message $message */
$message = $folder->query()->limit(1)->get()->first();
/** @var CustomMessageMask $masked_message */
$masked_message = $message->mask(CustomMessageMask::class);
echo 'Token for uid ['.$masked_message->uid.']: '.$masked_message->my_token().' @atms:'.$masked_message->getAttachmentCount();
$masked_message->setFlag('seen');