mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-09 05:38:39 +00:00
Doc fixes and bug fixes
This commit is contained in:
parent
ca0e03efc3
commit
fb7c720c3d
|
|
@ -71,7 +71,17 @@ class Integer
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function trialFactorization(int $value)
|
/**
|
||||||
|
* Trial factorization.
|
||||||
|
*
|
||||||
|
* @param int $value Integer to factorize
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn
|
||||||
|
*/
|
||||||
|
public static function trialFactorization(int $value) : array
|
||||||
{
|
{
|
||||||
if ($value < 2) {
|
if ($value < 2) {
|
||||||
return [];
|
return [];
|
||||||
|
|
@ -98,31 +108,65 @@ class Integer
|
||||||
return $factors;
|
return $factors;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function pollardsRho($value, $x = 2, $factor = 1, $cycleSize = 2, $xFixed = 2)
|
/**
|
||||||
|
* Pollard's Rho.
|
||||||
|
*
|
||||||
|
* Integer factorization algorithm
|
||||||
|
*
|
||||||
|
* @param int $n Integer to factorize
|
||||||
|
* @param int $x Used for g(x) = (x^2 + 1) mod n
|
||||||
|
* @param int $factor Period for repetition
|
||||||
|
* @param int $cycleSize Cycle size
|
||||||
|
* @param int $y Fixed value for g(x) = g(y) mod p
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn
|
||||||
|
*/
|
||||||
|
public static function pollardsRho(int $n, int $x = 2, int $factor = 1, int $cycleSize = 2, int $y = 2) : int
|
||||||
{
|
{
|
||||||
while ($factor === 1) {
|
while ($factor === 1) {
|
||||||
for ($i = 1; $i < $cycleSize && $factor <= 1; $i++) {
|
for ($i = 1; $i < $cycleSize && $factor <= 1; $i++) {
|
||||||
$x = ($x * $x + 1) % $value;
|
$x = ($x * $x + 1) % $n;
|
||||||
$factor = self::greatestCommonDivisor($x - $xFixed, $value);
|
$factor = self::greatestCommonDivisor($x - $y, $n);
|
||||||
}
|
}
|
||||||
|
|
||||||
$cycleSize *= 2;
|
$cycleSize *= 2;
|
||||||
$xFixed = $x;
|
$y = $x;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $factor;
|
return $factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function fermatFactor(int $value)
|
/**
|
||||||
|
* Fermat factorization of odd integers.
|
||||||
|
*
|
||||||
|
* @param int $value Integer to factorize
|
||||||
|
* @param int $limit Max amount of iterations
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*
|
||||||
|
* @throws \Exception
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn
|
||||||
|
*/
|
||||||
|
public static function fermatFactor(int $value, int $limit = 1000000) : int
|
||||||
{
|
{
|
||||||
$a = $value;
|
if(($value % 2) !== 0) {
|
||||||
$b2 = $a * $a - $value;
|
throw new \Exception('Only odd integers are allowed');
|
||||||
|
}
|
||||||
|
|
||||||
while (abs((int) round(sqrt($b2), 0) - sqrt($b2)) > 0.0001) {
|
$a = (int) ceil(sqrt($value));
|
||||||
|
$b2 = $a * $a - $value;
|
||||||
|
$i = 1;
|
||||||
|
|
||||||
|
while (!Numbers::isSquare($b2) && $i < $limit) {
|
||||||
$a += 1;
|
$a += 1;
|
||||||
$b2 = $a * $a - $value;
|
$b2 = $a * $a - $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $a - sqrt($b2);
|
return (int) round($a - sqrt($b2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -15,16 +15,60 @@
|
||||||
*/
|
*/
|
||||||
namespace phpOMS\Message\Mail;
|
namespace phpOMS\Message\Mail;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Imap mail class.
|
||||||
|
*
|
||||||
|
* @category Framework
|
||||||
|
* @package phpOMS\Message\Mail
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @link http://orange-management.com
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
class Imap extends Mail
|
class Imap extends Mail
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Mail inbox.
|
||||||
|
*
|
||||||
|
* @var resource
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private $inbox = null;
|
private $inbox = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Host.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private $host = '';
|
private $host = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
private $user = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct(MailType::IMAP);
|
parent::__construct(MailType::IMAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destructor.
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function __destruct()
|
public function __destruct()
|
||||||
{
|
{
|
||||||
if (isset($this->inbox)) {
|
if (isset($this->inbox)) {
|
||||||
|
|
@ -32,103 +76,273 @@ class Imap extends Mail
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connect to inbox.
|
||||||
|
*
|
||||||
|
* @param string $host Host
|
||||||
|
* @param string $user User
|
||||||
|
* @param string $password Password
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function connect($host, $user, $password)
|
public function connect($host, $user, $password)
|
||||||
{
|
{
|
||||||
$this->host = $host;
|
$this->host = $host;
|
||||||
|
$this->user = $user;
|
||||||
$this->inbox = imap_open($host, $user, $password);
|
$this->inbox = imap_open($host, $user, $password);
|
||||||
|
|
||||||
return !($this->inbox === false);
|
return !($this->inbox === false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBoxes()
|
/**
|
||||||
|
* Get boxes.
|
||||||
|
*
|
||||||
|
* @param string $pattern Pattern for boxes
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function getBoxes(string $pattern = '*') : array
|
||||||
{
|
{
|
||||||
return imap_list($this->inbox, $this->host, '*');
|
return imap_list($this->inbox, $this->host, $pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get inbox quota.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function getQuota()
|
public function getQuota()
|
||||||
{
|
{
|
||||||
return imap_get_quotaroot($this->inbox, "INBOX");
|
return imap_get_quotaroot($this->inbox, "INBOX");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInbox(string $option = 'ALL') : array
|
/**
|
||||||
|
* Get inbox overview.
|
||||||
|
*
|
||||||
|
* @param string $option Inbox option (imap_search creterias)
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function getInboxOverview(string $option = 'ALL') : array
|
||||||
{
|
{
|
||||||
$ids = imap_search($this->inbox, $option, SE_FREE, 'UTF-8');
|
$ids = imap_search($this->inbox, $option, SE_FREE, 'UTF-8');
|
||||||
|
|
||||||
return is_array($ids) ? imap_fetch_overview($this->inbox, implode(',', $ids)) : [];
|
return is_array($ids) ? imap_fetch_overview($this->inbox, implode(',', $ids)) : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEmail($id)
|
/**
|
||||||
|
* Get email.
|
||||||
|
*
|
||||||
|
* @param mixed $id mail id
|
||||||
|
*
|
||||||
|
* @return Mail
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function getEmail($id) : Mail
|
||||||
{
|
{
|
||||||
return [
|
$mail = new Mail($id);
|
||||||
'overview' => imap_fetch_overview($this->inbox, $id),
|
$mail->setOverview(imap_fetch_overview($this->inbox, $id));
|
||||||
'body' => imap_fetchbody($this->inbox, $id, 2),
|
$mail->setBody(imap_fetchbody($this->inbox, $id, 2));
|
||||||
'encoding' => imap_fetchstructure($this->inbox, $id),
|
$mail->setEncoding(imap_fetchstructure($this->inbox, $id));
|
||||||
];
|
|
||||||
|
return $mail;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInboxAll()
|
/**
|
||||||
|
* Get all inbox messages.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function getInboxAll() : array
|
||||||
{
|
{
|
||||||
return $this->getInbox('ALL');
|
return $this->getInboxOverview('ALL');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInboxNew()
|
/**
|
||||||
|
* Get all new inbox messages.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function getInboxNew() : array
|
||||||
{
|
{
|
||||||
return $this->getInbox('NEW');
|
return $this->getInboxOverview('NEW');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInboxFrom(string $from)
|
/**
|
||||||
|
* Get all inbox messages from a person.
|
||||||
|
*
|
||||||
|
* @param string $from Messages from
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function getInboxFrom(string $from) : array
|
||||||
{
|
{
|
||||||
return $this->getInbox('FROM "' . $from . '"');
|
return $this->getInboxOverview('FROM "' . $from . '"');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInboxTo(string $to)
|
/**
|
||||||
|
* Get all inbox messages to a person.
|
||||||
|
*
|
||||||
|
* @param string $to Messages to
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function getInboxTo(string $to) : array
|
||||||
{
|
{
|
||||||
return $this->getInbox('TO "' . $to . '"');
|
return $this->getInboxOverview('TO "' . $to . '"');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInboxCc(string $cc)
|
/**
|
||||||
|
* Get all inbox messages cc a person.
|
||||||
|
*
|
||||||
|
* @param string $cc Messages cc
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function getInboxCc(string $cc) : array
|
||||||
{
|
{
|
||||||
return $this->getInbox('CC "' . $cc . '"');
|
return $this->getInboxOverview('CC "' . $cc . '"');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInboxBcc(string $bcc)
|
/**
|
||||||
|
* Get all inbox messages bcc a person.
|
||||||
|
*
|
||||||
|
* @param string $bcc Messages bcc
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function getInboxBcc(string $bcc) : array
|
||||||
{
|
{
|
||||||
return $this->getInbox('BCC "' . $bcc . '"');
|
return $this->getInboxOverview('BCC "' . $bcc . '"');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInboxAnswered()
|
/**
|
||||||
|
* Get all answered inbox messages.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function getInboxAnswered() : array
|
||||||
{
|
{
|
||||||
return $this->getInbox('ANSWERED');
|
return $this->getInboxOverview('ANSWERED');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInboxSubject(string $subject)
|
/**
|
||||||
|
* Get all inbox messages with a certain subject.
|
||||||
|
*
|
||||||
|
* @param string $subject Subject
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function getInboxSubject(string $subject) : array
|
||||||
{
|
{
|
||||||
return $this->getInbox('SUBJECT "' . $subject . '"');
|
return $this->getInboxOverview('SUBJECT "' . $subject . '"');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInboxSince(\DateTime $since)
|
/**
|
||||||
|
* Get all inbox messages from a certain date onwards.
|
||||||
|
*
|
||||||
|
* @param \DateTime $since Messages since
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function getInboxSince(\DateTime $since) : array
|
||||||
{
|
{
|
||||||
return $this->getInbox('SINCE "' . $since->format('d-M-Y') . '"');
|
return $this->getInboxOverview('SINCE "' . $since->format('d-M-Y') . '"');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInboxUnseen()
|
/**
|
||||||
|
* Get all unseen inbox messages.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function getInboxUnseen() : array
|
||||||
{
|
{
|
||||||
return $this->getInbox('UNSEEN');
|
return $this->getInboxOverview('UNSEEN');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInboxSeen()
|
/**
|
||||||
|
* Get all seen inbox messages.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function getInboxSeen() : array
|
||||||
{
|
{
|
||||||
return $this->getInbox('SEEN');
|
return $this->getInboxOverview('SEEN');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInboxDeleted()
|
/**
|
||||||
|
* Get all deleted inbox messages.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function getInboxDeleted() : array
|
||||||
{
|
{
|
||||||
return $this->getInbox('DELETED');
|
return $this->getInboxOverview('DELETED');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInboxText(string $text)
|
/**
|
||||||
|
* Get all inbox messages with text.
|
||||||
|
*
|
||||||
|
* @param string $text Text in message body
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function getInboxText(string $text) : array
|
||||||
{
|
{
|
||||||
return $this->getInbox('TEXT "' . $text . '"');
|
return $this->getInboxOverview('TEXT "' . $text . '"');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function decode($content, $encoding)
|
public static function decode($content, $encoding)
|
||||||
|
|
|
||||||
|
|
@ -17,46 +17,232 @@ namespace phpOMS\Message\Mail;
|
||||||
|
|
||||||
use phpOMS\Datatypes\Exception\InvalidEnumValue;
|
use phpOMS\Datatypes\Exception\InvalidEnumValue;
|
||||||
|
|
||||||
abstract class Mail
|
/**
|
||||||
|
* Mail class.
|
||||||
|
*
|
||||||
|
* @category Framework
|
||||||
|
* @package phpOMS\Message\Mail
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @link http://orange-management.com
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
class Mail
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Mail from.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
protected $from = '';
|
protected $from = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mail to.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
protected $to = [];
|
protected $to = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mail subject.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
protected $subject = '';
|
protected $subject = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mail cc.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
protected $cc = [];
|
protected $cc = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mail reply to.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
protected $replyTo = [];
|
protected $replyTo = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mail bcc.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
protected $bcc = [];
|
protected $bcc = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mail attachments.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
protected $attachment = [];
|
protected $attachment = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mail body.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
protected $body = '';
|
protected $body = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mail overview.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected $overview = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mail alt.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
protected $bodyAlt = '';
|
protected $bodyAlt = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mail mime.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
protected $bodyMime = '';
|
protected $bodyMime = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mail header.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
protected $headerMail = '';
|
protected $headerMail = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Word wrap.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
protected $wordWrap = 78;
|
protected $wordWrap = 78;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encoding.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected $encoding = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mail type.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
protected $type = MailType::MAIL;
|
protected $type = MailType::MAIL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mail host name.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
protected $hostname = '';
|
protected $hostname = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mail id.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
protected $messageId = '';
|
protected $messageId = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mail message type.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
protected $messageType = '';
|
protected $messageType = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mail from.
|
||||||
|
*
|
||||||
|
* @var \DateTime
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
protected $messageDate = null;
|
protected $messageDate = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* todo: ???
|
||||||
|
*/
|
||||||
protected $mailer = null;
|
protected $mailer = null;
|
||||||
|
|
||||||
public function __construct(int $type)
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param mixed $id Id
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function __construct($id)
|
||||||
{
|
{
|
||||||
$this->type = $type;
|
$this->messageId = $id;
|
||||||
|
}
|
||||||
|
|
||||||
switch ($type) {
|
/**
|
||||||
case MailType::MAIL:
|
* Set body.
|
||||||
break;
|
*
|
||||||
case MailType::SMTP:
|
* @param string $body Mail body
|
||||||
break;
|
*
|
||||||
case MailType::IMAP:
|
* @return void
|
||||||
break;
|
*
|
||||||
case MailType::POP3:
|
* @since 1.0.0
|
||||||
break;
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
case MailType::SENDMAIL:
|
*/
|
||||||
break;
|
public function setBody(string $body)
|
||||||
default:
|
{
|
||||||
throw new InvalidEnumValue($type);
|
$this->body = $body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set body.
|
||||||
|
*
|
||||||
|
* @param string $overview Mail overview
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function setOverview(string $overview)
|
||||||
|
{
|
||||||
|
$this->overview = $overview;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set encoding.
|
||||||
|
*
|
||||||
|
* @param int $encoding Mail encoding
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function setEncoding(int $encoding)
|
||||||
|
{
|
||||||
|
$this->encoding = $encoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ use phpOMS\Datatypes\Enum;
|
||||||
* Mail type.
|
* Mail type.
|
||||||
*
|
*
|
||||||
* @category Framework
|
* @category Framework
|
||||||
* @package phpOMS\DataStorage\Database
|
* @package phpOMS\Message\Mail
|
||||||
* @author OMS Development Team <dev@oms.com>
|
* @author OMS Development Team <dev@oms.com>
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
* @license OMS License 1.0
|
* @license OMS License 1.0
|
||||||
|
|
|
||||||
|
|
@ -325,6 +325,14 @@ abstract class RequestAbstract implements MessageInterface
|
||||||
return $this->status;
|
return $this->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get request header.
|
||||||
|
*
|
||||||
|
* @return HeaderAbstract
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function getHeader() : HeaderAbstract
|
public function getHeader() : HeaderAbstract
|
||||||
{
|
{
|
||||||
return $this->header;
|
return $this->header;
|
||||||
|
|
@ -353,5 +361,13 @@ abstract class RequestAbstract implements MessageInterface
|
||||||
*/
|
*/
|
||||||
abstract public function getRequestTarget() : string;
|
abstract public function getRequestTarget() : string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get route verb.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
abstract public function getRouteVerb() : int;
|
abstract public function getRouteVerb() : int;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -186,5 +186,13 @@ abstract class ResponseAbstract implements MessageInterface
|
||||||
return $this->header;
|
return $this->header;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get response body.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
abstract public function getBody() : string;
|
abstract public function getBody() : string;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@
|
||||||
namespace phpOMS\Utils\Parser\Php;
|
namespace phpOMS\Utils\Parser\Php;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array parser class.
|
* Class parser class.
|
||||||
*
|
*
|
||||||
* Parsing/serializing arrays to and from php file
|
* Parsing/serializing classes, interfaces to and from php file
|
||||||
*
|
*
|
||||||
* @category Framework
|
* @category Framework
|
||||||
* @package phpOMS\Utils\Parser
|
* @package phpOMS\Utils\Parser
|
||||||
|
|
@ -30,38 +30,118 @@ namespace phpOMS\Utils\Parser\Php;
|
||||||
*/
|
*/
|
||||||
class ClassParser
|
class ClassParser
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Indention.
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
const INDENT = 4;
|
const INDENT = 4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is final?
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private $isFinal = false;
|
private $isFinal = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is abstract?
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private $isAbstract = false;
|
private $isAbstract = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private $type = ClassType::_CLASS;
|
private $type = ClassType::_CLASS;
|
||||||
|
|
||||||
private $extends = null;
|
/**
|
||||||
|
* Extends.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
private $extends = '';
|
||||||
|
|
||||||
private $namespace = null;
|
/**
|
||||||
|
* Namespace.
|
||||||
|
*
|
||||||
|
* @var null|string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
private $namespace = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Includes.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private $includes = [];
|
private $includes = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requires.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private $requires = [];
|
private $requires = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uses.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private $use = [];
|
private $use = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private $name = '';
|
private $name = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private $implements = [];
|
private $implements = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Traits.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private $traits = [];
|
private $traits = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Members.
|
||||||
|
*
|
||||||
|
* @var MemberParser[]
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private $members = [];
|
private $members = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Functions.
|
||||||
|
*
|
||||||
|
* @var FunctionParser[]
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private $functions = [];
|
private $functions = [];
|
||||||
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saving class to file.
|
* Saving class to file.
|
||||||
*
|
*
|
||||||
|
|
@ -74,68 +154,188 @@ class ClassParser
|
||||||
*/
|
*/
|
||||||
public function createFile(string $path)
|
public function createFile(string $path)
|
||||||
{
|
{
|
||||||
|
// todo: implement
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set final.
|
||||||
|
*
|
||||||
|
* @param bool $final Is final
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function setFinal(bool $final)
|
public function setFinal(bool $final)
|
||||||
{
|
{
|
||||||
$this->isFinal = $final;
|
$this->isFinal = $final;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is final?
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function isFinal() : bool
|
public function isFinal() : bool
|
||||||
{
|
{
|
||||||
return $this->isFinal;
|
return $this->isFinal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set abstract.
|
||||||
|
*
|
||||||
|
* @param bool $abstract Is abstract
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function setAbstract(bool $abstract)
|
public function setAbstract(bool $abstract)
|
||||||
{
|
{
|
||||||
$this->isAbstract = $abstract;
|
$this->isAbstract = $abstract;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is abstract?
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function isAbstract() : bool
|
public function isAbstract() : bool
|
||||||
{
|
{
|
||||||
return $this->isAbstract;
|
return $this->isAbstract;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set type.
|
||||||
|
*
|
||||||
|
* Available types are ClassType::
|
||||||
|
*
|
||||||
|
* @param string $type Set type
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function setType(string $type)
|
public function setType(string $type)
|
||||||
{
|
{
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get type.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function getType() : string
|
public function getType() : string
|
||||||
{
|
{
|
||||||
return $this->type;
|
return $this->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set extends.
|
||||||
|
*
|
||||||
|
* @param string $extends Extended class
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function setExtends(string $extends)
|
public function setExtends(string $extends)
|
||||||
{
|
{
|
||||||
$this->extends = $extends;
|
$this->extends = $extends;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get extends.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function getExtends() : string
|
public function getExtends() : string
|
||||||
{
|
{
|
||||||
return $this->extends;
|
return $this->extends;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove extends.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function removeExtends()
|
public function removeExtends()
|
||||||
{
|
{
|
||||||
$this->extends = null;
|
$this->extends = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set namespace.
|
||||||
|
*
|
||||||
|
* @param string $namespace Namespace
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function setNamespace(string $namespace)
|
public function setNamespace(string $namespace)
|
||||||
{
|
{
|
||||||
$this->namespace = $namespace;
|
$this->namespace = $namespace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get namespace.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function getNamespace() : string
|
public function getNamespace() : string
|
||||||
{
|
{
|
||||||
return $this->namespace;
|
return $this->namespace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove namespace.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function removeNamespace()
|
public function removeNamespace()
|
||||||
{
|
{
|
||||||
$this->namespace = null;
|
$this->namespace = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add use.
|
||||||
|
*
|
||||||
|
* @param string $namespace Namespace to use
|
||||||
|
* @param string $as Namespace as
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function addUse(string $namespace, string $as = null)
|
public function addUse(string $namespace, string $as = null)
|
||||||
{
|
{
|
||||||
if (isset($as)) {
|
if (isset($as)) {
|
||||||
|
|
@ -145,6 +345,16 @@ class ClassParser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove use.
|
||||||
|
*
|
||||||
|
* @param string $id Namespace numerical id or 'as' if used.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function removeUse($id) : bool
|
public function removeUse($id) : bool
|
||||||
{
|
{
|
||||||
if (isset($this->use[$id])) {
|
if (isset($this->use[$id])) {
|
||||||
|
|
@ -156,16 +366,44 @@ class ClassParser
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set name.
|
||||||
|
*
|
||||||
|
* @param string $name Class name
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function setName(string $name)
|
public function setName(string $name)
|
||||||
{
|
{
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get name.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function getName() : string
|
public function getName() : string
|
||||||
{
|
{
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add implements.
|
||||||
|
*
|
||||||
|
* @param string $implements Implement
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function addImplements(string $implements)
|
public function addImplements(string $implements)
|
||||||
{
|
{
|
||||||
$this->implements[] = $implements;
|
$this->implements[] = $implements;
|
||||||
|
|
@ -173,6 +411,16 @@ class ClassParser
|
||||||
array_unique($this->implements);
|
array_unique($this->implements);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add include.
|
||||||
|
*
|
||||||
|
* @param string $include Include
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function addInclude(string $include)
|
public function addInclude(string $include)
|
||||||
{
|
{
|
||||||
$this->includes[] = $include;
|
$this->includes[] = $include;
|
||||||
|
|
@ -180,6 +428,16 @@ class ClassParser
|
||||||
array_unique($this->includes);
|
array_unique($this->includes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add $require.
|
||||||
|
*
|
||||||
|
* @param string $require Require
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function addRequire(string $require)
|
public function addRequire(string $require)
|
||||||
{
|
{
|
||||||
$this->requires[] = $require;
|
$this->requires[] = $require;
|
||||||
|
|
@ -187,6 +445,17 @@ class ClassParser
|
||||||
array_unique($this->requires);
|
array_unique($this->requires);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add trait.
|
||||||
|
*
|
||||||
|
* @param string $trait Trait to use
|
||||||
|
* @param string $as Trait as
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function addTrait(string $trait, string $as = null)
|
public function addTrait(string $trait, string $as = null)
|
||||||
{
|
{
|
||||||
if (isset($as)) {
|
if (isset($as)) {
|
||||||
|
|
@ -196,11 +465,52 @@ class ClassParser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove trait.
|
||||||
|
*
|
||||||
|
* @param string $id Namespace numerical id or 'as' if used.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function removeTrait($id) : bool
|
||||||
|
{
|
||||||
|
if (isset($this->traits[$id])) {
|
||||||
|
unset($this->traits[$id]);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add member.
|
||||||
|
*
|
||||||
|
* @param MemberParser $member Member
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function addMember(MemberParser $member)
|
public function addMember(MemberParser $member)
|
||||||
{
|
{
|
||||||
$this->members[$member->getName()] = $member;
|
$this->members[$member->getName()] = $member;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove member by name.
|
||||||
|
*
|
||||||
|
* @param string $name Member name
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function removeMember(string $name) : bool
|
public function removeMember(string $name) : bool
|
||||||
{
|
{
|
||||||
if (isset($this->members[$name])) {
|
if (isset($this->members[$name])) {
|
||||||
|
|
@ -212,16 +522,46 @@ class ClassParser
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get member by name.
|
||||||
|
*
|
||||||
|
* @param string $name Member name
|
||||||
|
*
|
||||||
|
* @return MemberParser
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function getMember(string $name) : MemberParser
|
public function getMember(string $name) : MemberParser
|
||||||
{
|
{
|
||||||
return $this->members[$name] ?? new MemberParser();
|
return $this->members[$name] ?? new MemberParser();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add function.
|
||||||
|
*
|
||||||
|
* @param FunctionParser $function Function
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function addFunction(FunctionParser $function)
|
public function addFunction(FunctionParser $function)
|
||||||
{
|
{
|
||||||
$this->functions[$function->getName()] = $function;
|
$this->functions[$function->getName()] = $function;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove function by name.
|
||||||
|
*
|
||||||
|
* @param string $name Function name
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function removeFunction(string $name) : bool
|
public function removeFunction(string $name) : bool
|
||||||
{
|
{
|
||||||
if (isset($this->functions[$name])) {
|
if (isset($this->functions[$name])) {
|
||||||
|
|
@ -233,12 +573,30 @@ class ClassParser
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get function by name.
|
||||||
|
*
|
||||||
|
* @param string $name Function name
|
||||||
|
*
|
||||||
|
* @return FunctionParser
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function getFunction(string $name) : FunctionParser
|
public function getFunction(string $name) : FunctionParser
|
||||||
{
|
{
|
||||||
return $this->functions[$name] ?? new FunctionParser();
|
return $this->functions[$name] ?? new FunctionParser();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function parse() : string
|
/**
|
||||||
|
* Serialize class.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function serialize() : string
|
||||||
{
|
{
|
||||||
$class = '';
|
$class = '';
|
||||||
|
|
||||||
|
|
@ -258,8 +616,8 @@ class ClassParser
|
||||||
$class .= PHP_EOL;
|
$class .= PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($namespace)) {
|
if (!empty($this->namespace)) {
|
||||||
$class = $namespace . ';' . PHP_EOL . PHP_EOL;
|
$class = $this->namespace . ';' . PHP_EOL . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($this->use)) {
|
if (!empty($this->use)) {
|
||||||
|
|
@ -280,7 +638,7 @@ class ClassParser
|
||||||
|
|
||||||
$class .= $this->type . ' ' . $this->name . ' ';
|
$class .= $this->type . ' ' . $this->name . ' ';
|
||||||
|
|
||||||
if (isset($this->extends)) {
|
if (!empty($this->extends)) {
|
||||||
$class .= 'extends ' . $this->extends . ' ';
|
$class .= 'extends ' . $this->extends . ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -299,11 +657,11 @@ class ClassParser
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->members as $name => $member) {
|
foreach ($this->members as $name => $member) {
|
||||||
$class .= $member->parse() . PHP_EOL . PHP_EOL;
|
$class .= $member->serialize() . PHP_EOL . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->functions as $name => $function) {
|
foreach ($this->functions as $name => $function) {
|
||||||
$class .= $function->parse() . PHP_EOL . PHP_EOL;
|
$class .= $function->serialize() . PHP_EOL . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
$class .= '}';
|
$class .= '}';
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ namespace phpOMS\Utils\Parser\Php;
|
||||||
/**
|
/**
|
||||||
* Member parser class.
|
* Member parser class.
|
||||||
*
|
*
|
||||||
* Parsing/serializing variables
|
* Parsing/serializing functions
|
||||||
*
|
*
|
||||||
* @category Framework
|
* @category Framework
|
||||||
* @package phpOMS\Utils\Parser
|
* @package phpOMS\Utils\Parser
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ namespace phpOMS\Utils\Parser\Php;
|
||||||
/**
|
/**
|
||||||
* Member parser class.
|
* Member parser class.
|
||||||
*
|
*
|
||||||
* Parsing/serializing variables
|
* Parsing/serializing member variables
|
||||||
*
|
*
|
||||||
* @category Framework
|
* @category Framework
|
||||||
* @package phpOMS\Utils\Parser
|
* @package phpOMS\Utils\Parser
|
||||||
|
|
@ -30,36 +30,112 @@ namespace phpOMS\Utils\Parser\Php;
|
||||||
*/
|
*/
|
||||||
class MemberParser
|
class MemberParser
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Member name.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private $name = '';
|
private $name = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Member visibility.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private $visibility = Visibility::_PUBLIC;
|
private $visibility = Visibility::_PUBLIC;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is static.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private $isStatic = false;
|
private $isStatic = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is const.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private $isConst = false;
|
private $isConst = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default value.
|
||||||
|
*
|
||||||
|
* @var mixed
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private $default = null;
|
private $default = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set member name.
|
||||||
|
*
|
||||||
|
* @param string $name Member name
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function setName(string $name)
|
public function setName(string $name)
|
||||||
{
|
{
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get member name.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function getName() : string
|
public function getName() : string
|
||||||
{
|
{
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set visibility.
|
||||||
|
*
|
||||||
|
* @param string $visibility Member visibility
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function setVisibility(string $visibility)
|
public function setVisibility(string $visibility)
|
||||||
{
|
{
|
||||||
$this->visibility = $visibility;
|
$this->visibility = $visibility;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get visibility.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function getVisibility() : string
|
public function getVisibility() : string
|
||||||
{
|
{
|
||||||
return $this->visibility;
|
return $this->visibility;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set static.
|
||||||
|
*
|
||||||
|
* @param bool $static Is static
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function setStatic(bool $static)
|
public function setStatic(bool $static)
|
||||||
{
|
{
|
||||||
$this->isStatic = $static;
|
$this->isStatic = $static;
|
||||||
|
|
@ -69,11 +145,29 @@ class MemberParser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is static?
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function isStatic() : bool
|
public function isStatic() : bool
|
||||||
{
|
{
|
||||||
return $this->isStatic;
|
return $this->isStatic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set const.
|
||||||
|
*
|
||||||
|
* @param bool $const Is const
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function setConst(bool $const)
|
public function setConst(bool $const)
|
||||||
{
|
{
|
||||||
$this->isConst = $const;
|
$this->isConst = $const;
|
||||||
|
|
@ -83,12 +177,43 @@ class MemberParser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is const?
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function isConst() : bool
|
||||||
|
{
|
||||||
|
return $this->isConst;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set default value.
|
||||||
|
*
|
||||||
|
* @param string $default
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
public function setDefault($default)
|
public function setDefault($default)
|
||||||
{
|
{
|
||||||
$this->default = $default;
|
$this->default = $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function parse() : string
|
/**
|
||||||
|
* Serialize member.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function serialize() : string
|
||||||
{
|
{
|
||||||
$member = '';
|
$member = '';
|
||||||
$member .= str_repeat(' ', ClassParser::INDENT);
|
$member .= str_repeat(' ', ClassParser::INDENT);
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,9 @@ namespace phpOMS\Utils\Parser\Php;
|
||||||
use phpOMS\Datatypes\Enum;
|
use phpOMS\Datatypes\Enum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database type enum.
|
* Visibility type enum.
|
||||||
*
|
*
|
||||||
* Database types that are supported by the application
|
* Visibility for member variables and functions
|
||||||
*
|
*
|
||||||
* @category Framework
|
* @category Framework
|
||||||
* @package phpOMS\Utils\Parser
|
* @package phpOMS\Utils\Parser
|
||||||
|
|
@ -32,6 +32,7 @@ use phpOMS\Datatypes\Enum;
|
||||||
*/
|
*/
|
||||||
abstract class Visibility extends Enum
|
abstract class Visibility extends Enum
|
||||||
{
|
{
|
||||||
|
const _NONE = '';
|
||||||
const _PUBLIC = 'public';
|
const _PUBLIC = 'public';
|
||||||
const _PRIVATE = 'private';
|
const _PRIVATE = 'private';
|
||||||
const _PROTECTED = 'protected';
|
const _PROTECTED = 'protected';
|
||||||
|
|
|
||||||
|
|
@ -26,47 +26,27 @@ namespace phpOMS\Utils\TaskSchedule;
|
||||||
* @link http://orange-management.com
|
* @link http://orange-management.com
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
class Cron implements ScheduleInterface
|
class Cron extends SchedulerAbstract
|
||||||
{
|
{
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function add(TaskInterface $task)
|
|
||||||
{
|
|
||||||
// TODO: Implement add() method.
|
|
||||||
}
|
|
||||||
|
|
||||||
public function remove($id)
|
|
||||||
{
|
|
||||||
// TODO: Implement remove() method.
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get(string $id)
|
|
||||||
{
|
|
||||||
// TODO: Implement get() method.
|
|
||||||
}
|
|
||||||
|
|
||||||
public function list()
|
|
||||||
{
|
|
||||||
$output = shell_exec('crontab -l');
|
|
||||||
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function set(TaskInterface $task)
|
|
||||||
{
|
|
||||||
// TODO: Implement set() method.
|
|
||||||
}
|
|
||||||
|
|
||||||
public function save()
|
public function save()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run(string $cmd)
|
/**
|
||||||
|
* Run command
|
||||||
|
*
|
||||||
|
* @param string $cmd Command to run
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn
|
||||||
|
*/
|
||||||
|
public function run(string $cmd) : array
|
||||||
{
|
{
|
||||||
// TODO: Implement run() method.
|
// TODO: Implement run() method.
|
||||||
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,6 @@ namespace phpOMS\Utils\TaskSchedule;
|
||||||
*/
|
*/
|
||||||
class Schedule extends TaskAbstract
|
class Schedule extends TaskAbstract
|
||||||
{
|
{
|
||||||
private $name = '';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* Orange Management
|
|
||||||
*
|
|
||||||
* PHP Version 7.0
|
|
||||||
*
|
|
||||||
* @category TBD
|
|
||||||
* @package TBD
|
|
||||||
* @author OMS Development Team <dev@oms.com>
|
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
|
||||||
* @copyright 2013 Dennis Eichhorn
|
|
||||||
* @license OMS License 1.0
|
|
||||||
* @version 1.0.0
|
|
||||||
* @link http://orange-management.com
|
|
||||||
*/
|
|
||||||
namespace phpOMS\Utils\TaskSchedule;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Schedule Interface.
|
|
||||||
*
|
|
||||||
* @category Framework
|
|
||||||
* @package phpOMS\Utils\TaskSchedule
|
|
||||||
* @author OMS Development Team <dev@oms.com>
|
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
|
||||||
* @license OMS License 1.0
|
|
||||||
* @link http://orange-management.com
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
interface ScheduleInterface
|
|
||||||
{
|
|
||||||
public function add(TaskInterface $task);
|
|
||||||
|
|
||||||
public function remove($id);
|
|
||||||
|
|
||||||
public function get(string $id);
|
|
||||||
|
|
||||||
public function list();
|
|
||||||
|
|
||||||
public function set(TaskInterface $task);
|
|
||||||
|
|
||||||
public function save();
|
|
||||||
|
|
||||||
public function run(string $cmd);
|
|
||||||
}
|
|
||||||
127
Utils/TaskSchedule/SchedulerAbstract.php
Normal file
127
Utils/TaskSchedule/SchedulerAbstract.php
Normal file
|
|
@ -0,0 +1,127 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.0
|
||||||
|
*
|
||||||
|
* @category TBD
|
||||||
|
* @package TBD
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
* @copyright 2013 Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link http://orange-management.com
|
||||||
|
*/
|
||||||
|
namespace phpOMS\Utils\TaskSchedule;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scheduler abstract.
|
||||||
|
*
|
||||||
|
* @category Framework
|
||||||
|
* @package phpOMS\Utils\TaskSchedule
|
||||||
|
* @author OMS Development Team <dev@oms.com>
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @link http://orange-management.com
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
abstract class SchedulerAbstract
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* tasks.
|
||||||
|
*
|
||||||
|
* @var TaskAbstract[]
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected $tasks = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add task
|
||||||
|
*
|
||||||
|
* @param TaskAbstract $task Task to add
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn
|
||||||
|
*/
|
||||||
|
public function add(TaskAbstract $task)
|
||||||
|
{
|
||||||
|
$this->tasks[$task->getId()] = $task;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove task
|
||||||
|
*
|
||||||
|
* @param mixed $id Task id
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn
|
||||||
|
*/
|
||||||
|
public function remove(string $id) : bool
|
||||||
|
{
|
||||||
|
if (isset($this->tasks[$id])) {
|
||||||
|
unset($this->tasks[$id]);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get task
|
||||||
|
*
|
||||||
|
* @param mixed $id Task id
|
||||||
|
*
|
||||||
|
* @return TaskAbstract|null
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn
|
||||||
|
*/
|
||||||
|
public function get(string $id)
|
||||||
|
{
|
||||||
|
return $this->tasks[$id] ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all tasks
|
||||||
|
*
|
||||||
|
* @return TaskAbstract[]
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn
|
||||||
|
*/
|
||||||
|
public function list() : array
|
||||||
|
{
|
||||||
|
return $this->tasks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set task
|
||||||
|
*
|
||||||
|
* @param TaskAbstract $task Task to edit
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn
|
||||||
|
*/
|
||||||
|
public function set(TaskAbstract $task)
|
||||||
|
{
|
||||||
|
$this->tasks[$task->getId()] = $task;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save tasks
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn
|
||||||
|
*/
|
||||||
|
abstract public function save();
|
||||||
|
}
|
||||||
|
|
@ -28,6 +28,14 @@ namespace phpOMS\Utils\TaskSchedule;
|
||||||
*/
|
*/
|
||||||
abstract class TaskAbstract
|
abstract class TaskAbstract
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Id.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected $id = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interval.
|
* Interval.
|
||||||
*
|
*
|
||||||
|
|
@ -44,6 +52,19 @@ abstract class TaskAbstract
|
||||||
*/
|
*/
|
||||||
protected $command = '';
|
protected $command = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get id.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function getId() : string
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set interval.
|
* Set interval.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -26,45 +26,27 @@ namespace phpOMS\Utils\TaskSchedule;
|
||||||
* @link http://orange-management.com
|
* @link http://orange-management.com
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
class TaskScheduler implements ScheduleInterface
|
class TaskScheduler extends SchedulerAbstract
|
||||||
{
|
{
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function add(TaskInterface $task)
|
|
||||||
{
|
|
||||||
// TODO: Implement add() method.
|
|
||||||
}
|
|
||||||
|
|
||||||
public function remove($id)
|
|
||||||
{
|
|
||||||
// TODO: Implement remove() method.
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get(string $id)
|
|
||||||
{
|
|
||||||
// TODO: Implement get() method.
|
|
||||||
}
|
|
||||||
|
|
||||||
public function list()
|
|
||||||
{
|
|
||||||
// TODO: Implement list() method.
|
|
||||||
}
|
|
||||||
|
|
||||||
public function set(TaskInterface $task)
|
|
||||||
{
|
|
||||||
// TODO: Implement set() method.
|
|
||||||
}
|
|
||||||
|
|
||||||
public function save()
|
public function save()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run(string $cmd)
|
/**
|
||||||
|
* Run command
|
||||||
|
*
|
||||||
|
* @param string $cmd Command to run
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn
|
||||||
|
*/
|
||||||
|
public function run(string $cmd) : array
|
||||||
{
|
{
|
||||||
// TODO: Implement run() method.
|
// TODO: Implement run() method.
|
||||||
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user