*/ final class JoinColumnMapping implements ArrayAccess { use ArrayAccessImplementation; public bool|null $unique = null; public bool|null $quoted = null; public string|null $fieldName = null; public string|null $onDelete = null; public string|null $columnDefinition = null; public bool|null $nullable = null; /** @var array|null */ public array|null $options = null; public function __construct( public string $name, public string $referencedColumnName, ) { } /** * @param array $mappingArray * @psalm-param array{ * name: string, * referencedColumnName: string, * unique?: bool|null, * quoted?: bool|null, * fieldName?: string|null, * onDelete?: string|null, * columnDefinition?: string|null, * nullable?: bool|null, * options?: array|null, * } $mappingArray */ public static function fromMappingArray(array $mappingArray): self { $mapping = new self($mappingArray['name'], $mappingArray['referencedColumnName']); foreach ($mappingArray as $key => $value) { if (property_exists($mapping, $key) && $value !== null) { $mapping->$key = $value; } } return $mapping; } /** @return list */ public function __sleep(): array { $serialized = []; foreach (['name', 'fieldName', 'onDelete', 'columnDefinition', 'referencedColumnName', 'options'] as $stringOrArrayKey) { if ($this->$stringOrArrayKey !== null) { $serialized[] = $stringOrArrayKey; } } foreach (['unique', 'quoted', 'nullable'] as $boolKey) { if ($this->$boolKey !== null) { $serialized[] = $boolKey; } } return $serialized; } }