Total Complexity | 8 |
Total Lines | 66 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
8 | trait ModifiesLabels |
||
9 | { |
||
10 | |||
11 | private $messageRequest; |
||
12 | |||
13 | public $service; |
||
14 | |||
15 | public function __construct() |
||
18 | } |
||
19 | |||
20 | /** |
||
21 | * Adds labels to the email |
||
22 | * |
||
23 | * @param string|array $labels |
||
24 | * |
||
25 | * @return Mail|string |
||
26 | * @throws \Exception |
||
27 | */ |
||
28 | public function addLabel( $labels ) |
||
29 | { |
||
30 | if(is_string($labels)) { |
||
31 | $labels = [$labels]; |
||
32 | } |
||
33 | |||
34 | $this->messageRequest->setAddLabelIds( $labels ); |
||
35 | |||
36 | try { |
||
37 | return $this->modify(); |
||
38 | } catch ( \Exception $e ) { |
||
39 | throw new \Exception( "Couldn't add labels: {$e->getMessage()}" ); |
||
40 | } |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * Removes labels from the email |
||
45 | * |
||
46 | * @param string|array $labels |
||
47 | * |
||
48 | * @return Mail|string |
||
49 | * @throws \Exception |
||
50 | */ |
||
51 | public function removeLabel( $labels ) |
||
63 | } |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * Executes the modification |
||
68 | * |
||
69 | * @return Mail |
||
70 | */ |
||
71 | private function modify() |
||
74 | } |
||
75 | } |