mirror of
https://github.com/Karaka-Management/oms-HumanResourceTimeRecording.git
synced 2026-01-24 09:48:41 +00:00
phpstan fixes
This commit is contained in:
parent
cc9ae17107
commit
cdf964b9f8
|
|
@ -36,8 +36,8 @@ $head = $this->getData('head');
|
|||
|
||||
--input-border: rgba(166, 135, 232, .4);
|
||||
--input-border-active: rgba(166, 135, 232, .7);
|
||||
--input-color: rgba(255, 255, 255, 0.7);
|
||||
--input-color-active: rgba(255, 255, 255, 0.7);
|
||||
--input-color: rgba(166, 135, 232, .6);
|
||||
--input-color-active: rgba(166, 135, 232, .8);
|
||||
|
||||
--input-icon-color: rgba(166, 135, 232, .6);
|
||||
--input-icon-color-active: rgba(166, 135, 232, 1);
|
||||
|
|
|
|||
|
|
@ -180,10 +180,12 @@ final class ApiController extends Controller
|
|||
|
||||
if ($element === null) {
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::ERROR, 'Session Element', 'You cannot create a session element for another person!', $element);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($element->getStatus() === ClockingStatus::END) {
|
||||
$session = SessionMapper::get($element->getSession()->getId());
|
||||
$session = SessionMapper::get($element->session->getId());
|
||||
$session->addSessionElement($element);
|
||||
SessionMapper::update($session);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\HumanResourceTimeRecording\Models;
|
||||
|
||||
use Modules\HumanResourceManagement\Models\Employee;
|
||||
use Modules\HumanResourceManagement\Models\NullEmployee;
|
||||
use phpOMS\Contract\ArrayableInterface;
|
||||
|
||||
/**
|
||||
|
|
@ -77,22 +79,22 @@ class Session implements \JsonSerializable, ArrayableInterface
|
|||
/**
|
||||
* Employee.
|
||||
*
|
||||
* @var int|Employee
|
||||
* @var Employee
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $employee = 0;
|
||||
private Employee $employee;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param int|Employee $employee Employee
|
||||
* @param Employee $employee Employee
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct($employee = 0)
|
||||
public function __construct(Employee $employee = null)
|
||||
{
|
||||
$this->start = new \DateTime('now');
|
||||
$this->employee = $employee;
|
||||
$this->employee = $employee ?? new NullEmployee();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -110,11 +112,11 @@ class Session implements \JsonSerializable, ArrayableInterface
|
|||
/**
|
||||
* Get employee.
|
||||
*
|
||||
* @return int|Employee
|
||||
* @return Employee
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getEmployee()
|
||||
public function getEmployee() : Employee
|
||||
{
|
||||
return $this->employee;
|
||||
}
|
||||
|
|
@ -122,13 +124,13 @@ class Session implements \JsonSerializable, ArrayableInterface
|
|||
/**
|
||||
* Add a session element to the session
|
||||
*
|
||||
* @param int|SessionElement $element Session element
|
||||
* @param SessionElement $element Session element
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function addSessionElement($element) : void
|
||||
public function addSessionElement(SessionElement $element) : void
|
||||
{
|
||||
if ($element->getStatus() === ClockingStatus::START) {
|
||||
foreach ($this->sessionElements as $e) {
|
||||
|
|
|
|||
|
|
@ -53,22 +53,22 @@ class SessionElement implements \JsonSerializable, ArrayableInterface
|
|||
/**
|
||||
* Session id this element belongs to
|
||||
*
|
||||
* @var int|Session
|
||||
* @var Session
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $session = 0;
|
||||
public Session $session;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param int $session Session id
|
||||
* @param Session $session Session id
|
||||
* @param null|\DateTime $dt DateTime of the session element
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct($session = 0, \DateTime $dt = null)
|
||||
public function __construct(Session $session = null, \DateTime $dt = null)
|
||||
{
|
||||
$this->session = $session;
|
||||
$this->session = $session ?? new NullSession();
|
||||
$this->dt = $dt ?? new \DateTime('now');
|
||||
}
|
||||
|
||||
|
|
@ -122,18 +122,6 @@ class SessionElement implements \JsonSerializable, ArrayableInterface
|
|||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get session this element is for
|
||||
*
|
||||
* @return int|Session
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getSession()
|
||||
{
|
||||
return $this->session;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
@ -143,7 +131,7 @@ class SessionElement implements \JsonSerializable, ArrayableInterface
|
|||
'id' => $this->id,
|
||||
'status' => $this->status,
|
||||
'dt' => $this->dt,
|
||||
'session' => \is_int($this->session) ? $this->session : $this->session->getId(),
|
||||
'session' => $this->session->getId(),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user