Passed
Branch master (328f34)
by Chubarov
04:39
created

OneToAll::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 3
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 3
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 1
nc 1
nop 0
crap 1
1
<?php
2
namespace agoalofalife\postman\Modes;
3
4
use agoalofalife\postman\Contract\Mode;
5
6
use Illuminate\Support\Facades\Mail;
7
use agoalofalife\postman\Models\SheduleEmail;
8
9
/**
10
 * Class OneToAll
11
 * POST `BCC EMAIL
12
 * @package agoalofalife\postman\Modes
13
 */
14 View Code Duplication
class OneToAll implements Mode
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
15
{
16
    /**
17
     * @param SheduleEmail $tasks
18
     */
19
    public function postEmail(SheduleEmail $tasks) : void
20
    {
21 1
         Mail::raw($tasks->email->text, function ($message) use ($tasks) {
22 1
            $message->subject($tasks->email->theme);
23 1
            $message->from(config('mail.from.address'));
24 1
            $message->to(config('mail.from.address'));
25
26 1
            $tasks->email->users->each(function ($value) use ($message) {
27 1
                $message->bcc($value->email);
28 1
            });
29 1
         });
30
31
        // if to reached the sender
32 1
        if (empty(Mail::failures())) {
33 1
            $tasks->status_action = 1;
34 1
            $tasks->save();
35
        }
36 1
    }
37
38
    /**
39
     *  Get name mode
40
     * @return string
41
     */
42 2
    public function getName(): string
43
    {
44 2
        return trans('postman::mode.one.name');
0 ignored issues
show
Bug Best Practice introduced by
The expression return trans('postman::mode.one.name') could return the type Illuminate\Contracts\Tra...n\Translator|null|array which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
45
    }
46
47
    /**
48
     * Get full description
49
     * @return string
50
     */
51 2
    public function getDescription(): string
52
    {
53 2
        return trans('postman::mode.one.description');
0 ignored issues
show
Bug Best Practice introduced by
The expression return trans('postman::mode.one.description') could return the type Illuminate\Contracts\Tra...n\Translator|null|array which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
54
    }
55
}