LogEmail::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 4
rs 10
1
<?php
2
namespace Yaro\LogEnvelope\Mail;
3
4
use Illuminate\Bus\Queueable;
0 ignored issues
show
Bug introduced by
The type Illuminate\Bus\Queueable was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
5
use Illuminate\Mail\Mailable;
0 ignored issues
show
Bug introduced by
The type Illuminate\Mail\Mailable was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Illuminate\Queue\SerializesModels;
0 ignored issues
show
Bug introduced by
The type Illuminate\Queue\SerializesModels was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Illuminate\Contracts\Queue\ShouldQueue;
0 ignored issues
show
Bug introduced by
The type Illuminate\Contracts\Queue\ShouldQueue was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
class LogEmail extends Mailable implements ShouldQueue
10
{
11
    use Queueable, SerializesModels;
12
    
13
    public $data;
14
    public $config;
15
    
16
    public function __construct($data, $config)
17
    {
18
        $this->data = $data;
19
        $this->config = $config;
20
    }
21
    
22
    /**
23
     * Build the message.
24
     *
25
     * @return $this
26
     */
27
    public function build()
28
    {
29
        $subject = sprintf('[%s] @ %s: %s', $this->data['class'], $this->data['host'], $this->data['exception']);
30
    
31
        // to protect from gmail's anchors automatic generating
32
        $this->withSwiftMessage(function ($message) {
33
            $message->setBody(
34
                preg_replace(
35
                    ['~\.~', '~http~'],
36
                    ['<span>.</span>', '<span>http</span>'],
37
                    $message->getBody()
38
                )
39
            );
40
        });
41
        
42
        return $this->view('log-envelope::main')
43
            ->with($this->data)
44
            ->to($this->config['to'])
45
            ->from($this->config['from_email'], $this->config['from_name'])
46
            ->subject($subject);
47
    }
48
}
49