Pool::getConfigDefaults()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
nc 1
nop 0
1
<?php
2
3
namespace PHPDaemon\Clients\IMAP;
4
5
use PHPDaemon\Network\Client;
6
use PHPDaemon\Core\Daemon;
7
8
class Pool extends Client
9
{
10
    protected function getConfigDefaults()
11
    {
12
        return [
13
            'port'    => 143,
14
            'sslport' => 993,
15
        ];
16
    }
17
18
    public function open($host, $user, $pass, $cb, $ssl = true)
19
    {
20
        $params = compact('host', 'user', 'pass', 'cb', 'ssl');
21
        $params['port'] = $params['ssl'] ? $this->config->sslport->value : $this->config->port->value;
0 ignored issues
show
Bug introduced by
The property sslport does not seem to exist in PHPDaemon\Config\Section.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
Bug introduced by
The property port does not seem to exist in PHPDaemon\Config\Section.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
22
        $dest = 'tcp://' . $params['host'] . ':' . $params['port'] . ($params['ssl'] ? '#ssl' : '');
23
        $this->getConnection($dest, function ($conn) use ($params) {
24
            if (!$conn || !$conn->isConnected()) {
25
                call_user_func($params['cb'], false);
26
                return;
27
            }
28
            $conn->auth(
29
                function ($conn) use ($params) {
30
                    if (!$conn) {
31
                        call_user_func($params['cb'], false);
32
                        return;
33
                    }
34
                    $conn->selectBox($params['cb']);
35
                },
36
                $params['user'],
37
                $params['pass']
38
            );
39
40
            //TODO: startTls
41
        });
42
    }
43
}
44