Skip to content

Commit

Permalink
PHPCS
Browse files Browse the repository at this point in the history
  • Loading branch information
driusan committed Jun 20, 2023
1 parent 6d33c73 commit 1b0a23b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
8 changes: 6 additions & 2 deletions modules/api/php/endpoints/project/project.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ class Project extends Endpoint implements \LORIS\Middleware\ETagCalculator
public function handle(ServerRequestInterface $request) : ResponseInterface
{
$apiversion = $request->getAttribute("LORIS-API-Version") ?? "unknown";
$pathparts = $request->getAttribute('pathparts');
$pathparts = $request->getAttribute('pathparts');

if (count($pathparts) === 0) {
switch ($request->getMethod()) {
case 'GET':
Expand Down Expand Up @@ -134,6 +135,8 @@ class Project extends Endpoint implements \LORIS\Middleware\ETagCalculator
* Generates a JSON representation of this project following the API
* specification.
*
* @param string $version The version of the API the GET is for.
*
* @return ResponseInterface
*/
private function _handleGET($version): ResponseInterface
Expand All @@ -159,6 +162,7 @@ class Project extends Endpoint implements \LORIS\Middleware\ETagCalculator
*/
public function ETag(ServerRequestInterface $request) : string
{
return md5(json_encode($this->_handleGET($request)->getBody()));
$apiversion = $request->getAttribute("LORIS-API-Version") ?? "unknown";
return md5(json_encode($this->_handleGET($apiversion)->getBody()));
}
}
12 changes: 8 additions & 4 deletions modules/api/php/views/project.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class Project
/**
* Constructor
*
* @param \Project $project The project to format
* @param \Project $project The project to format
* @param string $apiversion The version of the API being accessed
*/
public function __construct(\Project $project, private string $apiversion = '')
{
Expand All @@ -58,9 +59,12 @@ class Project
'Visits' => $this->_getVisits(),
];
if ($this->apiversion == 'v0.0.4-dev') {
$obj['Cohorts'] = array_map(function($cohort) {
return $cohort['title'];
}, $this->_project->getCohorts());
$obj['Cohorts'] = array_map(
function ($cohort) {
return $cohort['title'];
},
$this->_project->getCohorts()
);
}
return $obj;
}
Expand Down
19 changes: 11 additions & 8 deletions modules/api/php/views/visit.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ class Visit
/**
* Constructor which sets the instance variables based on the provided timepoint
*
* @param \Timepoint $timepoint The timepoint to represent
* @param \Timepoint $timepoint The timepoint to represent
* @param string $apiversion The version of the API being used
*/
public function __construct(\Timepoint $timepoint, private string $apiversion = 'v0.0.3')
{
public function __construct(
\Timepoint $timepoint,
private string $apiversion = 'v0.0.3'
) {
$this->_timepoint = $timepoint;
}

Expand All @@ -44,12 +47,12 @@ class Visit
public function toArray(): array
{
$cohortKey = $this->apiversion == 'v0.0.4-dev' ? 'Cohort' : 'Battery';
$meta = [
'CandID' => $this->_timepoint->getCandID(),
'Visit' => $this->_timepoint->getVisitLabel(),
'Site' => $this->_timepoint->getPSC(),
$meta = [
'CandID' => $this->_timepoint->getCandID(),
'Visit' => $this->_timepoint->getVisitLabel(),
'Site' => $this->_timepoint->getPSC(),
$cohortKey => $this->_timepoint->getData('CohortTitle'),
'Project' => $this->_timepoint->getProject(),
'Project' => $this->_timepoint->getProject(),
];

$stages = [];
Expand Down

0 comments on commit 1b0a23b

Please sign in to comment.