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
216 changes: 110 additions & 106 deletions clients/GitHubEnterprise-3.13/etc/openapi-client-generator.state

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

declare(strict_types=1);

namespace ApiClients\Client\GitHubEnterprise\Internal\Attribute\CastUnionToType\Schema\Integration;

use ApiClients\Client\GitHubEnterprise\Schema;
use Attribute;
use EventSauce\ObjectHydrator\ObjectMapper;
use EventSauce\ObjectHydrator\PropertyCaster;
use Throwable;

use function array_keys;
use function array_unique;
use function implode;
use function is_array;
use function sort;

#[Attribute(Attribute::TARGET_PARAMETER)]
final class Owner implements PropertyCaster
{
public function cast(mixed $value, ObjectMapper $hydrator): mixed
{
if (is_array($value)) {
$signatureChunks = array_unique(array_keys($value));
sort($signatureChunks);
$signature = implode('|', $signatureChunks);
if ($signature === 'avatar_url|email|events_url|followers_url|following_url|gists_url|gravatar_id|html_url|id|login|name|node_id|organizations_url|received_events_url|repos_url|site_admin|starred_at|starred_url|subscriptions_url|type|url|user_view_type') {
try {
return $hydrator->hydrateObject(Schema\SimpleUser::class, $value);
} catch (Throwable) {
}
}

if ($signature === 'avatar_url|created_at|description|html_url|id|name|node_id|slug|updated_at|website_url') {
try {
return $hydrator->hydrateObject(Schema\Enterprise::class, $value);
} catch (Throwable) {
}
}
}

return $value;
}
}
Loading
Loading