Passed
Pull Request — master (#130)
by
unknown
06:19 queued 03:18
created

MandrillAdapter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 12
c 1
b 0
f 1
dl 0
loc 22
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A sendMail() 0 15 2
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 MandrillAdapter implements MailerInterface
21
{
22
    /**
23
     * Send mail by using Mandrill
24
     * @param  string $data
25
     * @return bool
26
     */
27
    public function sendMail($data)
28
    {
29
        try {
30
            $data["key"] = config()->get('mailer.mandrill.api_key');
31
32
            $httpClient = new HttpClient();
33
            $httpClient->createMultiRequest()
34
                ->createRequest("https://mandrillapp.com/api/1.0/messages/send.json")
35
                ->setMethod("POST")
36
                ->setData($data)
37
                ->start();
38
39
            return true;
40
        } catch (\Exception $e) {
41
            return false;
42
        }
43
    }
44
}
45