1 | <?php |
||||
2 | |||||
3 | namespace Dacastro4\LaravelGmail\Traits; |
||||
4 | |||||
5 | use Google_Service_Gmail; |
||||
6 | |||||
7 | trait HasLabels |
||||
8 | { |
||||
9 | /** |
||||
10 | * List the labels in the user's mailbox. |
||||
11 | * |
||||
12 | * @param $userEmail |
||||
13 | * |
||||
14 | * @return \Google\Service\Gmail\ListLabelsResponse |
||||
15 | */ |
||||
16 | public function labelsList($userEmail) |
||||
17 | { |
||||
18 | $service = new Google_Service_Gmail($this); |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
19 | |||||
20 | return $service->users_labels->listUsersLabels($userEmail); |
||||
21 | } |
||||
22 | |||||
23 | /** |
||||
24 | * Create new label by name. |
||||
25 | * |
||||
26 | * @param $userEmail |
||||
27 | * @param $label |
||||
28 | * |
||||
29 | * @return \Google\Service\Gmail\Label |
||||
30 | */ |
||||
31 | public function createLabel($userEmail, $label) |
||||
32 | { |
||||
33 | $service = new Google_Service_Gmail($this); |
||||
0 ignored issues
–
show
$this of type Dacastro4\LaravelGmail\Traits\HasLabels is incompatible with the type Google\Client|array expected by parameter $clientOrConfig of Google_Service_Gmail::__construct() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
34 | |||||
35 | return $service->users_labels->create($userEmail, $label); |
||||
36 | } |
||||
37 | |||||
38 | /** |
||||
39 | * first or create label in the user's mailbox. |
||||
40 | * |
||||
41 | * @param $userEmail |
||||
42 | * @param $nLabel |
||||
43 | * @return \Google\Service\Gmail\Label |
||||
44 | */ |
||||
45 | public function firstOrCreateLabel($userEmail, $newLabel) |
||||
46 | { |
||||
47 | $labels = $this->labelsList($userEmail); |
||||
48 | |||||
49 | foreach ($labels->getLabels() as $existLabel) { |
||||
50 | if ($existLabel->getName() == $newLabel->getName()) { |
||||
51 | return $existLabel; |
||||
52 | } |
||||
53 | } |
||||
54 | |||||
55 | $service = new Google_Service_Gmail($this); |
||||
0 ignored issues
–
show
$this of type Dacastro4\LaravelGmail\Traits\HasLabels is incompatible with the type Google\Client|array expected by parameter $clientOrConfig of Google_Service_Gmail::__construct() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
56 | |||||
57 | return $service->users_labels->create($userEmail, $newLabel); |
||||
58 | } |
||||
59 | } |