ImapPool.php 738 字节
<?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(){

    }


}