mirror of
https://github.com/Karaka-Management/oms-Tasks.git
synced 2026-01-11 15:38:40 +00:00
phpstan, phpcs, phpunit fixes
This commit is contained in:
parent
6e14ae6ab0
commit
6faa514311
|
|
@ -189,11 +189,6 @@
|
|||
"type": "TINYINT(1)",
|
||||
"null": false
|
||||
},
|
||||
"task_attr_value_valuetype": {
|
||||
"name": "task_attr_value_valuetype",
|
||||
"type": "INT(11)",
|
||||
"null": false
|
||||
},
|
||||
"task_attr_value_valueStr": {
|
||||
"name": "task_attr_value_valueStr",
|
||||
"type": "VARCHAR(255)",
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ use Modules\Tasks\Models\TaskElementMapper;
|
|||
use Modules\Tasks\Models\TaskMapper;
|
||||
use Modules\Tasks\Models\TaskStatus;
|
||||
use Modules\Tasks\Models\TaskType;
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
use phpOMS\Message\Http\HttpResponse;
|
||||
use phpOMS\Message\Http\RequestStatusCode;
|
||||
use phpOMS\Message\NotificationLevel;
|
||||
|
|
@ -788,18 +790,18 @@ final class ApiController extends Controller
|
|||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return TaskAttributeTypeL11n
|
||||
* @return BaseStringL11n
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createTaskAttributeTypeL11nFromRequest(RequestAbstract $request) : TaskAttributeTypeL11n
|
||||
private function createTaskAttributeTypeL11nFromRequest(RequestAbstract $request) : BaseStringL11n
|
||||
{
|
||||
$attrL11n = new TaskAttributeTypeL11n();
|
||||
$attrL11n->type = (int) ($request->getData('type') ?? 0);
|
||||
$attrL11n = new BaseStringL11n();
|
||||
$attrL11n->ref = (int) ($request->getData('type') ?? 0);
|
||||
$attrL11n->setLanguage((string) (
|
||||
$request->getData('language') ?? $request->getLanguage()
|
||||
));
|
||||
$attrL11n->title = (string) ($request->getData('title') ?? '');
|
||||
$attrL11n->content = (string) ($request->getData('title') ?? '');
|
||||
|
||||
return $attrL11n;
|
||||
}
|
||||
|
|
@ -943,10 +945,14 @@ final class ApiController extends Controller
|
|||
*/
|
||||
private function createTaskAttributeValueFromRequest(RequestAbstract $request) : TaskAttributeValue
|
||||
{
|
||||
$type = (int) ($request->getData('attributetype') ?? 0);
|
||||
/** @var TaskAttributeType $type */
|
||||
$type = TaskAttributeTypeMapper::get()
|
||||
->where('id', (int) ($request->getData('type') ?? 0))
|
||||
->execute();
|
||||
|
||||
$attrValue = new TaskAttributeValue($type, $request->getData('value'));
|
||||
$attrValue = new TaskAttributeValue();
|
||||
$attrValue->isDefault = (bool) ($request->getData('default') ?? false);
|
||||
$attrValue->setValue($request->getData('value'), $type->datatype);
|
||||
|
||||
if ($request->getData('title') !== null) {
|
||||
$attrValue->setL11n($request->getData('title'), $request->getData('language') ?? ISO639x1Enum::_EN);
|
||||
|
|
@ -1008,18 +1014,18 @@ final class ApiController extends Controller
|
|||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return TaskAttributeValueL11n
|
||||
* @return BaseStringL11n
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createTaskAttributeValueL11nFromRequest(RequestAbstract $request) : TaskAttributeValueL11n
|
||||
private function createTaskAttributeValueL11nFromRequest(RequestAbstract $request) : BaseStringL11n
|
||||
{
|
||||
$attrL11n = new TaskAttributeValueL11n();
|
||||
$attrL11n->value = (int) ($request->getData('value') ?? 0);
|
||||
$attrL11n = new BaseStringL11n();
|
||||
$attrL11n->ref = (int) ($request->getData('value') ?? 0);
|
||||
$attrL11n->setLanguage((string) (
|
||||
$request->getData('language') ?? $request->getLanguage()
|
||||
));
|
||||
$attrL11n->title = (string) ($request->getData('title') ?? '');
|
||||
$attrL11n->content = (string) ($request->getData('title') ?? '');
|
||||
|
||||
return $attrL11n;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ final class AccountRelationMapper extends DataMapperFactory
|
|||
/**
|
||||
* Has one relation.
|
||||
*
|
||||
* @var array<string, array{mapper:string, external:string, by?:string, column?:string, conditional?:bool}>
|
||||
* @var array<string, array{mapper:class-string, external:string, by?:string, column?:string, conditional?:bool}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const OWNS_ONE = [
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ final class GroupRelationMapper extends DataMapperFactory
|
|||
/**
|
||||
* Has one relation.
|
||||
*
|
||||
* @var array<string, array{mapper:string, external:string, by?:string, column?:string, conditional?:bool}>
|
||||
* @var array<string, array{mapper:class-string, external:string, by?:string, column?:string, conditional?:bool}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const OWNS_ONE = [
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ class Task implements \JsonSerializable
|
|||
/**
|
||||
* Attributes.
|
||||
*
|
||||
* @var ItemAttribute[]
|
||||
* @var TaskAttribute[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private array $attributes = [];
|
||||
|
|
@ -613,13 +613,13 @@ class Task implements \JsonSerializable
|
|||
/**
|
||||
* Add attribute to item
|
||||
*
|
||||
* @param ItemAttribute $attribute Note
|
||||
* @param TaskAttribute $attribute Note
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function addAttribute(ItemAttribute $attribute) : void
|
||||
public function addAttribute(TaskAttribute $attribute) : void
|
||||
{
|
||||
$this->attributes[] = $attribute;
|
||||
}
|
||||
|
|
@ -627,7 +627,7 @@ class Task implements \JsonSerializable
|
|||
/**
|
||||
* Get attributes
|
||||
*
|
||||
* @return ItemAttribute[]
|
||||
* @return TaskAttribute[]
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
|
@ -662,11 +662,11 @@ class Task implements \JsonSerializable
|
|||
*
|
||||
* @param string $attrName Attribute name
|
||||
*
|
||||
* @return null|AttributeValue
|
||||
* @return null|TaskAttributeValue
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getAttribute(string $attrName) : ?AttributeValue
|
||||
public function getAttribute(string $attrName) : ?TaskAttributeValue
|
||||
{
|
||||
foreach ($this->attributes as $attribute) {
|
||||
if ($attribute->type->name === $attrName) {
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ final class TaskAttributeMapper extends DataMapperFactory
|
|||
/**
|
||||
* Has one relation.
|
||||
*
|
||||
* @var array<string, array{mapper:string, external:string, by?:string, column?:string, conditional?:bool}>
|
||||
* @var array<string, array{mapper:class-string, external:string, by?:string, column?:string, conditional?:bool}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const OWNS_ONE = [
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\Tasks\Models;
|
||||
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
|
||||
/**
|
||||
|
|
@ -62,12 +63,20 @@ class TaskAttributeType implements \JsonSerializable
|
|||
|
||||
public bool $isRequired = false;
|
||||
|
||||
/**
|
||||
* Datatype of the attribute
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $datatype = AttributeValueType::_STRING;
|
||||
|
||||
/**
|
||||
* Localization
|
||||
*
|
||||
* @var TaskAttributeTypeL11n
|
||||
* @var BaseStringL11n
|
||||
*/
|
||||
private string | TaskAttributeTypeL11n $l11n = '';
|
||||
private string | BaseStringL11n $l11n = '';
|
||||
|
||||
/**
|
||||
* Possible default attribute values
|
||||
|
|
@ -111,22 +120,23 @@ class TaskAttributeType implements \JsonSerializable
|
|||
/**
|
||||
* Set l11n
|
||||
*
|
||||
* @param string|TaskAttributeTypeL11n $l11n Tag article l11n
|
||||
* @param string $lang Language
|
||||
* @param string|BaseStringL11n $l11n Tag article l11n
|
||||
* @param string $lang Language
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setL11n(string | TaskAttributeTypeL11n $l11n, string $lang = ISO639x1Enum::_EN) : void
|
||||
public function setL11n(string | BaseStringL11n $l11n, string $lang = ISO639x1Enum::_EN) : void
|
||||
{
|
||||
if ($l11n instanceof TaskAttributeTypeL11n) {
|
||||
if ($l11n instanceof BaseStringL11n) {
|
||||
$this->l11n = $l11n;
|
||||
} elseif (isset($this->l11n) && $this->l11n instanceof TaskAttributeTypeL11n) {
|
||||
$this->l11n->title = $l11n;
|
||||
} elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) {
|
||||
$this->l11n->content = $l11n;
|
||||
$this->l11n->setLanguage($lang);
|
||||
} else {
|
||||
$this->l11n = new TaskAttributeTypeL11n();
|
||||
$this->l11n->title = $l11n;
|
||||
$this->l11n = new BaseStringL11n();
|
||||
$this->l11n->content = $l11n;
|
||||
$this->l11n->setLanguage($lang);
|
||||
}
|
||||
}
|
||||
|
|
@ -138,7 +148,11 @@ class TaskAttributeType implements \JsonSerializable
|
|||
*/
|
||||
public function getL11n() : string
|
||||
{
|
||||
return $this->l11n instanceof TaskAttributeTypeL11n ? $this->l11n->title : $this->l11n;
|
||||
if (!isset($this->l11n)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->l11n instanceof BaseStringL11n ? $this->l11n->content : $this->l11n;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ final class TaskAttributeTypeL11nMapper extends DataMapperFactory
|
|||
/**
|
||||
* Model to use by the mapper.
|
||||
*
|
||||
* @var string
|
||||
* @var class-string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const MODEL = BaseStringL11n::class;
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ final class TaskAttributeTypeMapper extends DataMapperFactory
|
|||
/**
|
||||
* Has many relation.
|
||||
*
|
||||
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const HAS_MANY = [
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ class TaskAttributeValue implements \JsonSerializable
|
|||
* Set l11n
|
||||
*
|
||||
* @param string|BaseStringL11n $l11n Tag article l11n
|
||||
* @param string $lang Language
|
||||
* @param string $lang Language
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
|
|
@ -135,11 +135,12 @@ class TaskAttributeValue implements \JsonSerializable
|
|||
if ($l11n instanceof BaseStringL11n) {
|
||||
$this->l11n = $l11n;
|
||||
} elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) {
|
||||
$this->l11n->content = $l11n;
|
||||
$this->l11n->content = $l11n;
|
||||
$this->l11n->setLanguage($lang);
|
||||
} else {
|
||||
$this->l11n = new BaseStringL11n();
|
||||
$this->l11n = new BaseStringL11n();
|
||||
$this->l11n->content = $l11n;
|
||||
$this->l11n->ref = $this->id;
|
||||
$this->l11n->ref = $this->id;
|
||||
$this->l11n->setLanguage($lang);
|
||||
}
|
||||
}
|
||||
|
|
@ -159,7 +160,7 @@ class TaskAttributeValue implements \JsonSerializable
|
|||
/**
|
||||
* Set value
|
||||
*
|
||||
* @param int|string|float|\DateTimeInterface $value Value
|
||||
* @param int|string|float $value Value
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
|
|
@ -177,7 +178,7 @@ class TaskAttributeValue implements \JsonSerializable
|
|||
} elseif ($datatype === AttributeValueType::_FLOAT) {
|
||||
$this->valueDec = (float) $value;
|
||||
} elseif ($datatype === AttributeValueType::_DATETIME) {
|
||||
$this->valueDat = new \DateTime($value);
|
||||
$this->valueDat = new \DateTime((string) $value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ declare(strict_types=1);
|
|||
namespace Modules\Tasks\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
|
||||
/**
|
||||
* Task mapper class.
|
||||
|
|
@ -58,7 +59,7 @@ final class TaskAttributeValueL11nMapper extends DataMapperFactory
|
|||
/**
|
||||
* Model to use by the mapper.
|
||||
*
|
||||
* @var string
|
||||
* @var class-string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const MODEL = BaseStringL11n::class;
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ final class TaskAttributeValueMapper extends DataMapperFactory
|
|||
/**
|
||||
* Has many relation.
|
||||
*
|
||||
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const HAS_MANY = [
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ final class TaskElementMapper extends DataMapperFactory
|
|||
/**
|
||||
* Has many relation.
|
||||
*
|
||||
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const HAS_MANY = [
|
||||
|
|
@ -76,7 +76,7 @@ final class TaskElementMapper extends DataMapperFactory
|
|||
/**
|
||||
* Belongs to.
|
||||
*
|
||||
* @var array<string, array{mapper:string, external:string, column?:string, by?:string}>
|
||||
* @var array<string, array{mapper:class-string, external:string, column?:string, by?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const BELONGS_TO = [
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ final class TaskMapper extends DataMapperFactory
|
|||
/**
|
||||
* Has many relation.
|
||||
*
|
||||
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const HAS_MANY = [
|
||||
|
|
@ -96,7 +96,7 @@ final class TaskMapper extends DataMapperFactory
|
|||
/**
|
||||
* Belongs to.
|
||||
*
|
||||
* @var array<string, array{mapper:string, external:string, column?:string, by?:string}>
|
||||
* @var array<string, array{mapper:class-string, external:string, column?:string, by?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const BELONGS_TO = [
|
||||
|
|
@ -109,7 +109,7 @@ final class TaskMapper extends DataMapperFactory
|
|||
/**
|
||||
* Has one relation.
|
||||
*
|
||||
* @var array<string, array{mapper:string, external:string, by?:string, column?:string, conditional?:bool}>
|
||||
* @var array<string, array{mapper:class-string, external:string, by?:string, column?:string, conditional?:bool}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const OWNS_ONE = [
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ final class TaskSeenMapper extends DataMapperFactory
|
|||
/**
|
||||
* Belongs to.
|
||||
*
|
||||
* @var array<string, array{mapper:string, external:string, column?:string, by?:string}>
|
||||
* @var array<string, array{mapper:class-string, external:string, column?:string, by?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const BELONGS_TO = [
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user