ImapPool.php
738 字节
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace Lib\Imap;
class ImapPool {
    /**
     * @var Imap[]
     */
    private static array $pool;
    /**
     * 获取连接
     * @param ImapConfig $config
     * @return Imap
     * @author:dc
     * @time 2024/9/14 9:19
     */
    public static function get(ImapConfig $config){
        if(!isset(static::$pool[$config->getEmail()])){
            static::$pool[$config->getEmail()] = new Imap($config);
        }
        return static::$pool[$config->getEmail()];
    }
    /**
     * @param Imap $imap
     * @author:dc
     * @time 2024/10/14 9:05
     */
    public static function release(Imap $imap){
        unset(static::$pool[$imap->config->getEmail()]);
    }
    public function noop(){
    }
}