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 CustomAttachmentMask extends \Webklex\PHPIMAP\Support\Masks\AttachmentMask { |
||||
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->id, $this->getMessage()->getUid(), $this->name]); |
||||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() The property
id does not exist on CustomAttachmentMask . Since you implemented __get , consider adding a @property annotation.
![]() The method
getMessage() does not exist on CustomAttachmentMask . 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
![]() |
|||||
21 | } |
||||
22 | |||||
23 | /** |
||||
24 | * Custom attachment saving method |
||||
25 | * @return bool |
||||
26 | */ |
||||
27 | public function custom_save() { |
||||
28 | $path = storage_path('foo'); |
||||
29 | $filename = $this->token(); |
||||
30 | |||||
31 | $path = substr($path, -1) == DIRECTORY_SEPARATOR ? $path : $path.DIRECTORY_SEPARATOR; |
||||
32 | |||||
33 | return \Illuminate\Support\Facades\File::put($path.$filename, $this->getContent()) !== false; |
||||
0 ignored issues
–
show
The method
getContent() does not exist on CustomAttachmentMask . 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
![]() |
|||||
34 | } |
||||
35 | |||||
36 | } |
||||
37 | |||||
38 | /** @var \Webklex\PHPIMAP\Client $oClient */ |
||||
39 | $oClient = \Webklex\IMAP\Facades\Client::account('default'); |
||||
0 ignored issues
–
show
The method
Webklex\IMAP\Facades\Client::account() is not static, but was called statically.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
40 | $oClient->connect(); |
||||
41 | $oClient->setDefaultAttachmentMask(CustomAttachmentMask::class); |
||||
42 | |||||
43 | /** @var \Webklex\PHPIMAP\Folder $folder */ |
||||
44 | $folder = $oClient->getFolder('INBOX'); |
||||
45 | |||||
46 | /** @var \Webklex\PHPIMAP\Message $message */ |
||||
47 | $message = $folder->query()->limit(1)->get()->first(); |
||||
48 | |||||
49 | /** @var \Webklex\PHPIMAP\Attachment $attachment */ |
||||
50 | $attachment = $message->getAttachments()->first(); |
||||
51 | |||||
52 | /** @var CustomAttachmentMask $masked_attachment */ |
||||
53 | $masked_attachment = $attachment->mask(); |
||||
54 | |||||
55 | echo 'Token for uid ['.$masked_attachment->getMessage()->getUid().']: '.$masked_attachment->token(); |
||||
56 | |||||
57 | $masked_attachment->custom_save(); |