Completed
Push — master ( 3afd02...a4590b )
by Vojta
04:54
created

BaseMailer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 39
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getTemplateIdent() 0 12 2
A initRecipients() 0 8 1
1
<?php namespace VojtaSvoboda\Reservations\Mailers;
2
3
use App;
4
use Config;
5
6
class BaseMailer
7
{
8
    /** Default template locale. */
9
    const DEFAULT_TEMPLATE_LOCALE = 'en';
10
11
    /**
12
     * Get template ident by locale.
13
     *
14
     * @param string $name
15
     *
16
     * @return string
17
     */
18
    public function getTemplateIdent($name)
19
    {
20
        $locale = App::getLocale();
21
        $identBase = 'vojtasvoboda.reservations::mail.' . $name . '-';
22
        $ident = $identBase . $locale;
23
24
        if (file_exists(__DIR__ . '/../views/mail/' . $ident . '.htm')) {
25
            return $ident;
26
        }
27
28
        return $identBase . self::DEFAULT_TEMPLATE_LOCALE;
29
    }
30
31
    /**
32
     * Init recipients array.
33
     *
34
     * @return array
35
     */
36
    public function initRecipients()
37
    {
38
        $recipients = [];
39
        $recipients['bcc_email'] = Config::get('vojtasvoboda.reservations::config.mail.bcc_email');
40
        $recipients['bcc_name'] = Config::get('vojtasvoboda.reservations::config.mail.bcc_name');
41
42
        return $recipients;
43
    }
44
}
45