public function testShouldMapValueToArray() { $val = null; $this->assertInternalType('array', Scalar::mapArray($val)); $this->assertInternalType('array', Scalar::map($val, 'array')); $this->assertSame(0, count(Scalar::mapArray($val))); }
/** * @param $type * @param $value * @return mixed */ private function mapField($type, $value) { $cacheKey = $this->getCacheKey($type, $value); if (!isset($this->mappingFieldsCache[$cacheKey])) { if (Scalar::isScalar($type)) { $this->mappingFieldsCache[$cacheKey] = Scalar::map($value, $type); } else { $class = new \ReflectionClass($type); $result = $class->getMethod('getMapped')->invoke(null, $value); if (is_object($result)) { $object = new \ReflectionObject($result); if ($object->isCloneable()) { $result = clone $result; } } $this->mappingFieldsCache[$cacheKey] = $result; } } return $this->mappingFieldsCache[$cacheKey]; }