Passed
Pull Request — master (#130)
by
unknown
03:14
created

MailgunAdapter::sendMail()   A

Complexity

Conditions 2
Paths 3

Size

Total Lines 18
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 15
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 18
rs 9.7666
1
<?php
2
3
/**
4
 * Quantum PHP Framework
5
 *
6
 * An open source software development framework for PHP
7
 *
8
 * @package Quantum
9
 * @author Arman Ag. <[email protected]>
10
 * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
11
 * @link http://quantum.softberg.org/
12
 * @since 2.9.0
13
 */
14
15
namespace Quantum\Libraries\Mailer\Adapters;
16
17
use Quantum\Libraries\Mailer\MailerInterface;
18
use Quantum\Libraries\Curl\HttpClient;
19
20
class MailgunAdapter implements MailerInterface
21
{
22
    /**
23
     * Send mail by using Sendinblue
24
     * @param  string $data
25
     * @return bool
26
     */
27
    public function sendMail($data)
28
    {
29
        try {
30
            $httpClient = new HttpClient();
31
            $httpClient->createMultiRequest()
32
                ->createRequest('https://api.mailgun.net/v3/' . config()->get('mailer.mailgun.domain') . '/messages')
33
                ->setMethod('POST')
34
                ->setHeaders([
0 ignored issues
show
Bug introduced by
The method setHeaders() does not exist on Quantum\Libraries\Curl\HttpClient. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

34
                ->/** @scrutinizer ignore-call */ setHeaders([
Loading history...
35
                    "Authorization: Basic " . base64_encode("api:" . config()->get('mailer.mailgun.api_key')),
36
                    "Content-Type: application/x-www-form-urlencoded"
37
                ])
38
                ->setData($data)
39
                ->start();
40
            return true;
41
            dd($httpClient);
0 ignored issues
show
Unused Code introduced by
dd($httpClient) is not reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
42
        } catch (\Exception $e) {
43
            dd($e);
44
            return false;
45
        }
46
    }
47
}
48