Webklex /
php-imap
| 1 | <?php |
||||||
| 2 | /* |
||||||
| 3 | * File: custom_message_mask.php |
||||||
| 4 | * Category: Example |
||||||
| 5 | * Author: M.Goldenbaum |
||||||
| 6 | * Created: 14.03.19 18:47 |
||||||
| 7 | * Updated: - |
||||||
| 8 | * |
||||||
| 9 | * Description: |
||||||
| 10 | * - |
||||||
| 11 | */ |
||||||
| 12 | |||||||
| 13 | class CustomMessageMask extends \Webklex\PHPIMAP\Support\Masks\MessageMask { |
||||||
| 14 | |||||||
| 15 | /** |
||||||
| 16 | * New custom method which can be called through a mask |
||||||
| 17 | * @return string |
||||||
| 18 | */ |
||||||
| 19 | public function token(){ |
||||||
| 20 | return implode('-', [$this->message_id, $this->uid, $this->message_no]); |
||||||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
The property
message_id does not exist on CustomMessageMask. Since you implemented __get, consider adding a @property annotation.
Loading history...
The property
uid does not exist on CustomMessageMask. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||||||
| 21 | } |
||||||
| 22 | |||||||
| 23 | /** |
||||||
| 24 | * Get number of message attachments |
||||||
| 25 | * @return integer |
||||||
| 26 | */ |
||||||
| 27 | public function getAttachmentCount() { |
||||||
| 28 | return $this->getAttachments()->count(); |
||||||
|
0 ignored issues
–
show
The method
getAttachments() does not exist on CustomMessageMask. Since you implemented __call, consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 29 | } |
||||||
| 30 | |||||||
| 31 | } |
||||||
| 32 | |||||||
| 33 | /** @var \Webklex\PHPIMAP\Client $client */ |
||||||
| 34 | $cm = new \Webklex\PHPIMAP\ClientManager('path/to/config/imap.php'); |
||||||
| 35 | $client = $cm->account('default'); |
||||||
| 36 | $client->connect(); |
||||||
| 37 | |||||||
| 38 | /** @var \Webklex\PHPIMAP\Folder $folder */ |
||||||
| 39 | $folder = $client->getFolder('INBOX'); |
||||||
| 40 | |||||||
| 41 | /** @var \Webklex\PHPIMAP\Message $message */ |
||||||
| 42 | $message = $folder->query()->limit(1)->get()->first(); |
||||||
| 43 | |||||||
| 44 | /** @var CustomMessageMask $masked_message */ |
||||||
| 45 | $masked_message = $message->mask(CustomMessageMask::class); |
||||||
| 46 | |||||||
| 47 | echo 'Token for uid ['.$masked_message->uid.']: '.$masked_message->token().' @atms:'.$masked_message->getAttachmentCount(); |
||||||
|
0 ignored issues
–
show
The property
uid does not exist on CustomMessageMask. Since you implemented __get, consider adding a @property annotation.
Loading history...
|
|||||||
| 48 | |||||||
| 49 | $masked_message->setFlag('seen'); |
||||||
|
0 ignored issues
–
show
The method
setFlag() does not exist on CustomMessageMask. Since you implemented __call, consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 50 | |||||||
| 51 |