Ejemplo n.º 1
0
 public function extract($value, ExtractionContext $context = null)
 {
     if (!is_object($value)) {
         return $value;
     }
     return $this->hydrator->extract($value);
 }
Ejemplo n.º 2
0
 /**
  * {@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;
 }
Ejemplo n.º 4
0
 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;
 }
Ejemplo n.º 5
0
 /**
  *
  * @dataProvider extractProvider
  */
 public function testExtract(HydratorInterface $hydrator, $objFunc, array $expData)
 {
     $extractedData = $hydrator->extract($objFunc());
     $this->assertSame($expData, $extractedData);
 }