mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 09:48:40 +00:00
Fixes during tests
This commit is contained in:
parent
5405c6e1ea
commit
e5610f01c5
|
|
@ -17,6 +17,7 @@ namespace phpOMS\Account;
|
|||
|
||||
use phpOMS\Localization\Localization;
|
||||
use phpOMS\Localization\NullLocalization;
|
||||
use phpOMS\Validation\Base\Email;
|
||||
|
||||
/**
|
||||
* Account manager class.
|
||||
|
|
@ -98,6 +99,14 @@ class Account
|
|||
*/
|
||||
protected $lastActive = null;
|
||||
|
||||
/**
|
||||
* Last activity.
|
||||
*
|
||||
* @var \DateTime
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected $created = null;
|
||||
|
||||
/**
|
||||
* Permissions.
|
||||
*
|
||||
|
|
@ -284,6 +293,19 @@ class Account
|
|||
return $this->lastActive ?? new \DateTime('NOW');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get last activity.
|
||||
*
|
||||
* @return \DateTime
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function getCreated() : \DateTime
|
||||
{
|
||||
return $this->created ?? new \DateTime('NOW');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name1.
|
||||
*
|
||||
|
|
@ -341,6 +363,10 @@ class Account
|
|||
*/
|
||||
public function setEmail(\string $email)
|
||||
{
|
||||
if(!Email::isValid($email)) {
|
||||
throw new \InvalidArgumentException();
|
||||
}
|
||||
|
||||
$this->email = $email;
|
||||
}
|
||||
|
||||
|
|
@ -356,6 +382,10 @@ class Account
|
|||
*/
|
||||
public function setStatus(\int $status)
|
||||
{
|
||||
if(!AccountStatus::isValidValue($status)) {
|
||||
throw new \InvalidArgumentException();
|
||||
}
|
||||
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
|
|
@ -371,6 +401,10 @@ class Account
|
|||
*/
|
||||
public function setType(\int $type)
|
||||
{
|
||||
if(!AccountType::isValidValue($type)) {
|
||||
throw new \InvalidArgumentException();
|
||||
}
|
||||
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,14 +77,6 @@ class Group
|
|||
*/
|
||||
protected $permissions = [];
|
||||
|
||||
/**
|
||||
* Multition cache.
|
||||
*
|
||||
* @var \Model\Account[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private static $instances = [];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
|
@ -96,35 +88,20 @@ class Group
|
|||
}
|
||||
|
||||
/**
|
||||
* Multition constructor.
|
||||
*
|
||||
* @param \int $id Account id
|
||||
*
|
||||
* @return \phpOMS\Account\Group
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public static function getInstance($id)
|
||||
{
|
||||
return self::$instances[$id] = self::$instances[$id] ?? new self();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get account id.
|
||||
* Get group id.
|
||||
*
|
||||
* @return \int
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function getId()
|
||||
public function getId() : \int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get account name.
|
||||
* Get group name.
|
||||
*
|
||||
* @return \string
|
||||
*
|
||||
|
|
@ -149,4 +126,30 @@ class Group
|
|||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set group name.
|
||||
*
|
||||
* @param \string $name Group name
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function setName(\string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set group description.
|
||||
*
|
||||
* @param \string $description Group description
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function setDescription(\string $description)
|
||||
{
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@
|
|||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
namespace phpOMS\Validation;
|
||||
|
||||
namespace phpOMS\Validation\Base;
|
||||
|
||||
use phpOMS\Validation\ValidatorAbstract;
|
||||
|
||||
/**
|
||||
* Validator abstract.
|
||||
|
|
@ -28,7 +28,7 @@ namespace phpOMS\Validation;
|
|||
* @link http://orange-management.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
abstract class Email extends ValidatorAbstract
|
||||
class Email extends ValidatorAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
|
|
@ -37,15 +37,15 @@ abstract class Email extends ValidatorAbstract
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function __construct()
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function isValid($value)
|
||||
public static function isValid(\string $value) : \bool
|
||||
{
|
||||
return filter_var($value, FILTER_VALIDATE_EMAIL);
|
||||
return filter_var($value, FILTER_VALIDATE_EMAIL) === false ? false : true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user