/** * {@inheritdoc} * @see BaseAdapter::toEntity() */ public function toEntity($data) { $entity = parent::toEntity($data); $converterRules = $this->getRules(); if (!is_object($data)) { $data = (object) $data; } if (!empty($converterRules[static::RULE_TYPE_SETTINGS])) { $collection = $this->getSettingsCollection($entity); foreach ($this->getSettingsRules() as $key => $property) { $key = is_int($key) ? $property : $key; $collection[$key] = $data->{$property}; } } return $entity; }
/** * @test * @dataProvider providerToEntity() */ public function testToEntity($rules, $data, $cb) { $adapter = new BaseAdapter(); $adapter->setEntityClass(self::OS_CLASS_NAME); $adapter->setRules($rules); $cb($adapter->toEntity($data)); }