diff options
Diffstat (limited to 'vendor/doctrine/orm/src/Mapping/JoinColumnMapping.php')
| -rw-r--r-- | vendor/doctrine/orm/src/Mapping/JoinColumnMapping.php | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/vendor/doctrine/orm/src/Mapping/JoinColumnMapping.php b/vendor/doctrine/orm/src/Mapping/JoinColumnMapping.php new file mode 100644 index 0000000..172c256 --- /dev/null +++ b/vendor/doctrine/orm/src/Mapping/JoinColumnMapping.php | |||
| @@ -0,0 +1,77 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\ORM\Mapping; | ||
| 6 | |||
| 7 | use ArrayAccess; | ||
| 8 | |||
| 9 | use function property_exists; | ||
| 10 | |||
| 11 | /** @template-implements ArrayAccess<string, mixed> */ | ||
| 12 | final class JoinColumnMapping implements ArrayAccess | ||
| 13 | { | ||
| 14 | use ArrayAccessImplementation; | ||
| 15 | |||
| 16 | public bool|null $unique = null; | ||
| 17 | public bool|null $quoted = null; | ||
| 18 | public string|null $fieldName = null; | ||
| 19 | public string|null $onDelete = null; | ||
| 20 | public string|null $columnDefinition = null; | ||
| 21 | public bool|null $nullable = null; | ||
| 22 | |||
| 23 | /** @var array<string, mixed>|null */ | ||
| 24 | public array|null $options = null; | ||
| 25 | |||
| 26 | public function __construct( | ||
| 27 | public string $name, | ||
| 28 | public string $referencedColumnName, | ||
| 29 | ) { | ||
| 30 | } | ||
| 31 | |||
| 32 | /** | ||
| 33 | * @param array<string, mixed> $mappingArray | ||
| 34 | * @psalm-param array{ | ||
| 35 | * name: string, | ||
| 36 | * referencedColumnName: string, | ||
| 37 | * unique?: bool|null, | ||
| 38 | * quoted?: bool|null, | ||
| 39 | * fieldName?: string|null, | ||
| 40 | * onDelete?: string|null, | ||
| 41 | * columnDefinition?: string|null, | ||
| 42 | * nullable?: bool|null, | ||
| 43 | * options?: array<string, mixed>|null, | ||
| 44 | * } $mappingArray | ||
| 45 | */ | ||
| 46 | public static function fromMappingArray(array $mappingArray): self | ||
| 47 | { | ||
| 48 | $mapping = new self($mappingArray['name'], $mappingArray['referencedColumnName']); | ||
| 49 | foreach ($mappingArray as $key => $value) { | ||
| 50 | if (property_exists($mapping, $key) && $value !== null) { | ||
| 51 | $mapping->$key = $value; | ||
| 52 | } | ||
| 53 | } | ||
| 54 | |||
| 55 | return $mapping; | ||
| 56 | } | ||
| 57 | |||
| 58 | /** @return list<string> */ | ||
| 59 | public function __sleep(): array | ||
| 60 | { | ||
| 61 | $serialized = []; | ||
| 62 | |||
| 63 | foreach (['name', 'fieldName', 'onDelete', 'columnDefinition', 'referencedColumnName', 'options'] as $stringOrArrayKey) { | ||
| 64 | if ($this->$stringOrArrayKey !== null) { | ||
| 65 | $serialized[] = $stringOrArrayKey; | ||
| 66 | } | ||
| 67 | } | ||
| 68 | |||
| 69 | foreach (['unique', 'quoted', 'nullable'] as $boolKey) { | ||
| 70 | if ($this->$boolKey !== null) { | ||
| 71 | $serialized[] = $boolKey; | ||
| 72 | } | ||
| 73 | } | ||
| 74 | |||
| 75 | return $serialized; | ||
| 76 | } | ||
| 77 | } | ||
