-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f835447
commit 7648555
Showing
2 changed files
with
87 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
modules/api/php/views/visit/instrument_0_0_4_dev.class.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php declare(strict_types=1); | ||
/** | ||
* PHP Version 7 | ||
* | ||
* @category ApiViews | ||
* @package Loris | ||
* @author Xavier Lecours Boucher <xavier.lecours@mcin.ca> | ||
* @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 | ||
* @link https://github.com/aces/Loris/ | ||
*/ | ||
|
||
namespace LORIS\api\Views\Visit; | ||
|
||
/** | ||
* Creates a representation of a visit intrument following the api response | ||
* specifications. | ||
* | ||
* @category ApiViews | ||
* @package Loris | ||
* @author Xavier Lecours Boucher <xavier.lecours@mcin.ca> | ||
* @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 | ||
* @link https://github.com/aces/Loris/ | ||
*/ | ||
|
||
class Instrument_0_0_4_Dev | ||
{ | ||
private $_timepoint; | ||
private $_instrument; | ||
|
||
/** | ||
* Constructor which sets the instance variables based on the provided timepoint | ||
* and instrument. | ||
* | ||
* @param \Timepoint $timepoint The timepoint to represent | ||
* @param \NDB_BVL_Instrument $instrument The instrument. | ||
*/ | ||
public function __construct( | ||
\Timepoint $timepoint, | ||
\NDB_BVL_Instrument $instrument | ||
) { | ||
$this->_timepoint = $timepoint; | ||
$this->_instrument = $instrument; | ||
} | ||
|
||
/** | ||
* Creates an serializable array of this object's data | ||
* | ||
* @return array | ||
*/ | ||
public function toArray(): array | ||
{ | ||
$instrumentname = $this->_instrument->testName; | ||
$instrumentdata = $this->_instrument->getInstanceData(); | ||
|
||
$isDDE = strpos($instrumentdata['CommentID'], 'DDE_') === 0; | ||
|
||
$meta = [ | ||
'Candidate' => $this->_timepoint->getCandID(), | ||
'Visit' => $this->_timepoint->getVisitLabel(), | ||
'DDE' => $isDDE, | ||
'Instrument' => $instrumentname, | ||
]; | ||
|
||
$instrument = ['Data' => $instrumentdata]; | ||
|
||
return array_merge( | ||
['Meta' => $meta], | ||
$instrument | ||
); | ||
} | ||
} | ||
|