Smtp::setSsl()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 8
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\Mail\Transport;
12
13
/**
14
 * Class Smtp
15
 */
16
class Smtp extends AbstractTransport
17
{
18
    /**
19
     * @param string $host
20
     * @param string $username
21
     * @param string $password
22
     */
23
    public function __construct($host, $username, $password)
24
    {
25
        $this->setType('smtp');
26
        $this->setOptions([
27
            'host' => $host,
28
            'connection_class' => 'login',
29
            'connection_config' => [
30
                'username' => $username,
31
                'password' => $password,
32
            ],
33
        ]);
34
    }
35
36
    /**
37
     * @param int $port
38
     * @return $this
39
     */
40
    public function setSsl($port = 465)
41
    {
42
        $this->setOptions([
43
            'port' => $port,
44
            'connection_config' => ['ssl' => 'ssl'],
45
        ]);
46
        return $this;
47
    }
48
49
    /**
50
     * @param int $port
51
     * @return $this
52
     */
53
    public function setTls($port = 587)
54
    {
55
        $this->setOptions([
56
            'port' => $port,
57
            'connection_config' => ['ssl' => 'tls'],
58
        ]);
59
        return $this;
60
    }
61
}
62