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

Each::getDescription()   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
use agoalofalife\postman\Models\SheduleEmail;
6
use Illuminate\Support\Facades\Mail;
7
8 View Code Duplication
class Each 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...
9
{
10
    /**
11
     * @param SheduleEmail $tasks
12
     * @return mixed|void
13
     */
14
    public function postEmail(SheduleEmail $tasks)
15
    {
16
        Mail::raw($tasks->email->text, function ($message) use ($tasks) {
17
        $message->subject($tasks->email->theme);
18
        $message->from(config('mail.from.address'));
19
        $message->to($tasks->email->users->map(function($value){ return $value->email;})->toArray());
20
    });
21
22
        // if to reached the sender
23
        if (empty(Mail::failures())) {
24
            $tasks->status_action = 1;
25
            $tasks->save();
26
        }
27
    }
28
29
    /**
30
     *  Get name mode
31
     * @return string
32
     */
33 2
    public function getName(): string
34
    {
35 2
        return trans('postman::mode.two.name');
0 ignored issues
show
Bug Best Practice introduced by
The expression return trans('postman::mode.two.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...
36
    }
37
38
    /**
39
     * Get full description
40
     * @return string
41
     */
42 2
    public function getDescription(): string
43
    {
44 2
        return trans('postman::mode.two.name');
0 ignored issues
show
Bug Best Practice introduced by
The expression return trans('postman::mode.two.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
}