Quantcast
Channel: Recent Gists from assertchris
Viewing all articles
Browse latest Browse all 30

composition.php

$
0
0
composition.php
<?php
class RequestId
{
}
class ClientId
{
}
class AgencyId
{
}
class AgencyUserId
{
}
class ServiceId
{
}
class Deps
{
public function __construct(
public ?RequestId $requestId = null,
public ?ClientId $clientId = null,
public ?AgencyId $agencyId = null,
public ?AgencyUserId $agencyUserId = null,
public ?ServiceId $serviceId = null,
) {
}
public function unpack(): array
{
return array_filter([
'requestId' => $this->requestId ?? null,
'clientId' => $this->clientId ?? null,
'agencyId' => $this->agencyId ?? null,
'agencyUserId' => $this->agencyUserId ?? null,
'serviceId' => $this->serviceId ?? null,
]);
}
}
class Opened
{
public function __construct(
public RequestId $requestId,
public ClientId $clientId,
public ServiceId $serviceId,
) {
}
}
function deps(...$things): array
{
return (new Deps(...$things))->unpack();
}
$opened = new Opened(...deps(
requestId: new RequestId(),
clientId: new ClientId(),
serviceId: new ServiceId(),
));
print_r($opened);

Viewing all articles
Browse latest Browse all 30

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>