AbstractMailer::getTransportKey()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Webino™ (http://webino.sk)
4
 *
5
 * @link        https://github.com/webino for the canonical source repository
6
 * @copyright   Copyright (c) 2015-2017 Webino, s.r.o. (http://webino.sk)
7
 * @author      Peter Bačinský <[email protected]>
8
 * @license     BSD-3-Clause
9
 */
10
11
namespace WebinoConfigLib\Feature;
12
13
use WebinoConfigLib\Mail\Transport;
14
15
/**
16
 * Class AbstractMailer
17
 */
18
abstract class AbstractMailer extends AbstractFeature
19
{
20
    /**
21
     * Config key
22
     */
23
    const KEY = 'mail';
24
    
25
    /**
26
     * @var Transport\AbstractTransport
27
     */
28
    protected $transport;
29
30
    /**
31
     * @var string
32
     */
33
    protected $transportKey;
34
35
    /**
36
     * @return string
37
     */
38
    protected function getTransportKey()
39
    {
40
        if (null === $this->transportKey) {
41
            $this->setTransportKey(get_class($this));
42
        }
43
        return $this->transportKey;
44
    }
45
46
    /**
47
     * @param string $key
48
     * @return $this
49
     */
50
    protected function setTransportKey($key)
51
    {
52
        $this->transportKey = (string) $key;
53
        return $this;
54
    }
55
56
    /**
57
     * @return array
58
     */
59
    public function toArray()
60
    {
61
        $this->mergeArray([
62
            $this::KEY => [
63
                // TODO constant transports
64
                'transports' => [
65
                    $this->getTransportKey() => $this->transport->toArray(),
66
                ],
67
            ],
68
        ]);
69
70
        return parent::toArray();
71
    }
72
}
73