vendor/doctrine/orm/src/Query/Expr/Join.php line 14

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Doctrine\ORM\Query\Expr;
  4. use function strtoupper;
  5. /**
  6. * Expression class for DQL join.
  7. *
  8. * @link www.doctrine-project.org
  9. */
  10. class Join
  11. {
  12. public const INNER_JOIN = 'INNER';
  13. public const LEFT_JOIN = 'LEFT';
  14. public const ON = 'ON';
  15. public const WITH = 'WITH';
  16. /**
  17. * @var string
  18. * @phpstan-var self::INNER_JOIN|self::LEFT_JOIN
  19. */
  20. protected $joinType;
  21. /** @var string */
  22. protected $join;
  23. /** @var string|null */
  24. protected $alias;
  25. /**
  26. * @var string|null
  27. * @phpstan-var self::ON|self::WITH|null
  28. */
  29. protected $conditionType;
  30. /** @var string|Comparison|Composite|Func|null */
  31. protected $condition;
  32. /** @var string|null */
  33. protected $indexBy;
  34. /**
  35. * @param string $joinType The condition type constant. Either INNER_JOIN or LEFT_JOIN.
  36. * @param string $join The relationship to join.
  37. * @param string|null $alias The alias of the join.
  38. * @param string|null $conditionType The condition type constant. Either ON or WITH.
  39. * @param string|Comparison|Composite|Func|null $condition The condition for the join.
  40. * @param string|null $indexBy The index for the join.
  41. * @phpstan-param self::INNER_JOIN|self::LEFT_JOIN $joinType
  42. * @phpstan-param self::ON|self::WITH|null $conditionType
  43. */
  44. public function __construct($joinType, $join, $alias = null, $conditionType = null, $condition = null, $indexBy = null)
  45. {
  46. $this->joinType = $joinType;
  47. $this->join = $join;
  48. $this->alias = $alias;
  49. $this->conditionType = $conditionType;
  50. $this->condition = $condition;
  51. $this->indexBy = $indexBy;
  52. }
  53. /**
  54. * @return string
  55. * @phpstan-return self::INNER_JOIN|self::LEFT_JOIN
  56. */
  57. public function getJoinType()
  58. {
  59. return $this->joinType;
  60. }
  61. /** @return string */
  62. public function getJoin()
  63. {
  64. return $this->join;
  65. }
  66. /** @return string|null */
  67. public function getAlias()
  68. {
  69. return $this->alias;
  70. }
  71. /**
  72. * @return string|null
  73. * @phpstan-return self::ON|self::WITH|null
  74. */
  75. public function getConditionType()
  76. {
  77. return $this->conditionType;
  78. }
  79. /** @return string|Comparison|Composite|Func|null */
  80. public function getCondition()
  81. {
  82. return $this->condition;
  83. }
  84. /** @return string|null */
  85. public function getIndexBy()
  86. {
  87. return $this->indexBy;
  88. }
  89. /** @return string */
  90. public function __toString()
  91. {
  92. return strtoupper($this->joinType) . ' JOIN ' . $this->join
  93. . ($this->alias ? ' ' . $this->alias : '')
  94. . ($this->indexBy ? ' INDEX BY ' . $this->indexBy : '')
  95. . ($this->condition ? ' ' . strtoupper($this->conditionType) . ' ' . $this->condition : '');
  96. }
  97. }