public function testMakeTransferType() { $a = AbstractTransfer::makeTransfer('\\Hitmeister\\Component\\Api\\Transfers\\StatusPingTransfer', []); $this->assertInstanceOf('\\Hitmeister\\Component\\Api\\Transfers\\StatusPingTransfer', $a); }
/** * @param array $data */ public function fromArray(array $data) { foreach ($data as $name => $rawValue) { try { $this->validateProperty($name); } catch (UnexpectedPropertyException $e) { continue; } $this->validateMulti($name, $rawValue); $type = $this->getCustomType($name); if (null === $type) { $value = $rawValue; } else { if (!$this->isMulti($name)) { $value = is_null($rawValue) ? null : AbstractTransfer::makeTransfer($type, $rawValue); } else { $value = []; foreach ($rawValue as $item) { $value[] = AbstractTransfer::makeTransfer($type, $item); } } } $this->data[$name] = $value; } }
/** * @return AbstractTransfer|null */ private function getCurrent() { // Check transfer first if (isset($this->transferData[$this->position])) { return $this->transferData[$this->position]; } // Check raw data next, build transfer if (isset($this->rawData[$this->position])) { $this->transferData[$this->position] = AbstractTransfer::makeTransfer($this->transferClass, $this->rawData[$this->position]); return $this->transferData[$this->position]; } return null; }