Mailable::mail()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 9
rs 10
cc 2
nc 2
nop 3
1
<?php
2
3
/*
4
 * This file is part of the PHALCON-EXT package.
5
 *
6
 * (c) Jitendra Adhikari <[email protected]>
7
 *     <https://github.com/adhocore>
8
 *
9
 * Licensed under MIT license.
10
 */
11
12
namespace PhalconExt\Mail;
13
14
use Phalcon\Di;
0 ignored issues
show
Bug introduced by
The type Phalcon\Di 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...
15
16
trait Mailable
17
{
18
    /**
19
     * Mail.
20
     *
21
     * @param mixed  $to      Recepient address(es) [array/string]
22
     * @param string $subject
23
     * @param array  $options The body &/or view template.
24
     *
25
     * @return int
26
     */
27
    public function mail($to, string $subject, array $options = []): int
28
    {
29
        $mailer = Di::getDefault()->resolve('mailer');
30
31
        $mail = ($options['template'] ?? null)
32
            ? $mailer->newTemplateMail($options['template'], $options['params'] ?? [])
33
            : $mailer->newMail()->setBody($options['body']);
34
35
        return $mail->setTo($to)->setSubject($subject)->mail();
36
    }
37
}
38