isList = $list; $this->propertyName = $propertyName; $this->className = $className && class_exists($className) ? $className : null; } /** * @param mixed $value * * @return mixed */ public function getValue(ResourceInterface $resource, $value) { if (null === $value || !$this->className) { return $value; } elseif ($this->isList && is_array($value)) { $array = []; foreach ($value as $subVal) { $array[] = $resource->model($this->className, $subVal); } return $array; } elseif (\DateTimeImmutable::class === $this->className) { return new \DateTimeImmutable($value); } return $resource->model($this->className, $value); } }