mapByProperties($this->getProps(), $item); } /** * Map a collection of Decisions * * @see self::map */ public function mapMany(Enumerable $collection): Enumerable { $this->collection = $collection; return $collection->map(function ($item) { return $this->map($item); }); } /** * Map schema properties of a Decision to an assoc array */ protected function mapByProperties(array $props, Decision $item): array { $type = Repo::decision()->getDecisionType($item->getData('decision')); $output = []; foreach ($props as $prop) { switch ($prop) { case '_href': $output[$prop] = $this->getApiUrl('submissions/' . (int) $item->getData('submissionId') . '/decisions/' . (int) $item->getId()); break; case 'description': $output[$prop] = $type ? $type->getDescription() : ''; break; case 'label': $output[$prop] = $type ? $type->getLabel() : ''; break; default: $output[$prop] = $item->getData($prop); break; } } ksort($output); return $this->withExtensions($output, $item); } }