Completed
Push — master ( 91ccea...f6c83d )
by Vasily
06:04 queued 02:17
created

Pool::getConfigDefaults()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 4
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 7
rs 9.4285
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
0 ignored issues
show
Coding Style Best Practice introduced by
Comments for TODO tasks are often forgotten in the code; it might be better to use a dedicated issue tracker.
Loading history...
41
        });
42
    }
43
}
44