public function extract($value, ExtractionContext $context = null) { if (!is_object($value)) { return $value; } return $this->hydrator->extract($value); }
/** * {@inheritDoc} */ public function hydrate($value, $property, HydrationContext $context = null) { if (is_array($value)) { $property = $this->namingStrategy->getNameForHydration($property, $context); $method = 'get' . $property; $object = $context->object->{$method}(); return $this->hydrator->hydrate($value, $object); } return $value; }
public function extract($value, ExtractionContext $context = null) { if (!is_array($value)) { return $value; } $collection = []; foreach ($value as $item) { $collection[] = $this->hydrator->extract($item); } return $collection; }
public function extract($object) { $data = $this->hydrator->extract($object); $filtered = []; foreach ($this->extractKeys as $k) { if (!isset($data[$k])) { continue; } $filtered[$k] = $data[$k]; } return $filtered; }
/** * * @dataProvider extractProvider */ public function testExtract(HydratorInterface $hydrator, $objFunc, array $expData) { $extractedData = $hydrator->extract($objFunc()); $this->assertSame($expData, $extractedData); }