$payload * @param array $parameters */ private function __construct( private array $payload, private array $parameters, ) {} /** * @param array $contract * @param array $parameters */ public static function fromVerifiedArray( array $contract, ExchangePowerShellCommandContracts $contracts, array $parameters = [], ): self { $validation = $contracts->validateInvocation($contract, $parameters); if (! $validation['accepted']) { throw new InvalidArgumentException('Exchange PowerShell command contract was not verified.'); } $commandName = $contract['command_name'] ?? null; $canonicalContract = is_string($commandName) ? $contracts->contractForCommandName($commandName) : null; if (! is_array($canonicalContract)) { throw new InvalidArgumentException('Exchange PowerShell command contract was not canonical.'); } return new self($canonicalContract, $parameters); } /** * @return array */ public function toArray(): array { return $this->payload; } /** * @return array */ public function parameters(): array { return $this->parameters; } /** * @return list */ public function parameterNames(): array { return array_values(array_map('strval', array_keys($this->parameters))); } }