/** * @param mixed $item * * @return mixed */ public function convert($item) { foreach ($this->mappings as $mapping) { if (!empty($mapping['from']) && !empty($mapping['to'])) { $item = Vale::set($item, $mapping['to'], Vale::get($item, $mapping['from'])); if ($mapping['remove']) { $item = Vale::remove($item, $mapping['from']); } } elseif (!empty($mapping['to'])) { $item = Vale::set([], $mapping['to'], $item); } elseif (!empty($mapping['from'])) { $item = Vale::get($item, $mapping['from']); } } return $item; }
/** * @test * @covers Cocur\Vale\Vale::remove() */ public function removeRemovesValue() { $result = Vale::remove(['name' => 'Tyrion'], ['name']); $this->assertFalse(isset($result['name'])); }