Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/Transfer/AbstractTransfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ final public function toArray(): array

foreach (static::META_DATA as $index => $propertyName) {
$data[$propertyName] = isset($attributes[$propertyName])
? $attributes[$propertyName]->toArray($this->{$propertyName})
? $attributes[$propertyName]->toArray($this->_data[$index])
: $this->_data[$index];
}

Expand All @@ -118,6 +118,7 @@ final public function fromArray(array $data): static
}

$attributes = $this->getTypeAttributes();

foreach ($data as $propertyName => $value) {
$this->{$propertyName} = isset($attributes[$propertyName])
? $attributes[$propertyName]->fromArray($value)
Expand Down
27 changes: 13 additions & 14 deletions src/TransferGenerator/Definition/Enum/BuildInTypeEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,26 @@ enum BuildInTypeEnum: string
case ARRAY = 'array';
case ARRAY_OBJECT = 'ArrayObject';

private const array IS_ALLOWED = [
self::BOOL,
self::TRUE,
self::FALSE,
self::INT,
self::FLOAT,
self::STRING,
self::ARRAY,
self::ARRAY_OBJECT,
];

case ITERABLE = 'iterable';
case NULL = 'null';
case OBJECT = 'object';
case MIXED = 'mixed';
case CALLABLE = 'callable';

private const array NOT_ALLOWED = [
self::ITERABLE,
self::NULL,
self::OBJECT,
self::MIXED,
self::CALLABLE,
];

public static function getTrueFalse(bool $value): self
{
if ($value === true) {
return self::TRUE;
}

return self::FALSE;
return $value === true ? self::TRUE : self::FALSE;
}

public function isArray(): bool
Expand All @@ -50,6 +49,6 @@ public function isArrayObject(): bool

public function isAllowed(): bool
{
return !in_array($this, self::NOT_ALLOWED, true);
return in_array($this, self::IS_ALLOWED, true);
}
}