connection error exception class added
This commit is contained in:
parent
26f6ff8840
commit
948d61cc3f
|
@ -5,6 +5,8 @@
|
|||
|
||||
namespace Clivern\Imap\Core;
|
||||
|
||||
use Clivern\Imap\Core\Exception\ConnectionError;
|
||||
|
||||
/**
|
||||
* Connection Class
|
||||
*
|
||||
|
@ -72,10 +74,15 @@ class Connection
|
|||
* Connect to IMAP Email
|
||||
*
|
||||
* @return Connection
|
||||
* @throws ConnectionError
|
||||
*/
|
||||
public function connect()
|
||||
{
|
||||
$this->stream = imap_open("{" . $this->server . ":" . $this->port . $this->flag . "}" . $this->folder, $this->email, $this->password);
|
||||
try {
|
||||
$this->stream = imap_open("{" . $this->server . ":" . $this->port . $this->flag . "}" . $this->folder, $this->email, $this->password);
|
||||
} catch (\Exception $e) {
|
||||
throw new ConnectionError("Error! Connecting to Imap Email.");
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
13
src/Core/Exception/ConnectionError.php
Normal file
13
src/Core/Exception/ConnectionError.php
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
/**
|
||||
* @author clivern <hello@clivern.com>
|
||||
*/
|
||||
|
||||
namespace Clivern\Imap\Core\Exception;
|
||||
|
||||
/**
|
||||
* Connection Error Class
|
||||
*
|
||||
* @package Clivern\Imap\Core\Exception
|
||||
*/
|
||||
class ConnectionError extends \Exception{}
|
|
@ -4,6 +4,7 @@
|
|||
*/
|
||||
|
||||
namespace Clivern\Imap\Core;
|
||||
|
||||
use Clivern\Imap\Core\Connection;
|
||||
|
||||
/**
|
||||
|
@ -22,12 +23,16 @@ class Stats
|
|||
|
||||
public function getQuota($folder = 'INBOX')
|
||||
{
|
||||
return imap_get_quotaroot($this->connection->getStream(), $folder);
|
||||
$data = imap_get_quotaroot($this->connection->getStream(), $folder);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
public function getStatus($folder = 'INBOX', $flag = SA_ALL)
|
||||
{
|
||||
return imap_status($this->connection->getStream(), "{" . $this->connection->getServer() . "}" . $folder, $flag);
|
||||
$data = imap_status($this->connection->getStream(), "{" . $this->connection->getServer() . "}" . $folder, $flag);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue