Query.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. declare(strict_types=1);
  3. namespace Doctrine\Migrations\Query;
  4. use Doctrine\Migrations\Query\Exception\InvalidArguments;
  5. use function count;
  6. /**
  7. * The Query wraps the sql query, parameters and types.
  8. */
  9. final class Query
  10. {
  11. /** @var string */
  12. private $statement;
  13. /** @var mixed[] */
  14. private $parameters;
  15. /** @var mixed[] */
  16. private $types;
  17. /**
  18. * @param mixed[] $parameters
  19. * @param mixed[] $types
  20. */
  21. public function __construct(string $statement, array $parameters = [], array $types = [])
  22. {
  23. if (count($types) > count($parameters)) {
  24. throw InvalidArguments::wrongTypesArgumentCount($statement, count($parameters), count($types));
  25. }
  26. $this->statement = $statement;
  27. $this->parameters = $parameters;
  28. $this->types = $types;
  29. }
  30. public function __toString(): string
  31. {
  32. return $this->statement;
  33. }
  34. public function getStatement(): string
  35. {
  36. return $this->statement;
  37. }
  38. /** @return mixed[] */
  39. public function getParameters(): array
  40. {
  41. return $this->parameters;
  42. }
  43. /** @return mixed[] */
  44. public function getTypes(): array
  45. {
  46. return $this->types;
  47. }
  48. }