vendor/doctrine/orm/lib/Doctrine/ORM/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.      * @psalm-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.      * @psalm-var self::ON|self::WITH|null
  28.      */
  29.     protected $conditionType;
  30.     /** @var string|Comparison|Composite|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|null $condition     The condition for the join.
  40.      * @param string|null                      $indexBy       The index for the join.
  41.      * @psalm-param self::INNER_JOIN|self::LEFT_JOIN $joinType
  42.      * @psalm-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.      * @psalm-return self::INNER_JOIN|self::LEFT_JOIN
  56.      */
  57.     public function getJoinType()
  58.     {
  59.         return $this->joinType;
  60.     }
  61.     /**
  62.      * @return string
  63.      */
  64.     public function getJoin()
  65.     {
  66.         return $this->join;
  67.     }
  68.     /**
  69.      * @return string|null
  70.      */
  71.     public function getAlias()
  72.     {
  73.         return $this->alias;
  74.     }
  75.     /**
  76.      * @return string|null
  77.      * @psalm-return self::ON|self::WITH|null
  78.      */
  79.     public function getConditionType()
  80.     {
  81.         return $this->conditionType;
  82.     }
  83.     /**
  84.      * @return string|Comparison|Composite|null
  85.      */
  86.     public function getCondition()
  87.     {
  88.         return $this->condition;
  89.     }
  90.     /**
  91.      * @return string|null
  92.      */
  93.     public function getIndexBy()
  94.     {
  95.         return $this->indexBy;
  96.     }
  97.     /**
  98.      * @return string
  99.      */
  100.     public function __toString()
  101.     {
  102.         return strtoupper($this->joinType) . ' JOIN ' $this->join
  103.              . ($this->alias ' ' $this->alias '')
  104.              . ($this->indexBy ' INDEX BY ' $this->indexBy '')
  105.              . ($this->condition ' ' strtoupper($this->conditionType) . ' ' $this->condition '');
  106.     }
  107. }