Skip to content

Commit

Permalink
fixing lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ridz1208 committed Nov 25, 2024
1 parent 254a993 commit 40ab6f7
Show file tree
Hide file tree
Showing 16 changed files with 39 additions and 27 deletions.
6 changes: 3 additions & 3 deletions modules/biobank/php/containercontroller.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,9 @@ class ContainerController
if ($container->getId()) {
$prevContainer = $this->dao->getInstanceFromId($container->getId());
if ($prevContainer) {
$stati = $this->dao->getStati();
$statusId = $prevContainer->getStatusId();
$statusLabel = $stati[$statusId ?? '']['label'];
// $stati = $this->dao->getStati();
// $statusId = $prevContainer->getStatusId();
// $statusLabel = $stati[$statusId ?? '']['label'];
// TODO: figure out what should not be changed if the
// container is dispensed.
}
Expand Down
4 changes: 2 additions & 2 deletions modules/biobank/php/containerdao.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,10 @@ class ContainerDAO extends \LORIS\Data\ProvisionerInstance
* @param Container $container The Container Object to be saved into the
* database.
*
* @return Container $container The Container Object that was saved to the
* @return ?Container $container The Container Object that was saved to the
database.
*/
public function createInstance(Container $container) : Container
public function createInstance(Container $container) : ?Container
{
// TODO: THIS IS DUPLICATED IN BOTH FUNCTIONS AND COULD PROBABLY BE
// DEALT WITH EITHER FRONT END OR SOMEWHERE ELSE.
Expand Down
2 changes: 1 addition & 1 deletion modules/biobank/php/containerendpoint.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ContainerEndpoint extends \NDB_Page implements RequestHandlerInterface
* This function can be overridden in a module's page to load the necessary
* resources to check the permissions of a user.
*
* @param User $user The user to load the resources for
* @param \User $user The user to load the resources for
* @param ServerRequestInterface $request The PSR15 Request being handled
*
* @return void
Expand Down
2 changes: 1 addition & 1 deletion modules/biobank/php/labelendpoint.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class LabelEndpoint implements RequestHandlerInterface
* This function can be overridden in a module's page to load the necessary
* resources to check the permissions of a user.
*
* @param User $user The user to load the resources for
* @param \User $user The user to load the resources for
* @param ServerRequestInterface $request The PSR15 Request being handled
*
* @return void
Expand Down
6 changes: 3 additions & 3 deletions modules/biobank/php/module.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ class Module extends \Module
return $resp;
}

$this->lorisinstance = $request->getAttribute("loris");
$pagename = $this->getName();
$path = trim($request->getURI()->getPath(), "/");
$this->loris = $request->getAttribute("loris");
$pagename = $this->getName();
$path = trim($request->getURI()->getPath(), "/");
if ($path == 'optionsendpoint'
|| $path == 'poolendpoint'
|| $path == 'containerendpoint'
Expand Down
2 changes: 1 addition & 1 deletion modules/biobank/php/optionsendpoint.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class OptionsEndpoint extends \NDB_Page implements RequestHandlerInterface
* This function can be overridden in a module's page to load the necessary
* resources to check the permissions of a user.
*
* @param User $user The user to load the resources for
* @param \User $user The user to load the resources for
* @param ServerRequestInterface $request The PSR15 Request being handled
*
* @return void
Expand Down
2 changes: 1 addition & 1 deletion modules/biobank/php/pool.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class Pool implements
/**
* Sets the Candidate PSCID of the pool
*
* @param int $candidatePSCID Candidate ID of the pool
* @param string $candidatePSCID Candidate ID of the pool
*
* @return void
*/
Expand Down
4 changes: 2 additions & 2 deletions modules/biobank/php/poolcontroller.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ class PoolController
*
* @param array $poolArray pool array to be created.
*
* @return string a json encoded string of all permissable Pool Objects.
* @return Pool $pool The created Pool.
*/
public function createInstance(array $poolArray)
public function createInstance(array $poolArray) : Pool
{
$this->_validatePermission('create');
$pool = (new Pool())->fromArray($poolArray);
Expand Down
2 changes: 1 addition & 1 deletion modules/biobank/php/poolendpoint.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class PoolEndpoint extends \NDB_Page implements RequestHandlerInterface
* This function can be overridden in a module's page to load the necessary
* resources to check the permissions of a user.
*
* @param User $user The user to load the resources for
* @param \User $user The user to load the resources for
* @param ServerRequestInterface $request The PSR15 Request being handled
*
* @return void
Expand Down
2 changes: 1 addition & 1 deletion modules/biobank/php/shipment.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ class Shipment implements
case 'received':
return [$this->getDestinationCenterId()];
case 'shipped':
return [$this->getOriginCenterId(), $this->getDestinationCenterId];
return [$this->getOriginCenterId(), $this->getDestinationCenterId()];
default:
return [$this->getOriginCenterId()];
}
Expand Down
4 changes: 2 additions & 2 deletions modules/biobank/php/shipmentdao.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,8 @@ class ShipmentDAO extends \LORIS\Data\ProvisionerInstance
'StatusID' => $statusId,
'UserID' => $userId,
'Temperature' => $log->temperature,
'Date' => (new \DateTime($log->date))->format('Y-m-d H:i'),
'Time' => (new \DateTime($log->time))->format('Y-m-d H:i'),
'Date' => $log->date?->format('Y-m-d H:i'),
'Time' => $log->time?->format('Y-m-d H:i'),
'Comments' => $log->comments,
];
}
Expand Down
4 changes: 1 addition & 3 deletions modules/biobank/php/shipmenthandler.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,9 @@ class ShipmentHandler
* instantiates it and then sends it to the DAO to be saved to the
* database.
*
* @param array $shipmentArray shipment array to be created
*
* @return array a list of shipments objects that were created
*/
public function updateInstance(array $shipmentArray) : array
public function updateInstance() : array
{
$this->_validatePermission('update');
return $this->dao->saveInstance($this->shipment);
Expand Down
2 changes: 1 addition & 1 deletion modules/biobank/php/shipments.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Shipments implements RequestHandlerInterface
* This function can be overridden in a module's page to load the necessary
* resources to check the permissions of a user.
*
* @param User $user The user to load the resources for
* @param \User $user The user to load the resources for
* @param ServerRequestInterface $request The PSR15 Request being handled
*
* @return void
Expand Down
2 changes: 1 addition & 1 deletion modules/biobank/php/specimen.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class Specimen implements
private $parentSpecimenIds;
private $parentSpecimenBarcodes;
private $candidateId;
private $candidatePCSID;
private $candidatePSCID;
private $candidateAge;
private $sessionId;
private $sessionCenterId;
Expand Down
20 changes: 17 additions & 3 deletions modules/biobank/php/specimendao.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,10 @@ class SpecimenDAO extends \LORIS\Data\ProvisionerInstance
* @param Specimen $specimen The Specimen Object to be saved the
* database.
*
* @throws \InvalidArgumentException If required data is missing or invalid.
*
* @return Specimen $specimen The Specimen Object that was saved
to the database.
* to the database.
*/
public function saveInstance(Specimen $specimen) : Specimen
{
Expand Down Expand Up @@ -548,12 +550,24 @@ class SpecimenDAO extends \LORIS\Data\ProvisionerInstance
);
}

// Prepare project data and sent it to be saved.
// Validate that 'biobank_specimen_project_rel' exists and is an array
if (!isset($data['biobank_specimen_project_rel']) || !is_array($data['biobank_specimen_project_rel'])) {
throw new \InvalidArgumentException("'biobank_specimen_project_rel' must be a non-nullable array.");
}

// Prepare project data and send it to be saved.
foreach ($data['biobank_specimen_project_rel'] as $i => $insert) {
// Ensure each insert is an array
if (!is_array($insert)) {
throw new \InvalidArgumentException("Each project relationship must be an array.");
}

// Reference to the current project relationship
$projInsert =& $data['biobank_specimen_project_rel'][$i];

// Assign the SpecimenID to the project relationship
$projInsert['SpecimenID'] = $specimen->getId();
}
$this->_saveProject($specimen, $data);

return $this->getInstanceFromId($specimen->getId());
}
Expand Down
2 changes: 1 addition & 1 deletion modules/biobank/php/specimenendpoint.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SpecimenEndpoint extends \NDB_Page implements RequestHandlerInterface
* This function can be overridden in a module's page to load the necessary
* resources to check the permissions of a user.
*
* @param User $user The user to load the resources for
* @param \User $user The user to load the resources for
* @param ServerRequestInterface $request The PSR15 Request being handled
*
* @return void
Expand Down

0 comments on commit 40ab6f7

Please sign in to comment.