mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-14 15:38: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\Localization;
|
||||||
use phpOMS\Localization\NullLocalization;
|
use phpOMS\Localization\NullLocalization;
|
||||||
|
use phpOMS\Validation\Base\Email;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Account manager class.
|
* Account manager class.
|
||||||
|
|
@ -98,6 +99,14 @@ class Account
|
||||||
*/
|
*/
|
||||||
protected $lastActive = null;
|
protected $lastActive = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Last activity.
|
||||||
|
*
|
||||||
|
* @var \DateTime
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected $created = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Permissions.
|
* Permissions.
|
||||||
*
|
*
|
||||||
|
|
@ -284,6 +293,19 @@ class Account
|
||||||
return $this->lastActive ?? new \DateTime('NOW');
|
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.
|
* Set name1.
|
||||||
*
|
*
|
||||||
|
|
@ -341,6 +363,10 @@ class Account
|
||||||
*/
|
*/
|
||||||
public function setEmail(\string $email)
|
public function setEmail(\string $email)
|
||||||
{
|
{
|
||||||
|
if(!Email::isValid($email)) {
|
||||||
|
throw new \InvalidArgumentException();
|
||||||
|
}
|
||||||
|
|
||||||
$this->email = $email;
|
$this->email = $email;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -356,6 +382,10 @@ class Account
|
||||||
*/
|
*/
|
||||||
public function setStatus(\int $status)
|
public function setStatus(\int $status)
|
||||||
{
|
{
|
||||||
|
if(!AccountStatus::isValidValue($status)) {
|
||||||
|
throw new \InvalidArgumentException();
|
||||||
|
}
|
||||||
|
|
||||||
$this->status = $status;
|
$this->status = $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -371,6 +401,10 @@ class Account
|
||||||
*/
|
*/
|
||||||
public function setType(\int $type)
|
public function setType(\int $type)
|
||||||
{
|
{
|
||||||
|
if(!AccountType::isValidValue($type)) {
|
||||||
|
throw new \InvalidArgumentException();
|
||||||
|
}
|
||||||
|
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,14 +77,6 @@ class Group
|
||||||
*/
|
*/
|
||||||
protected $permissions = [];
|
protected $permissions = [];
|
||||||
|
|
||||||
/**
|
|
||||||
* Multition cache.
|
|
||||||
*
|
|
||||||
* @var \Model\Account[]
|
|
||||||
* @since 1.0.0
|
|
||||||
*/
|
|
||||||
private static $instances = [];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
|
|
@ -96,35 +88,20 @@ class Group
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Multition constructor.
|
* Get group id.
|
||||||
*
|
|
||||||
* @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.
|
|
||||||
*
|
*
|
||||||
* @return \int
|
* @return \int
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
*/
|
*/
|
||||||
public function getId()
|
public function getId() : \int
|
||||||
{
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get account name.
|
* Get group name.
|
||||||
*
|
*
|
||||||
* @return \string
|
* @return \string
|
||||||
*
|
*
|
||||||
|
|
@ -149,4 +126,30 @@ class Group
|
||||||
return $this->description;
|
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
|
* @version 1.0.0
|
||||||
* @link http://orange-management.com
|
* @link http://orange-management.com
|
||||||
*/
|
*/
|
||||||
namespace phpOMS\Validation;
|
namespace phpOMS\Validation\Base;
|
||||||
|
|
||||||
|
|
||||||
|
use phpOMS\Validation\ValidatorAbstract;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validator abstract.
|
* Validator abstract.
|
||||||
|
|
@ -28,7 +28,7 @@ namespace phpOMS\Validation;
|
||||||
* @link http://orange-management.com
|
* @link http://orange-management.com
|
||||||
* @since 1.0.0
|
* @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
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
private function __construct()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@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