Completed
Pull Request — master (#259)
by
unknown
04:18
created

Pool   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfigDefaults() 0 7 1
B open() 0 21 5
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->bind('onauth', function ($conn, $ok) use ($params) {
0 ignored issues
show
Unused Code introduced by
The parameter $ok is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
29
                $conn->selectBox();
30
            });
31
            $conn->bind('onselect', function ($conn, $ok) use ($params) {
0 ignored issues
show
Unused Code introduced by
The parameter $ok is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
32
                call_user_func($params['cb'], $conn);
33
            });
34
            $conn->auth($params['user'], $params['pass']);
35
36
            //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...
37
        });
38
    }
39
}
40