context = $context; $this->tools = $tools; } /** * Creates an instance from an array. * * @param array{ * context?: object|null, * tools?: object|null * } $data * @phpstan-param array $data * @return self */ public static function fromArray(array $data): self { return new self( self::asObjectOrNull($data['context'] ?? null), self::asObjectOrNull($data['tools'] ?? null) ); } /** * Converts the instance to an array. * * @return array */ public function toArray(): array { $result = []; if ($this->context !== null) { $result['context'] = $this->context; } if ($this->tools !== null) { $result['tools'] = $this->tools; } return $result; } /** * @return object|null */ public function getContext(): ?object { return $this->context; } /** * @return object|null */ public function getTools(): ?object { return $this->tools; } }