CustomMessageMask   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 3
dl 0
loc 16
rs 10
c 1
b 0
f 1
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getAttachmentCount() 0 2 1
A my_token() 0 2 1
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 my_token(){
20
        return implode('-', [$this->message_id, $this->uid, $this->message_no]);
0 ignored issues
show
Bug Best Practice introduced by
The property message_no does not exist on CustomMessageMask. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug Best Practice introduced by
The property message_id does not exist on CustomMessageMask. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug Best Practice introduced by
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
Bug introduced by
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 ignore-call  annotation

28
        return $this->/** @scrutinizer ignore-call */ getAttachments()->count();
Loading history...
29
    }
30
31
}
32
33
/** @var \Webklex\PHPIMAP\Client $oClient */
34
$oClient = \Webklex\IMAP\Facades\Client::account('default');
0 ignored issues
show
Bug Best Practice introduced by
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 ignore-call  annotation

34
$oClient = \Webklex\IMAP\Facades\Client::/** @scrutinizer ignore-call */ account('default');
Loading history...
35
$oClient->connect();
36
37
/** @var \Webklex\PHPIMAP\Folder $folder */
38
$folder = $oClient->getFolder('INBOX');
39
40
/** @var \Webklex\PHPIMAP\Message $message */
41
$message = $folder->query()->limit(1)->get()->first();
42
43
/** @var CustomMessageMask $masked_message */
44
$masked_message = $message->mask(CustomMessageMask::class);
45
46
echo 'Token for uid ['.$masked_message->uid.']: '.$masked_message->my_token().' @atms:'.$masked_message->getAttachmentCount();
0 ignored issues
show
Bug Best Practice introduced by
The property uid does not exist on CustomMessageMask. Since you implemented __get, consider adding a @property annotation.
Loading history...
47
48
$masked_message->setFlag('seen');
0 ignored issues
show
Bug introduced by
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 ignore-call  annotation

48
$masked_message->/** @scrutinizer ignore-call */ 
49
                 setFlag('seen');
Loading history...
49
50